FabGL
ESP32 Display Controller and Graphics Library

◆ playSound()

void playSound ( T const &  waveform,
int  frequency,
int  durationMS,
int  volume = 100 
)
inline

Plays the specified waveform.

Starts immediately to play the specified waveform. It is not required to call play(). This method returns without wait the end of sound.

Parameters
waveformWaveform to play.
frequencyFrequency in Hertz.
durationMSDuration in milliseconds.
volumeVolume value. Minimum is 0, maximum is 127.

Example:

// plays a sinewave at 500Hz for 200 milliseconds
soundGen.playSound(SineWaveformGenerator(), 500, 200);

// plays a C Major chord for 1 second
soundGen.playSound(SineWaveformGenerator(), 262, 1000);  // C
soundGen.playSound(SineWaveformGenerator(), 330, 1000);  // E
soundGen.playSound(SineWaveformGenerator(), 392, 1000);  // G

Definition at line 403 of file soundgen.h.