Question on Piezo Speaker?
does anybody know where i can find people who have taken midis for example mary
had a little lamb and translated it to basic stamp code so that piezo speaker would play it.
Im aware that there is one for mary had a little lamb but i was wondering if there was a site
where other midis have been broken down.
Thanks For Reading
Sincerely,
ConfusedPerson
had a little lamb and translated it to basic stamp code so that piezo speaker would play it.
Im aware that there is one for mary had a little lamb but i was wondering if there was a site
where other midis have been broken down.
Thanks For Reading
Sincerely,
ConfusedPerson
![confused.gif](http://forums.parallax.com/images/smilies/confused.gif)
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·
It does get a bit complicated because the PBasic only supports one dimension arrays - so you have to nest the two components [noparse][[/noparse]tone and length of tone] and make sure they arrive at the output together.
Of course you can go a more sophisticated route if you want really musical sounding music.· I have seen some boards that support cell phone output using a BasicStamp.· It is up to you.· What do you want to learn?· And what do you really want to have?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
G. Herzog in Taiwan
Here is the code for the variable constants that refer to the musical notes.
You can take a sheet of music and put the notes in by hand. It's time consuming but it works.
I have attached files to show how it works.
' MusicConstants.BS2
' {$STAMP BS2}
' {$PBASIC 2.5}
' MUSIC CONSTANTS
x VAR Byte
x = 4 'Change the port for the speaker here
' TIME VALUES WHOLE, DOTTED HALF, HALF, DOTTED QUARTER, QUARTER, EIGHTH, SIXTEENTH
W CON 750
DH CON 553
H· CON 375
DQ CON 250
Q· CON 180
E· CON 84
S· CON 55
'LOW NOTES
NC1· CON 523
NCS1 CON 554
ND1· CON 587
NDS1 CON 622
NE1· CON 659
NF1· CON 698
NFS1 CON 739
NG1· CON 783
NGS1 CON 830
NA1· CON 880
NAS1 CON 932
NB1· CON 987
'MID NOTES
NC2· CON 1046
NCS2 CON 1106
ND2· CON 1174
NDS2 CON 1244
NE2· CON 1318
NF2· CON 1396
NFS2 CON 1479
NG2· CON 1567
NGS2 CON 1661
NA2· CON 1760
NAS2 CON 1964
NB2· CON 1975
' HIGH NOTES
NC3· CON 2093
NCS3 CON 2217
ND3· CON 2344
NDS3 CON 2489
NE3· CON 2637
NF3· CON 2793
NFS3 CON 2959
NG3· CON 3135
NGS3 CON 3322
NA3· CON 3520
NAS3 CON 3729
NB3· CON 3951
NC4· CON 4380
I do remember that the important thing is to have a gap in between notes. Otherwise, it all blends together and sounds horrible.