No Matches
Public Member Functions | Protected Attributes | List of all members
audio_tools::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 audio_tools::GeneratorFromArray< T >:
audio_tools::SoundGenerator< T >

Public Member Functions

template<size_t arrayLen>
 GeneratorFromArray (T(&array)[arrayLen], int repeat=0, bool setInactiveAtEnd=true)
 Construct a new Generator From Array object. More...
bool begin () override
 Starts the generation of samples. More...
virtual bool begin (AudioBaseInfo info)
bool isRunning ()
readSample () override
 Provides a single sample. More...
void setArray (T *array, size_t size)
template<int arrayLen>
void setArray (T(&array)[arrayLen])
void setIncrement (int inc)
int setupSine (int sampleRate, int reqFrequency, float amplitude=1.0)
- Public Member Functions inherited from audio_tools::SoundGenerator< T >
virtual AudioBaseInfo audioInfo ()
virtual bool begin ()
virtual bool begin (AudioBaseInfo info)
virtual AudioBaseInfo defaultConfig ()
virtual void end ()
 ends the processing
virtual bool isActive ()
 Checks if the begin method has been called - after end() isActive returns false.
virtual size_t readBytes (uint8_t *buffer, size_t lengthBytes)
 Provides the data as byte array with the requested number of channels.
virtual T readSample ()=0
 Provides a single sample. More...
virtual size_t readSamples (T *data, size_t sampleCount=512)
 Provides the samples into simple array - which represents 1 channel.
virtual size_t readSamples (T src[][2], size_t frameCount)
 Provides the samples into a 2 channel array.
virtual void setAudioInfo (AudioBaseInfo info)
virtual void setFrequency (uint16_t frequency)

Protected Attributes

bool inactive_at_end
int index_increment = 1
bool is_running = false
int max_repeat = 0
bool owns_data = false
int repeat_counter = 0
int sound_index = 0
T * table
size_t table_length = 0
- Protected Attributes inherited from audio_tools::SoundGenerator< T >
bool active = false
bool activeWarningIssued = false
AudioBaseInfo info
int output_channels = 1

Detailed Description

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

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

Phil Schatzmann
Template Parameters

Constructor & Destructor Documentation

◆ GeneratorFromArray()

template<class T >
template<size_t arrayLen>
audio_tools::GeneratorFromArray< T >::GeneratorFromArray ( T(&)  array[arrayLen],
int  repeat = 0,
bool  setInactiveAtEnd = true 

Construct a new Generator From Array object.

Template Parameters
arrayarray of audio data of the the type defined as class template parameter
repeatnumber of repetions the array should be played (default 1)
setInactiveAtEnddefines if the generator is set inactive when the array has played fully. Default is true.

Member Function Documentation

◆ begin() [1/2]

template<class T >
bool audio_tools::GeneratorFromArray< T >::begin ( )

Starts the generation of samples.

Reimplemented from audio_tools::SoundGenerator< T >.

◆ begin() [2/2]

template<class T >
virtual bool audio_tools::GeneratorFromArray< T >::begin ( AudioBaseInfo  info)

Reimplemented from audio_tools::SoundGenerator< T >.

◆ readSample()

template<class T >
T audio_tools::GeneratorFromArray< T >::readSample ( )

Provides a single sample.

Implements audio_tools::SoundGenerator< T >.

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