| @@ -56,18 +56,19 @@ void playNote(void) { | |||
| } | |||
| //--------------------------------------------------------------------------------------- | |||
| void setup() { | |||
| // put your setup code here, to run once: | |||
| AudioMemory(4); | |||
| pinMode(LED_BUILTIN, OUTPUT); | |||
| playNoteTimer.begin(playNote, 1000); | |||
| // put your setup code here, to run once: | |||
| AudioMemory(4); | |||
| tuner.set_threshold( .05f ); | |||
| pinMode(LED_BUILTIN, OUTPUT); | |||
| playNoteTimer.begin(playNote, 1000); | |||
| } | |||
| void loop() { | |||
| // put your main code here, to run repeatedly: | |||
| if (tuner.available()) { | |||
| float note = tuner.read(); | |||
| float prob = tuner.probability(); | |||
| Serial.printf("Note: %3.2f | Probility: %.2f\n", note, prob); | |||
| } | |||
| // put your main code here, to run repeatedly: | |||
| if (tuner.available()) { | |||
| float note = tuner.read(); | |||
| float prob = tuner.probability(); | |||
| Serial.printf("Note: %3.2f | Probility: %.2f\n", note, prob); | |||
| } | |||
| } | |||
| @@ -1,24 +1,24 @@ | |||
| void handleCmds( String cmd ) { | |||
| String p = cmd; | |||
| if (p.startsWith("f ")) { | |||
| p.trim(); | |||
| p = p.substring(2); | |||
| float t = p.toFloat(); | |||
| Serial.print("new frequency: "); | |||
| Serial.println(t); | |||
| //AudioNoInterrupts(); // disable audio library momentarily | |||
| sine.frequency(p.toFloat()); | |||
| //AudioInterrupts(); // enable, both tones will start together | |||
| } | |||
| else if (p.startsWith("a ")) { | |||
| p.trim(); | |||
| p = p.substring(2); | |||
| float t = p.toFloat(); | |||
| Serial.print("new amplitude: "); | |||
| Serial.println(t); | |||
| AudioNoInterrupts(); // disable audio library momentarily | |||
| sine.amplitude(p.toFloat()); | |||
| AudioInterrupts(); // enable, both tones will start together | |||
| } | |||
| String p = cmd; | |||
| if (p.startsWith("f ")) { | |||
| p.trim(); | |||
| p = p.substring(2); | |||
| float t = p.toFloat(); | |||
| Serial.print("new frequency: "); | |||
| Serial.println(t); | |||
| //AudioNoInterrupts(); // disable audio library momentarily | |||
| sine.frequency(p.toFloat()); | |||
| //AudioInterrupts(); // enable, both tones will start together | |||
| } | |||
| else if (p.startsWith("a ")) { | |||
| p.trim(); | |||
| p = p.substring(2); | |||
| float t = p.toFloat(); | |||
| Serial.print("new amplitude: "); | |||
| Serial.println(t); | |||
| AudioNoInterrupts(); // disable audio library momentarily | |||
| sine.amplitude(p.toFloat()); | |||
| AudioInterrupts(); // enable, both tones will start together | |||
| } | |||
| } | |||
| @@ -39,22 +39,23 @@ AudioConnection patchCord3(mixer, 0, dac, 0); | |||
| char buffer[10]; | |||
| void setup() { | |||
| // put your setup code here, to run once: | |||
| AudioMemory(4); | |||
| sine.frequency(30.87); | |||
| sine.amplitude(1); | |||
| // put your setup code here, to run once: | |||
| AudioMemory(4); | |||
| tuner.set_threshold( .05f ); | |||
| sine.frequency(30.87); | |||
| sine.amplitude(1); | |||
| } | |||
| void loop() { | |||
| // put your main code here, to run repeatedly: | |||
| if (tuner.available()) { | |||
| float note = tuner.read(); | |||
| float prob = tuner.probability(); | |||
| Serial.printf("Note: %3.2f | Probility: %.2f\n", note, prob); | |||
| } | |||
| if (Serial.available()) { | |||
| Serial.readBytesUntil('\n', buffer, 10); | |||
| handleCmds( buffer ); | |||
| } | |||
| // put your main code here, to run repeatedly: | |||
| if (tuner.available()) { | |||
| float note = tuner.read(); | |||
| float prob = tuner.probability(); | |||
| Serial.printf("Note: %3.2f | Probility: %.2f\n", note, prob); | |||
| } | |||
| if (Serial.available()) { | |||
| Serial.readBytesUntil('\n', buffer, 10); | |||
| handleCmds( buffer ); | |||
| } | |||
| } | |||