瀏覽代碼

update

main
duff2013 9 年之前
父節點
當前提交
5a590e144f
共有 3 個檔案被更改,包括 50 行新增48 行删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

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

Loading…
取消
儲存