} | } | ||||
//--------------------------------------------------------------------------------------- | //--------------------------------------------------------------------------------------- | ||||
void setup() { | 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() { | 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); | |||||
} | |||||
} | } |
void handleCmds( String cmd ) { | 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 | |||||
} | |||||
} | } |
char buffer[10]; | char buffer[10]; | ||||
void setup() { | 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() { | 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 ); | |||||
} | |||||
} | } |