FabGL
ESP32 VGA Controller and Graphics Library
fabgl::SquareWaveformGenerator Class Reference

Square waveform generator. More...

#include <soundgen.h>

Inheritance diagram for fabgl::SquareWaveformGenerator:
Collaboration diagram for fabgl::SquareWaveformGenerator:

Public Member Functions

void enable (bool value)
 Enables or disabled this generator. More...
 
bool enabled ()
 Determines whether this generator is enabled or disabled. More...
 
int getSample ()
 Gets next sample. More...
 
uint16_t sampleRate ()
 Determines the sample rate. More...
 
void setDutyCycle (int dutyCycle)
 Sets square wave duty cycle. More...
 
void setFrequency (int value)
 Sets output frequency. More...
 
void setSampleRate (int value)
 Sets the sample rate. More...
 
void setVolume (int value)
 Sets volume of this generator. More...
 
int volume ()
 Determines current volume. More...
 

Detailed Description

Square waveform generator.

Member Function Documentation

◆ enable()

void fabgl::WaveformGenerator::enable ( bool  value)
inlineinherited

Enables or disabled this generator.

A generator is disabled for default and must be enabled in order to play sound

Parameters
valueTrue to enable the generator, False to disable

◆ enabled()

bool fabgl::WaveformGenerator::enabled ( )
inlineinherited

Determines whether this generator is enabled or disabled.

Returns
True if this generator is enabled

◆ getSample()

int fabgl::SquareWaveformGenerator::getSample ( )
virtual

Gets next sample.

Returns
Sample value as signed 8 bit (-128..127 range)

Implements fabgl::WaveformGenerator.

◆ sampleRate()

uint16_t fabgl::WaveformGenerator::sampleRate ( )
inlineinherited

Determines the sample rate.

Returns
Current sample rate in Hertz

◆ setDutyCycle()

void fabgl::SquareWaveformGenerator::setDutyCycle ( int  dutyCycle)

Sets square wave duty cycle.

Parameters
dutyCycleDuty cycle in 0..255 range. 255 = 100%

◆ setFrequency()

void fabgl::SquareWaveformGenerator::setFrequency ( int  value)
virtual

Sets output frequency.

Parameters
valueFrequency in Hertz

Implements fabgl::WaveformGenerator.

◆ setSampleRate()

void fabgl::WaveformGenerator::setSampleRate ( int  value)
inlineinherited

Sets the sample rate.

Default sample rate is 160000 Hertz.

Parameters
valueSample rate in Hertz

◆ setVolume()

void fabgl::WaveformGenerator::setVolume ( int  value)
inlineinherited

Sets volume of this generator.

Parameters
valueVolume value. Minimum is 0, maximum is 127.

◆ volume()

int fabgl::WaveformGenerator::volume ( )
inlineinherited

Determines current volume.

Returns
Current volume of this generator (0 = minimum, 127 = maximum)

The documentation for this class was generated from the following files: