sound command & music


Closed Thread
Results 1 to 15 of 15
  1. #1
    trying's Avatar
    trying Guest

    Smile sound command & music

    way back when I found a web site that had a lot of music code for using PBP and sound command . but I can no longer find it. Anybody know of a good site. trying to have fun with the grandkids.
    thanks

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Here's a sound demo (yankeedoodle) for 12F675...

    http://www.picbasic.co.uk/forum/showthread.php?t=64

  3. #3
    trying's Avatar
    trying Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Melanie the kids loveed it just wondering it a LCDOUT command "yankie doodle xxxxxxxx"could be put at the beginning and another one after Data $01,$52,$4E,$20"stuck a feather in his capxxxxxx"
    to show the words
    Last edited by trying; - 18th May 2006 at 14:13.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink The chauve must go on ...

    May be here also ...

    http://www.rc-float-flying.rchomepag.../PIC/Sound.htm

    héhé,

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    It's a tiny little music routrine that reads four Bytes from EEPROM and acts on it. If you changed it say to FIVE bytes, then use Byte5 (if say non-zero) to indicate what you want to display. Kinda tough on a 12F chip, because lack of pins means you're having to drive a Serial LCD to send your message, and the Serial LCD will take time (even at 9600 baud), so it will impact on the music giving you an abnormal pause between notes. Better if you choose a PIC with more pins.

  6. #6
    trying's Avatar
    trying Guest


    Did you find this post helpful? Yes | No

    Smile

    Sorry Melanie
    I was going to use a 16f630. and not use the words in real time
    lcdout $FE,1 "yankiexxxxxxxx"
    lcdout $FE, $C0 "xxxxxxpony"
    displayed then start the music
    but I not sure how to insert the second
    lcdout $FE,1 "stuckxxxxxxxx"
    lcdout $FE, $C0 "xxxxxxmacorone?"
    after the $20 Gf7
    this is for 5 years olds it can miss a beat or two. LAL
    thanks for anyhelp

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    That's really simple, tear the code appart and you discover that variable CounterA is a pointer into EEPROM starting at Address location 1 (for the first line)...

    CounterA=1

    Then after each note is played, we increment it by four...

    CounterA=CounterA+4

    So CounterA is pointing to the note currently being played... simply do something like this...

    Code:
    MusicalLoop:		
    	If CounterA=1 then LCDOut $FE,1,"Yankee Doodle"
    	If CounterA=17 then LCDOut $FE,$C0,"went to town"
    	If CounterA=33 then LCDOut $FE,1,"A-riding on",$FE,$C0," a pony"
    	If CounterA=57 then LCDOut $FE,1,"Stuck a feather"
    	If CounterA=73 then LCDOut $FE,$C0," in his hat"
    	If CounterA=85 then LCDOut $FE,1,"And called it",$FE,$C0," macaroni.
    	Read CounterA,NotePeriod.Highbyte
    	If NotePeriod.Highbyte=$FF then
    		LCDOut $FE,1
    		Pause 2000
    		Goto RestartLoop
    		endif
    	Read CounterA+1,NotePeriod.Lowbyte
    	Read CounterA+2,CounterB
    	NoteRepeat=CounterB*10
    	Read CounterA+3,CounterB
    	MessagePrompt=MessagePrompt+1
    	NotePause=CounterB*10
    	CounterA=CounterA+4
    	MessageNote
    	Gosub PlayNote
    	Goto MusicalLoop
    Only on this forum... rocket science for 5-year-olds (by five year olds!!).

    If you want to go more advanced... you can have the words appearing prior to every note...

    Code:
    	If CounterA=1 then LCDOut $FE,1,"Yan"
    	If CounterA=5 then LCDOut "kee "
    	If CounterA=9 then LCDOut "Doo"
    	If CounterA=13 then LCDOut "dle"
    	If CounterA=17 then LCDOut $FE,$C0,"went "
    	If CounterA=21 then LCDOut "to "
    	If CounterA=25 then LCDOut "town"
    etc etc

  8. #8
    trying's Avatar
    trying Guest


    Did you find this post helpful? Yes | No

    Smile

    Melanie your wonderful (bet you get told that a lot) it worked like charm!
    Now the grand kids will have there very own Karoke machine
    made by Papa

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    And now, if you want to do a 'little' improvement, you may use a PIC with a HPWM module and, if possible, use this module to generate the tone. This may avoid some unwanted 'distortion' in the tones. HPWM will continue to play the tone, while sending your info to the LCD. BUT as i'd didn't heard the actual result, i can't say if it's going to be a real improvement.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    trying's Avatar
    trying Guest


    Did you find this post helpful? Yes | No

    Default

    As I study the "Yankee" code more I understand CounterA is READing the DATA but I am still not sure how take the note from a frequency to DATA
    grand kids say more music papa
    can some one explain this were a newbie can understand it
    thanks.

    ' Musical Note/Frequency/Period/Cycles for 250mS
    ' Cs means C Sharp
    ' Df means D Flat
    '
    ' There are four Data statements per Note...
    ' Byte 1 is the MSB of half the Period Frequency
    ' Byte 2 is the LSB of above
    ' Byte 3 is the number of cycles the note will play for
    ' (divided by ten). All the notes have been calculated
    ' to Beep for approx 250mS except the last two notes
    ' of each line which are twice as long.
    ' Byte 4 is the time delay in mS (divided by ten)
    ' that follows any given played note.

    Data $01,$3F,$27,$10 ' G7 - 1567.98Hz 638uS 390c
    Data $01,$3F,$27,$10 ' G7
    Data $01,$1C,$2C,$10 ' A7 - 1760.00Hz 568uS 440c

  11. #11


    Did you find this post helpful? Yes | No

    Default

    Hi Trying. Hi Steve. Using the PWM module is a BIG improvement as each note will be perfectly on key. I converted some tunes into HPWM commands to play music on one of the PWM ports on a 16F818. The 818 can hold about 2 or 3 songs, the 16F819 can hold about 5 and a 16F88 that I used holds 8 different tunes. Below are 2 of them. If you want more volume, output the CCP1 pin to the gate of a FET. Source to ground and speaker from drain to B+. It will be painfully loud. I used a logic-level IRLZ44N at 3 Volts for this. Add the command CCP1CON = 0 and make the port LOW at the end of the song otherwise the FET may be left ON and kill the battery. CAUTION - writing songs and playing them on a PIC can be addicting! Be prepared to spend countless hours writing code.

    BABABLACKSHEEP:
    HPwm 1,127,262:Pause 320
    HPwm 1,127,262:Pause 320
    HPwm 1,127,392:Pause 320
    HPwm 1,127,392:Pause 320
    HPwm 1,127,440:Pause 160
    HPwm 1,127,494:Pause 160
    HPwm 1,127,523:Pause 160
    HPwm 1,127,440:Pause 160
    HPwm 1,127,392:Pause 320
    HPwm 1,127,000:Pause 320
    HPwm 1,127,349:Pause 320
    HPwm 1,127,349:Pause 320
    HPwm 1,127,330:Pause 320
    HPwm 1,127,330:Pause 320
    HPwm 1,127,294:Pause 320
    HPwm 1,127,294:Pause 320
    HPwm 1,127,262:Pause 320
    Pause 1000
    GoTo BABABLACKSHEEP

    STARSPANGLEDBANNER:
    HPwm 1,127,698:Pause 320
    HPwm 1,127,587:Pause 320
    HPwm 1,127,466:Pause 640
    HPwm 1,127,587:Pause 640
    HPwm 1,127,698:Pause 640
    HPwm 1,127,932:Pause 640
    HPwm 1,127,000:Pause 640
    HPwm 1,127,1175:Pause 320
    HPwm 1,127,1047:Pause 320
    HPwm 1,127,932:Pause 640
    HPwm 1,127,587:Pause 640
    HPwm 1,127,659:Pause 640
    HPwm 1,127,698:Pause 640
    HPwm 1,127,000:Pause 320
    HPwm 1,127,698:Pause 320
    HPwm 1,127,698:Pause 320
    HPwm 1,127,1175:Pause 640
    HPwm 1,127,1047:Pause 320
    HPwm 1,127,932:Pause 640
    HPwm 1,127,880:Pause 640
    HPwm 1,127,000:Pause 640
    HPwm 1,127,784:Pause 320
    HPwm 1,127,880:Pause 320
    HPwm 1,127,932:Pause 640
    HPwm 1,127,932:Pause 640
    HPwm 1,127,698:Pause 640
    HPwm 1,127,587:Pause 640
    HPwm 1,127,466:Pause 640
    Pause 1000
    GOTO STARSPANGLEDBANNER

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Funny things amuse grand kids here!
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=881&stc=1&d=1148640458 ">

    Now if there's any existing software to convert music sheet or MIDI sequence to note/duration table it could be just much easy... i'm sure it exist.
    Attached Images Attached Images  
    Last edited by mister_e; - 26th May 2006 at 11:50.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink Music ... yessss

    Hi, Steve,

    In my old papers (Electronique pratique 277 )... i've found something interesting !!!

    See a 16F84 reading a 24C256 gives 4 sec of sound.

    ...output on portB with a R -2R ladder ... amp is a LM386.

    Buuuuuut, where it becomes interesting ... is you can load the EEPROM using the Windows sound recorder ... aha !!!

    now, the Wave file has 58 bytes at top to config ...to wipe off !!!

    in the Wav-bin.exe, that's done automatically.

    then just have to load the EEPROM...

    Listen, that's all !!!

    Alain

    Problem ... the 200Kb limit is widely exploded !!! ... have an address to post that ???
    Last edited by Acetronics2; - 26th May 2006 at 13:26.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Dropped in your PM !

    Interesting but there's some additionnal hardware. Even some ISDXXX chipcoder would do the job as well. Let's see what we can with your suggestion. Will report something here... one day... when i'll found time to play 'round.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  15. #15
    trying's Avatar
    trying Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    Funny things amuse grand kids here!
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=881&stc=1&d=1148640458 ">

    Now if there's any existing software to convert music sheet or MIDI sequence to note/duration table it could be just much easy... i'm sure it exist.
    thats great guys but thats wayyyyyy over my head (right now)
    ok mister_e I just finished a spead sheet with excel that has 4 octaves of notes gives you the note freq,period time,note repete time and other things
    for 1/16,1/4,1/2 and whole notes. but I'm stuck on how to use this with
    MSB, LSB, in data the way Melanie used it in "Yankee doodle" for give me for not knowing how to ask the right ?'s but I sure need help on this in simple terms.
    thanks trying

Similar Threads

  1. Delayed output 10 secs
    By lilimike in forum mel PIC BASIC Pro
    Replies: 37
    Last Post: - 14th October 2011, 06:28
  2. comp music with pic Sounds - Aka BeepMaster
    By flipper_md in forum Code Examples
    Replies: 18
    Last Post: - 20th September 2010, 06:04
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. Sound and sound control with minimal parts
    By bartman in forum General
    Replies: 23
    Last Post: - 18th January 2005, 14:08
  5. Re: quick fix for sound command?
    By Melanie in forum Code Examples
    Replies: 0
    Last Post: - 9th July 2004, 01:44

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts