arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SineFromTable< T > Class Template Reference

A sine generator based on a table. The table is created using degrees where one full wave is 360 degrees. More...

#include <SoundGenerator.h>

Inheritance diagram for SineFromTable< T >:
SoundGenerator< T >

Public Member Functions

 SineFromTable (float amplitude=32767.0)
 
virtual AudioInfo audioInfo ()
 Provides the AudioInfo.
 
bool begin ()
 Starts the processing.
 
virtual bool begin (AudioInfo info)
 Starts the processing with the provided AudioInfo.
 
bool begin (AudioInfo info, float frequency)
 
bool begin (int channels, int sample_rate, uint16_t frequency=0)
 
virtual AudioInfo defaultConfig ()
 Provides the default configuration.
 
virtual void end ()
 Ends the processing.
 
virtual bool isActive ()
 Checks if the begin method has been called - after end() isActive is false.
 
virtual size_t readBytes (uint8_t *data, size_t len)
 Provides the data as byte array with the requested number of channels.
 
T readSample ()
 Provides a single sample.
 
void setAmplitude (float amplitude)
 Defines the new amplitude (volume)
 
virtual void setAudioInfo (AudioInfo info)
 Defines/updates the AudioInfo.
 
void setFrequency (float freq)
 Abstract method: not implemented! Just provides an error message...
 
void setMaxAmplitudeStep (float step)
 
void setPlayTime (uint32_t playMs, uint8_t upPercent=20, uint8_t downPercent=30)
 Defines the play time in ms and the ramp up and ramp down time in percent.
 

Protected Member Functions

T applyRamp (T sample)
 
T interpolate (float angle)
 
T map (T x, T in_min, T in_max, T out_min, T out_max)
 
size_t readBytesFrames (uint8_t *buffer, size_t lengthBytes, int frames, int channels)
 
size_t readBytesFromBuffer (uint8_t *buffer, size_t lengthBytes, int frame_size, int channels)
 
void recalculatePlayTime ()
 
void updateAmplitudeInSteps ()
 

Protected Attributes

bool active = false
 
bool activeWarningIssued = false
 
float amplitude
 
float amplitude_to_be
 
float angle = 0.0f
 
float base_frequency = 1.0f
 
uint32_t currentSample = 0
 
uint8_t downPercent = 40
 
float factor = 1.0f
 
AudioInfo info
 
bool is_first = true
 
float max_amplitude_step = 50.0f
 
uint32_t playMs = 0
 
uint32_t playSamples = 0
 
float rampDownDec = 0.0
 
uint32_t rampDownSamples = 0
 
float rampUpInc = 0.0
 
RingBuffer< uint8_tring_buffer {0}
 
float step = 1.0f
 
float step_new = 1.0f
 
uint8_t upPercent = 5
 
uint32_t upSamples = 0
 
const float values [181]
 

Detailed Description

template<class T = int16_t>
class audio_tools::SineFromTable< T >

A sine generator based on a table. The table is created using degrees where one full wave is 360 degrees.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ SineFromTable()

template<class T = int16_t>
SineFromTable ( float  amplitude = 32767.0)
inline

Member Function Documentation

◆ applyRamp()

template<class T = int16_t>
T applyRamp ( T  sample)
inlineprotectedinherited

◆ audioInfo()

template<class T = int16_t>
virtual AudioInfo audioInfo ( )
inlinevirtualinherited

Provides the AudioInfo.

◆ begin() [1/4]

template<class T = int16_t>
bool begin ( )
inlinevirtual

Starts the processing.

Reimplemented from SoundGenerator< T >.

◆ begin() [2/4]

template<class T = int16_t>
virtual bool begin ( AudioInfo  info)
inlinevirtualinherited

◆ begin() [3/4]

template<class T = int16_t>
bool begin ( AudioInfo  info,
float  frequency 
)
inline

◆ begin() [4/4]

template<class T = int16_t>
bool begin ( int  channels,
int  sample_rate,
uint16_t  frequency = 0 
)
inline

◆ defaultConfig()

template<class T = int16_t>
virtual AudioInfo defaultConfig ( )
inlinevirtualinherited

◆ end()

template<class T = int16_t>
virtual void end ( )
inlinevirtualinherited

Ends the processing.

Reimplemented in GeneratorFromArray< T >.

◆ interpolate()

template<class T = int16_t>
T interpolate ( float  angle)
inlineprotected

◆ isActive()

template<class T = int16_t>
virtual bool isActive ( )
inlinevirtualinherited

