Go Down

Topic: Christmas (bleeper) tunes (Read 13678 times) previous topic - next topic

CowJam

I've encoded some Christmas carols for an arduino driven buzzer (so I can annoy my colleagues) and thought I'd share.

Notes: note 's' is a f#, v is a b-flat.

Code is as here: http://www.arduino.cc/en/Tutorial/Melody
Replace the definition of the notes with these two lines (you need more notes than are defined in the example):
Code: [Select]
char names[] = { 'c', 'd', 'e', 'f', 's', 'g', 'a', 'v', 'b', 'C', 'D', 'E' };
int tones[] = { 1915, 1700, 1519, 1432, 1352, 1275, 1136, 1073, 1014, 956, 852, 758 };

I also changed the tempo to 150.

Replace length, notes[] and beats[] with any of the following...

Ding Dong Merrily on High
Code: [Select]
int length = 73;
char notes[] = "ggagsed deggsgg ggagsed deggsgg DCbCDbCbabCabagabgagsgasgsesgeseddeggsgg "; // a space represents a rest
int beats[] = { 2,2,1,1,1,1,4,2,2,2,2,2,2,4,2,2,2,2,1,1,1,1,4,2,2,2,2,2,2,4,2,2,3,1,1,1,1,1,3,1,1,1,1,1,3,1,1,1,1,1,3,1,1,1,1,1,3,1,1,1,1,1,3,1,2,2,2,2,2,2,4,2,2 };


God Rest Ye Merry Gentlemen
Code: [Select]
int length = 69;
char notes[] = "ddaagfedcdefga ddaagfedcdefga avgavCDagfdefgfgavaagfedfedgfgavCDagfed";
int beats[] = { 2,2,2,2,2,2,2,2,2,2,2,2,2,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,4,2,2,4,2,2,2,2,2,2,4,1,1,2,4,2,2,2,2,2,2,2,2,2,2,8 };


O Little Town of Bethlehem
Code: [Select]
int length = 71;
char notes[] = "cfffgagavCavafggfcfffgagavCavafggffaCDCvagfgavCcfagfccfffgagavCavafggf ";
int beats[] = { 2,2,2,2,2,1,1,1,1,2,2,2,1,1,2,2,6,2,2,2,2,2,1,1,1,1,2,2,2,1,1,2,2,6,1,1,3,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,4,4,2,2,2,2,1,1,1,1,2,2,2,1,1,2,2,6,2 };


While Shephards Watched
Code: [Select]
int length = 29;
char notes[] = "faagfvvagaCCbCaDCvagfeagffef ";
int beats[] = { 2,3,1,2,2,2,2,2,2,2,2,2,2,6,2,3,1,2,2,2,2,2,2,2,2,2,2,6,2 };


In The Bleak Midwinter
Code: [Select]
int length = 51;
char notes[] = "aavCagfgagdgavCaggfgagff vavCDDaaCagfecavCagfgagff ";
int beats[] = { 2,3,1,2,2,4,4,3,1,2,2,8,3,1,2,2,3,1,4,2,2,3,1,6,2,3,1,2,2,2,2,2,2,2,2,2,2,6,2,2,2,2,2,4,4,2,2,3,1,8,8};


Hark the Herald
Code: [Select]
int length = 77;
char notes[] = "cffefaagCCCvagacffefaagCffeedcCCCfvaagCCCfvaagDDDCvavgavCffgaDDDCvavgavCffgf ";
int beats[] = {2,2,3,1,2,2,2,2,2,2,3,1,2,2,4,2,2,3,1,2,2,2,2,2,2,3,1,2,2,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,4,2,1,1,3,1,2,2,4,3,1,2,2,2,2,4,2,1,1,3,1,2,2,4,8};


O come all Ye Faithful
Code: [Select]
int length = 64;
char notes[] = "ggdgadbabCbaggsesgabsedd DCbCbabgasedggsgagdbbabCbabCbagsgCbagg ";
int beats[] = { 2,4,2,2,4,4,2,2,2,2,4,2,2,4,2,2,2,2,2,2,4,3,1,6,2,4,2,2,4,4,2,2,2,2,3,1,2,2,2,2,2,2,4,2,2,2,2,2,2,4,2,2,2,2,2,2,4,2,2,4,3,1,6,8 };


O Come O Come Emmanuel
Code: [Select]
int length = 63;
char notes[] = "egbbbaCbagabgegasedeaaeesgsedgabbbaCbag DD bb baCdagabgegasede ";
int beats[] = { 2,2,2,2,2,2,2,2,2,6,2,2,2,2,2,2,2,2,2,6,2,2,2,2,2,4,2,2,6,2,2,2,2,2,2,2,2,2,4,2,2,4,2,2,4,2,2,2,2,2,2,6,2,2,2,2,2,2,2,2,2,8,8 };

sxdemon

#1
Nov 15, 2010, 01:42 am Last Edit: Nov 15, 2010, 03:13 am by kraig Reason: 1
can I ask you how does someone can take a music and make a perfect fit to the arduino without being a music player/audio type guy?
Ive been looking for that answer from a long time now  :-/

c123


bld

Nice! Going to try this when I get home! :D
captain-slow.dk | non contagious!

CowJam

Quote
can I ask you how does someone can take a music and make a perfect fit to the arduino without being a music player/audio type guy?


Depends what you mean by 'music'.  The buzzer above is pretty simple, it uses code from an example. I did need a bit of music knowledge to convert the songs though.

If you want 'proper' music you could look at an mp3 shield which will allow you to trigger mp3s being played from your adruino.

Big Oil

#5
Nov 16, 2010, 07:07 am Last Edit: Nov 16, 2010, 07:23 am by Big_Oil Reason: 1
I like the third one the best.  

I found some more Christmas songs that work with the RTTTL example in the Tone library: http://merwin.bespin.org/db/rts/index.php?ID=1752&QDB=Tones&PBrowse=Christmas
for example, "We wish you a merry Christmas:
Code: [Select]
char *song = "WeWishYou:d=4,o=5,b=200:d,g,8g,8a,8g,8f#,e,e,e,a,8a,8b,8a,8g,f#,d,d,b,8b,8c6,8b,8a,g,e,d,e,a,f#,2g,d,g,8g,8a,8g,8f#,e,e,e,a,8a,8b,8a,8g,f#,d,d,b,8b,8c6,8b,8a,g,e,d,e,a,f#,1g,d,g,g,g,2f#,f#,g,f#,e,2d,a,b,8a,8a,8g,8g,d6,d,d,e,a,f#,2g";

Go Up