Sound

Musical notes

For example:

The name of the notes are different on Anglo-Saxon musicians:

A piano has octaves


const int crotchet= 100; //negra
const int minim= 2*crotchet; //blanca
const int semiBreve= 4*crotchet; //redonda
const int quaver= crotchet/2; //corchera
const int semiQuaver= crotchet/4; //semicorchera
const int demiSemiQuaver= crotchet/8; //fusa
const int crotchetWithPoint= crotchet+quaver;
const int minimWithPoint= minim+crotchet;
//silences
const int crotchetSilence= crotchet; //silencio negra
const int minimSilence= minim; //silencio blanca
const int semiBreveSilence= semiBreve; //silencio redonda
const int quaverSilence= quaver; //silencio corchera
const int semiQuaverSilence= semiQuaver; //silencio semicorchera
const int demiSemiQuaverSilence= demiSemiQuaver; //silencio fusa
//notes
const long DO=  261.63;
const long RE= 293.66;
const long MI= 329.63;
const long FA= 349.23;
const long SOL= 392.00;
const long LA= 440.00;
const long SI= 493.88;
const long PAU=30000;
const int speakerOut = 8;
const int elements= 34;
const int nextNote= 200;
const int nextBlock= 300;
 void setup() {
   pinMode(speakerOut, OUTPUT);
 }
void loop() {
int melody[]= {MI, PAU, MI, MI, MI, PAU, MI, PAU, MI, FA, PAU, SOL, FA,
              PAU, MI, PAU, MI, FA, MI, FA, PAU, SOL, FA, PAU, MI, PAU,
              MI, FA, MI, FA, PAU, SOL, PAU, SOL};

int duration[]= {crotchetWithPoint, nextNote, quaver, crotchet, crotchet,
                nextNote, crotchet, nextBlock, crotchetSilence, nextNote, 
                crotchet, crotchet, nextNote, crotchet, crotchet, nextNote,
                crotchet, nextBlock, crotchet, crotchet, crotchet, crotchet, 
                nextNote, crotchet, crotchet, nextNote, crotchet, nextBlock,
                crotchet, crotchet, crotchet, crotchet, nextNote, crotchet,
                nextNote, crotchet };

for (int note = 0; note < elements; note++) { 
tone(speakerOut, melody[note]); 
delay(duration[note]);
noTone(speakerOut);}
}