Checks if the begin method has been called - after end() isActive is false.

◆ map()

template<class T = int16_t>
T map ( T  x,
T  in_min,
T  in_max,
T  out_min,
T  out_max 
)
inlineprotected

◆ readBytes()

template<class T = int16_t>
virtual size_t readBytes ( uint8_t data,
size_t  len 
)
inlinevirtualinherited

Provides the data as byte array with the requested number of channels.

◆ readBytesFrames()

template<class T = int16_t>
size_t readBytesFrames ( uint8_t buffer,
size_t  lengthBytes,
int  frames,
int  channels 
)
inlineprotectedinherited

◆ readBytesFromBuffer()

template<class T = int16_t>
size_t readBytesFromBuffer ( uint8_t buffer,
size_t  lengthBytes,
int  frame_size,
int  channels 
)
inlineprotectedinherited

◆ readSample()

template<class T = int16_t>
T readSample ( )
inlinevirtual

Provides a single sample.

Implements SoundGenerator< T >.

◆ recalculatePlayTime()

template<class T = int16_t>
void recalculatePlayTime ( )
inlineprotectedinherited

◆ setAmplitude()

template<class T = int16_t>
void setAmplitude ( float  amplitude)
inline

Defines the new amplitude (volume)

◆ setAudioInfo()

template<class T = int16_t>
virtual void setAudioInfo ( AudioInfo  info)
inlinevirtualinherited

Defines/updates the AudioInfo.

Reimplemented in SineGenerator< T >, and SineGenerator< int16_t >.

◆ setFrequency()

template<class T = int16_t>
void setFrequency ( float  frequency)
inlinevirtual

Abstract method: not implemented! Just provides an error message...

Reimplemented from SoundGenerator< T >.

◆ setMaxAmplitudeStep()

template<class T = int16_t>
void setMaxAmplitudeStep ( float  step)
inline

To avoid pops we do not allow to big amplitude changes at once and spread them over time

◆ setPlayTime()

template<class T = int16_t>
void setPlayTime ( uint32_t  playMs,
uint8_t  upPercent = 20,
uint8_t  downPercent = 30 
)
inlineinherited

Defines the play time in ms and the ramp up and ramp down time in percent.

◆ updateAmplitudeInSteps()

template<class T = int16_t>
void updateAmplitudeInSteps ( )
inlineprotected

Member Data Documentation

◆ active

template<class T = int16_t>
bool active = false
protectedinherited

◆ activeWarningIssued

template<class T = int16_t>
bool activeWarningIssued = false
protectedinherited

◆ amplitude

template<class T = int16_t>
float amplitude
protected

◆ amplitude_to_be

template<class T = int16_t>
float amplitude_to_be
protected

◆ angle

template<class T = int16_t>
float angle = 0.0f
protected

◆ base_frequency

template<class T = int16_t>
float base_frequency = 1.0f
protected

◆ currentSample

template<class T = int16_t>
uint32_t currentSample = 0
protectedinherited

◆ downPercent

template<class T = int16_t>
uint8_t downPercent = 40
protectedinherited

◆ factor

template<class T = int16_t>
float factor = 1.0f
protectedinherited

◆ info

template<class T = int16_t>
AudioInfo info
protectedinherited

◆ is_first

template<class T = int16_t>
bool is_first = true
protected

◆ max_amplitude_step

template<class T = int16_t>
float max_amplitude_step = 50.0f
protected

◆ playMs

template<class T = int16_t>
uint32_t playMs = 0
protectedinherited

◆ playSamples

template<class T = int16_t>
uint32_t playSamples = 0
protectedinherited

◆ rampDownDec

template<class T = int16_t>
float rampDownDec = 0.0
protectedinherited

◆ rampDownSamples

template<class T = int16_t>
uint32_t rampDownSamples = 0
protectedinherited

◆ rampUpInc

template<class T = int16_t>
float rampUpInc = 0.0
protectedinherited

◆ ring_buffer

template<class T = int16_t>
RingBuffer<uint8_t> ring_buffer {0}
protectedinherited

◆ step

template<class T = int16_t>
float step = 1.0f
protected

◆ step_new

template<class T = int16_t>
float step_new = 1.0f
protected

◆ upPercent

template<class T = int16_t>
uint8_t upPercent = 5
protectedinherited

◆ upSamples

template<class T = int16_t>
uint32_t upSamples = 0
protectedinherited

◆ values

template<class T = int16_t>
const float values[181]
protected

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