duff2013 il y a 9 ans
Parent
révision
5a590e144f
3 fichiers modifiés avec 50 ajouts et 48 suppressions
  1. +12
    -11
      examples/Sample_Guitar_Tunning_Notes/Sample_Guitar_Tunning_Notes.ino
  2. +22
    -22
      examples/Simple_Sine/Handle_Commands.ino
  3. +16
    -15
      examples/Simple_Sine/Simple_Sine.ino

+ 12
- 11
examples/Sample_Guitar_Tunning_Notes/Sample_Guitar_Tunning_Notes.ino Voir le fichier

@@ -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);
}
}

+ 22
- 22
examples/Simple_Sine/Handle_Commands.ino Voir le fichier

@@ -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
}
}

+ 16
- 15
examples/Simple_Sine/Simple_Sine.ino Voir le fichier

@@ -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 );
}
}

Chargement…
Annuler
Enregistrer