sound command & music


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    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

  2. #2
    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.

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


    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 " !!!
    *****************************************

  4. #4
    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.

  5. #5
    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

  6. #6
    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

  7. #7
    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

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 : 0

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