17 #include <driver/i2s.h> 19 #define TG_VOICE_MAP(XX) \ 25 #define TG_EFFECT_MAP(XX) \ 71 bool begin(
unsigned sampleRate);
118 transition.append(pending);
122 ToneBuffer* allocateBuffer(
unsigned sampleCount);
123 int16_t getSampleValue(
Voice voice,
unsigned pos,
unsigned sampleCount, int16_t amplitude);
124 static void IRAM_ATTR i2sCallback(
void* param, i2s_event_type_t event);
125 void IRAM_ATTR i2sWrite();
126 bool IRAM_ATTR i2sWriteBuffer(
ToneBuffer* buffer,
bool end);
130 unsigned curFreq = 0;
131 static constexpr
uint8_t fadeCycles = 2;
132 static constexpr
uint8_t noteGapMs = 16;
139 bool started =
false;
Definition: ToneBufferQueue.h:18
void submitPending()
Submit queued tone buffers for playback.
Definition: ToneGenerator.h:116
#define TG_EFFECT_MAP(XX)
Definition: ToneGenerator.h:25
static String getVoiceName(Voice voice)
bool start()
Start tone playback.
The String class.
Definition: WString.h:136
bool isStarted()
Definition: ToneGenerator.h:90
Contains samples for one full signal cycle at a specific frequency.
Definition: ToneBuffer.h:23
ToneBuffer * createTone(Voice voice, unsigned frequency, ToneEffect effect, unsigned repeatCount=0)
Create a tone and queue it.
void queueTone(Voice voice, unsigned frequency)
Create a tone with appropriate filtering.
Generates tones with smooth transitions using Tone Buffers.
Definition: ToneGenerator.h:42
#define TG_VOICE_MAP(XX)
Definition: ToneGenerator.h:19
Voice
Definition: ToneGenerator.h:45
bool begin(unsigned sampleRate)
Initialise the tone generator and I2S.
static String getEffectName(ToneEffect effect)
void end()
Stop playback and un-initialise I2S.
ToneEffect
Definition: ToneGenerator.h:52
void stop()
Stop tone playback and release any memory allocated for buffers.
~ToneGenerator()
Definition: ToneGenerator.h:61