arduino-audio-tools
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

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. More...
 
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.
 
virtual void end ()
 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.
 
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)
 
int setupSine (int sampleRate, float reqFrequency, float amplitude=1.0)
 

Protected Member Functions

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)
 

Protected Attributes

bool active = false
 
bool activeWarningIssued = false
 
bool inactive_at_end
 
int index_increment = 1
 
AudioInfo info
 
bool is_running = false
 
int max_repeat = 0
 
bool owns_data = false
 
int repeat_counter = 0
 
RingBuffer< uint8_t > ring_buffer {0}
 
int sound_index = 0
 
T * table = nullptr
 
size_t table_length = 0
 

Detailed Description

template<class 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()

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

◆ isActive()

virtual bool isActive ( )
inlinevirtualinherited

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


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