#include #include #include "player.h" #include "pitches.h" #define PIN 0 //Realer pin 11 const unsigned int introlength = 25; int intro[] = { //intro NOTE_DS5, NOTE_E5, NOTE_FS5, NOTE_B5, NOTE_DS5, NOTE_E5, NOTE_FS5, NOTE_B5, NOTE_CS6, NOTE_DS6, NOTE_CS6, NOTE_AS5, NOTE_B5, NOTE_FS5, NOTE_DS5, NOTE_E5, NOTE_FS5, NOTE_B5, NOTE_CS6, NOTE_AS5, NOTE_B5, NOTE_CS6, NOTE_E6, NOTE_DS6, NOTE_E6, NOTE_B5, }; // Noten Dauern: 4 --> Viertel Note, 8 --> Achtel Note usw. int noteDurations[] = { 16, 16, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 8, //13 8, 16, 16, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16 //25 intro }; int setupSoftTone(void) { int returncode = 0; returncode += wiringPiSetup(); //Braucht root Rechte returncode += softToneCreate(PIN); return returncode; // >0 --> error } void playIntro(void) { int nDuration, pauseBetweenNotes, thisNote; for (thisNote = 0; thisNote < introlength; thisNote++) { /** * Um die Zeit der Note zu berechnen muss eine Sekunde durch * die Laenge der Note geteilt werden. */ nDuration = 1000 / noteDurations[thisNote]; softToneWrite(PIN, intro[thisNote]); delay(nDuration); softToneWrite(PIN, 0); /** * Um die Noten voneinander zu unterscheiden, * sollte eine Pause dazwischen sein. * Diese wird später mit dem Beschleunigungssensor * gesteuert. Vorerst sind es aber 30% */ pauseBetweenNotes = nDuration * 1.30; delay(pauseBetweenNotes); // Sicherheitshalber Ton ausschalten softToneWrite(PIN, 0); } }