Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
AudioGenerator Class Reference

Virtual base class for audio-generating modules. More...

#include <audiogenerator.h>

Inheritance diagram for AudioGenerator:
Inheritance graph
Collaboration diagram for AudioGenerator:
Collaboration graph

Public Member Functions

 AudioGenerator ()
 Constructor. More...
 
 ~AudioGenerator ()
 Destructor without functionality. More...
 
void setParameters (const AudioParameters &parameters)
 Set audio device parameters. More...
 
void setMaxPacketSize (int n)
 
size_t getMaxPacketSize ()
 
virtual size_t generateSound (char *data, size_t maxSize)
 Virtual function for sound generation. This function generates an A440 on the right and an A220 on the left channel as a test tone. Override this function in the actual implementation. More...
 
int getSampleRate ()
 
void setVerbosity (int verbosity)
 Set the verbosity level of the class-specific messages. More...
 
int getVerbosity ()
 Get the actual verbosity level. More...
 

Protected Attributes

AudioParameters mParameters
 Local copy of the audio parameters. More...
 
size_t mMaxNumberOfFrames
 Maximal number of frames per buffer. More...
 

Detailed Description

Virtual base class for audio-generating modules.

This virtual base class has to be inherited by the actual sound-producing implementation such as a synthesizer or audio player.

The derived class should override the virtual function AudioGenerator::generateSound. If this function is not overridden it is implemented here a simple generator producing a 440 Hz sine wave for testing purposes.

Definition at line 42 of file audiogenerator.h.

Constructor & Destructor Documentation

AudioGenerator::AudioGenerator ( )

Constructor.

Definition at line 36 of file audiogenerator.cpp.

AudioGenerator::~AudioGenerator ( )
inline

Destructor without functionality.

Definition at line 46 of file audiogenerator.h.

Here is the call graph for this function:

Member Function Documentation

size_t AudioGenerator::generateSound ( char *  data,
size_t  maxSize 
)
virtual

Virtual function for sound generation. This function generates an A440 on the right and an A220 on the left channel as a test tone. Override this function in the actual implementation.

This function generates the sound in form of a vector of PCMType data packages. It is called internally by AudioOutputDevice. Whenever the sound system is ready to read new data. This call is executed in the local thread of the audio system.

The parameter maxSize specifies the maximal number of PCMType entries that may be generated and equals the available array size of data.

Each sample consists of two PCMType values (signed int from -32768 to +32767). The implementation should write at most maxSize values (maxSize/2 samples) to the data array and return the actual number of written PCMType values (two times the number of samples).

By default this function generates an A440 sine wave for testing purposes.

Parameters
data: Pointer to the buffer of bytes of the output device.
maxSize: Maximal number of bytes to be written.
Returns
Actual number of written PCMType values.

Reimplemented in Sampler.

Definition at line 102 of file audiogenerator.cpp.

size_t AudioGenerator::getMaxPacketSize ( )
inline

Definition at line 50 of file audiogenerator.h.

Here is the call graph for this function:

int AudioGenerator::getSampleRate ( )
inline

Definition at line 55 of file audiogenerator.h.

int Log::getVerbosity ( )
inherited

Get the actual verbosity level.

Returns
: Verbosity level (1...4)

Definition at line 118 of file log.cpp.

void AudioGenerator::setMaxPacketSize ( int  n)
inline

Definition at line 49 of file audiogenerator.h.

void AudioGenerator::setParameters ( const AudioParameters parameters)

Set audio device parameters.

Definition at line 50 of file audiogenerator.cpp.

void Log::setVerbosity ( int  verbosity)
inherited

Set the verbosity level of the class-specific messages.

Parameters
verbosity: Verbosity level (1...4)

Definition at line 107 of file log.cpp.

Member Data Documentation

size_t AudioGenerator::mMaxNumberOfFrames
protected

Maximal number of frames per buffer.

Definition at line 59 of file audiogenerator.h.

AudioParameters AudioGenerator::mParameters
protected

Local copy of the audio parameters.

Definition at line 58 of file audiogenerator.h.


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