Generates tones with smooth transitions using Tone Buffers.
More...
#include <ToneGenerator.h>
Generates tones with smooth transitions using Tone Buffers.
- Note
- During tone playback, a single
active
ToneBuffer feeds the I2S with samples. When a new tone is prepared via queueTone()
, a ToneBuffer is added to the pending
queue. If transitioning between tone and silence then additional fade in/out buffers are queued to implement low-pass filtering on these relatively abrupt transitions and thus reduce clicking. Calling submitPending()
appends the pending
queue onto the transition
queue. The transition to the new tone (or silence) is made within i2sWrite()
, at which point buffers are released back to the avail
queue.
◆ ToneEffect
◆ Voice
◆ ~ToneGenerator()
ToneGenerator::~ToneGenerator |
( |
| ) |
|
|
inline |
◆ begin()
Initialise the tone generator and I2S.
- Parameters
-
- Return values
-
◆ createTone()
Create a tone and queue it.
- Parameters
-
voice | Voice to use for tone |
frequency | Frequency in Hz |
effect | |
repeatCount | Specify non-zero to repeat this tone a specific number of times |
- Return values
-
ToneBuffer* | The queued buffer, nullptr on error |
◆ end()
void ToneGenerator::end |
( |
| ) |
|
Stop playback and un-initialise I2S.
- Note
- Releases all allocated memory
◆ getEffectName()
◆ getVoiceName()
static String ToneGenerator::getVoiceName |
( |
Voice |
voice | ) |
|
|
static |
◆ isStarted()
bool ToneGenerator::isStarted |
( |
| ) |
|
|
inline |
◆ queueTone()
void ToneGenerator::queueTone |
( |
Voice |
voice, |
|
|
unsigned |
frequency |
|
) |
| |
Create a tone with appropriate filtering.
- Parameters
-
voice | Voice to use for tone @frequency Frequency in Hz @ |
◆ start()
bool ToneGenerator::start |
( |
| ) |
|
◆ stop()
void ToneGenerator::stop |
( |
| ) |
|
Stop tone playback and release any memory allocated for buffers.
- Note
- Leaves I2S initialised. Call
start()
to resume.
◆ submitPending()
void ToneGenerator::submitPending |
( |
| ) |
|
|
inline |
Submit queued tone buffers for playback.
The documentation for this class was generated from the following file: