Kompletter Nyan cat Song

This commit is contained in:
2016-09-11 13:57:07 +02:00
parent a8ca0acd0b
commit bece9fee21
4 changed files with 525 additions and 74 deletions

View File

@@ -1,75 +1,9 @@
#include <wiringPi.h>
#include <softTone.h>
#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;
@@ -78,15 +12,15 @@ int setupSoftTone(void) {
return returncode; // >0 --> error
}
void playIntro(void) {
void play(int *notes, int *durations, int songlength) {
int nDuration, pauseBetweenNotes, thisNote;
for (thisNote = 0; thisNote < introlength; thisNote++) {
for (thisNote = 0; thisNote < songlength; 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]);
nDuration = 1000 / *(durations + thisNote);
softToneWrite(PIN, *(notes + thisNote));
delay(nDuration);
softToneWrite(PIN, 0);
/**
@@ -99,5 +33,5 @@ void playIntro(void) {
delay(pauseBetweenNotes);
// Sicherheitshalber Ton ausschalten
softToneWrite(PIN, 0);
}
}
}