From 9213f4c7d410e6b292e396117eb6253e8a1fdd75 Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Fri, 1 Nov 2024 20:56:48 +0100 Subject: [PATCH] Lyrat Mini example --- .../lyrat-mini/output/outout.ino | 36 +++++++++++++++++++ src/AudioTools/AudioLibs/AudioBoardStream.h | 4 +-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 examples/examples-custom-boards/lyrat-mini/output/outout.ino diff --git a/examples/examples-custom-boards/lyrat-mini/output/outout.ino b/examples/examples-custom-boards/lyrat-mini/output/outout.ino new file mode 100644 index 000000000..d8feaa215 --- /dev/null +++ b/examples/examples-custom-boards/lyrat-mini/output/outout.ino @@ -0,0 +1,36 @@ +// Demo to output audio on a lyrat-mini board: with headphone detection active +// to switch the power amplifier on and off + +#include "AudioTools.h" +#include "AudioTools/AudioLibs/AudioBoardStream.h" + +AudioInfo info(44100, 2, 16); +SineWaveGenerator sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000 +GeneratedSoundStream sound(sineWave); // Stream generated from sine wave +AudioBoardStream out(LyratMini); +StreamCopy copier(out, sound); // copies sound into i2s + +// Arduino Setup +void setup(void) { + // Open Serial + Serial.begin(115200); + AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning); + + // start I2S + Serial.println("starting I2S..."); + auto config = out.defaultConfig(TX_MODE); + config.copyFrom(info); + + // additinal settings + out.setVolume(0.5); + out.addHeadphoneDetectionAction(); + + // start sine wave + sineWave.begin(info, N_B4); + Serial.println("started..."); +} + +void loop() { + copier.copy(); + out.processActions(); +} \ No newline at end of file diff --git a/src/AudioTools/AudioLibs/AudioBoardStream.h b/src/AudioTools/AudioLibs/AudioBoardStream.h index 6eae1097e..73be23727 100644 --- a/src/AudioTools/AudioLibs/AudioBoardStream.h +++ b/src/AudioTools/AudioLibs/AudioBoardStream.h @@ -309,7 +309,7 @@ class AudioBoardStream : public I2SCodecStream { } /// Adds headphone determination - void addHeadphonDetectionAction() { + void addHeadphoneDetectionAction() { // pin conflicts with AIThinker A101: key6 and headphone detection int head_phone = pinHeadphoneDetect(); if (head_phone != -1 && (getPinID(PinFunction::KEY, 6) != head_phone)) { @@ -323,7 +323,7 @@ class AudioBoardStream : public I2SCodecStream { */ void addDefaultActions() { TRACEI(); - addHeadphonDetectionAction(); + addHeadphoneDetectionAction(); addStartStopAction(); addVolumeActions(); }