Piezo music... Happy Birthday to you
hmlittle59
Posts: 404
in BASIC Stamp
Hello All,
Has anyone ever posted PBASIC Code for the song "Happy Birthday to you"? If so were can I get it. I saw the Parallax video about it, but no way can I ever put it together.
Thanks for any help
Has anyone ever posted PBASIC Code for the song "Happy Birthday to you"? If so were can I get it. I saw the Parallax video about it, but no way can I ever put it together.
Thanks for any help
Comments
Do you know of this resource? https://forums.parallax.com/discussion/115409/playing-sheet-music-with-the-piezospeaker
With the next post, you should be in business! Good luck.
Its now time to enter the "Happy Birthday" code to my programs and I must admit. I'm 100 times more confused with this new knowledge then I was before. I've found 3 or 4 songs and on the BS2p 48pin they sound horrible. I know the FREQ. is off but don't know if to take it up or down,,,left or right :zombie:
I've seen the video (some links now broken) and links no longer available under new Parallax Site layout. (that I can find). Don't know any NOTE's.
I will read it over and over and over again. Maybe the light will come on. >:(
Will re read the What's a Microcontroller about again also.
Thanks
Page 253 of WAM 3.0 lists the frequencies of several piano keys.
Note that the center of the spiral of the Treble or G-Clef is actually note G4 but It's bumped up to G6 for the piezo so it sounds better.
Also the BS2p runs faster than the BS2 so the FREQOUT frequency and duration values will need to be adjusted.
FREQOUT is on page 199 of the BASIC Stamp Manual [Page 203 of the PDF].
You need to multiply the frequency by 3.77 and the duration by 0.265 to use BS2 code on the BS2p.
Thanks for all the help. I'm giving it another go at this time.
Back to the WAM file also. Don't know how to relate the Piano key freq. yet
Here we go.
Thanks again.
Gave up for now. Have read and down loaded some PBASIC short songs. I guess I am learning, just don't feel like it. Thanks to Whit for the Sheet music....but, don't know how to match anything up.
Tomorrow.
Thanks
I find it easiest to convert a song to RTTTL and then use the RTTTL player in WAM.
Since the program is large it's available as a download if you haven't already entered it in.
I did look at that in WAM, I will look at that again and see if I can make some headway.
Thanks
Some progress. Got the Twinkle Twinkle to play from Parallax and then converted it over to Happy Birthday. First I had to get a Google the song that included the Notes(letters, a,b,c...etc.). Sounds horrible but you can tell it's the song. Lots more work to do.
For some reason it will not stop looping over a count of 15....
Thanks again...will update.
First store the notes, their frequencies, and the note lengths. In this case I have stored three octaves of each note.
Then for happy birthday, you just call each note like this: In spin the playnote methods look like this... For my use case the freqStart method actually just runs forever in a separate cog and responds to changes in the value of "notex". I hope this helps, the frequencies may have to be adjusted for pbasic...
He's using a BASIC Stamp, not a Propeller.
hmlittle59,
Double check your code for an error or there might be a DATA value for the number of notes.
It's best if you post your code.
That code made my head start hurting all over again. :zombie: :clown:
It seems to be "ALMOST" working, but the "FREQ." just not working together from the sheet that I downloaded (D6,D7,D8).
Will keep plugging away.
I think that I've got it working.....kinda of sort of.....
I've tuned it, but it will need some fine tuning. The pitch (freq.) is a little off, but I can hear it. I go thru it twice (14 notes) of "Happy Birthday to you" pause 175 then once again.
Thanks to all for helping to really really reduce my learning curve. Could not have done it on my own and that's a fact...
PS: Now, maybe I can start to use my 25 yr old keyboard that's sitting here.....NOT BEING USED.
Now I have to patch it into my code.
Thanks again.
The Math can be done to reduce the code from BS2 to BS2p.
'
Edited Aug 31, 2018...OOP's
Corrected "PAUSE" # 5 from 360 to 300.... and Corrected "NOTE" #12 to 2794.
my bad.
thanks