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

We generate the samples from an array which is provided in the constructor. More...

#include <SoundGenerator.h>

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

Public Member Functions

 GeneratorFromArray ()=default
 
template<size_t arrayLen>
 GeneratorFromArray (T(&array)[arrayLen], int repeat=0, bool setInactiveAtEnd=false, size_t startIndex=0)
 Construct a new Generator from an array.
 
virtual AudioInfo audioInfo ()
 Provides the AudioInfo.
 
bool begin () override
 Starts the generation of samples.
 
virtual bool begin (AudioInfo info) override
 
virtual AudioInfo defaultConfig ()
 Provides the default configuration.
 
void end () override
 ends the processing
 
virtual bool isActive ()
 
bool isRunning ()
 
virtual size_t readBytes (uint8_t *data, size_t len)
 Provides the data as byte array with the requested number of channels.
 
T readSample () override
 Provides a single sample.
 
void setArray (T *array, size_t size)
 
template<int arrayLen>
void setArray (T(&array)[arrayLen])
 
virtual void setAudioInfo (AudioInfo info)
 Defines/updates the AudioInfo.
 
virtual void setFrequency (float frequency)
 Abstract method: not implemented! Just provides an error message...
 
void setIncrement (int inc)
 
void setPlayTime (uint32_t playMs, uint8_t upPercent=20, uint8_t downPercent=30)
 
int setupSine (int sampleRate, float reqFrequency, float amplitude=1.0)
 

Protected Member Functions

T applyRamp (T sample)
 
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 ()
 

Protected Attributes

bool active = false
 
bool activeWarningIssued = false
 
uint32_t currentSample = 0
 
uint8_t downPercent = 40
 
float factor = 1.0f
 
bool inactive_at_end
 
int index_increment = 1
 
AudioInfo info
 
bool is_running = false
 
int max_repeat = 0
 
bool owns_data = false
 
uint32_t playMs = 0
 
uint32_t playSamples = 0
 
float rampDownDec = 0.0
 
uint32_t rampDownSamples = 0
 
float rampUpInc = 0.0
 
int repeat_counter = 0
 
RingBuffer< uint8_tring_buffer {0}
 
int sound_index = 0
 
Vector< Ttable
 
uint8_t upPercent = 5
 
uint32_t upSamples = 0
 

Detailed Description

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

We generate the samples from an array which is provided in the constructor.

Author
Phil Schatzmann
Template Parameters
T

Constructor & Destructor Documentation

◆ GeneratorFromArray() [1/2]

template<class T = int16_t>
GeneratorFromArray ( )
default

◆ GeneratorFromArray() [2/2]

template<class T = int16_t>
template<size_t arrayLen>
GeneratorFromArray ( T(&)  array[arrayLen],
int  repeat = 0,
bool  setInactiveAtEnd = false,
size_t  startIndex = 0 
)
inline

Construct a new Generator from an array.

Template Parameters
arrayarray of audio data of the the type defined as class template parameter
Parameters
repeatnumber of repetions the array should be played, set to 0 for endless repeat. (default 0)
setInactiveAtEnddefines if the generator is set inactive when the array has played fully. Default is false.
startIndexdefines if the phase. Default is 0.

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/2]

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

Starts the generation of samples.

Reimplemented from SoundGenerator< T >.

◆ begin() [2/2]

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

Reimplemented from SoundGenerator< T >.

◆ defaultConfig()

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

◆ end()

template<class T = int16_t>
void end ( )
inlineoverridevirtual

ends the processing

Reimplemented from SoundGenerator< T >.

◆ isActive()

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

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

◆ isRunning()

template<class T = int16_t>
bool isRunning ( )
inline

◆ 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 ( )
inlineoverridevirtual

Provides a single sample.

Implements SoundGenerator< T >.

◆ recalculatePlayTime()

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

◆ setArray() [1/2]

template<class T = int16_t>
void setArray ( T array,
size_t  size 
)
inline

◆ setArray() [2/2]

template<class T = int16_t>
template<int arrayLen>
void setArray ( T(&)  array[arrayLen])
inline

◆ setAudioInfo()

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

Defines/updates the AudioInfo.

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

◆ setFrequency()

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

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

Reimplemented in SineFromTable< T >, STKInstrument< StkCls, T >, SineWaveGenerator< T >, and SineWaveGenerator< int16_t >.

◆ setIncrement()

template<class T = int16_t>
void setIncrement ( int  inc)
inline

◆ setPlayTime()

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

◆ setupSine()

template<class T = int16_t>
int setupSine ( int  sampleRate,
float  reqFrequency,
float  amplitude = 1.0 
)
inline

Member Data Documentation

◆ active

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

◆ activeWarningIssued

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

◆ 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

◆ inactive_at_end

template<class T = int16_t>
bool inactive_at_end
protected

◆ index_increment

template<class T = int16_t>
int index_increment = 1
protected

◆ info

template<class T = int16_t>
AudioInfo info
protectedinherited

◆ is_running

template<class T = int16_t>
bool is_running = false
protected

◆ max_repeat

template<class T = int16_t>
int max_repeat = 0
protected

◆ owns_data

template<class T = int16_t>
bool owns_data = false
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

◆ repeat_counter

template<class T = int16_t>
int repeat_counter = 0
protected

◆ ring_buffer

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

◆ sound_index

template<class T = int16_t>
int sound_index = 0
protected

◆ table

template<class T = int16_t>
Vector<T> table
protected

◆ upPercent

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

◆ upSamples

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

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