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

Sound-generating module which plays the tones held by the SoundGenerator. More...

#include <sampler.h>

Inheritance diagram for Sampler:
Inheritance graph
Collaboration diagram for Sampler:
Collaboration graph

Public Member Functions

 Sampler ()
 Constructor of the Sampler without functionality. More...
 
void init (SoundGenerator *soundgenerator)
 Initialization of the sampler. More...
 
void exit ()
 
void setParameters (const AudioParameters &parameters)
 Set audio device parameters. More...
 
void setMaxPacketSize (int n)
 
size_t getMaxPacketSize ()
 
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...
 

Private Member Functions

size_t generateSound (char *charbuffer, size_t maxSize) override final
 Essential sound-generating function of the sampler. More...
 

Private Attributes

SoundGeneratorpSoundGenerator
 Pointer to the SoundGenerator. More...
 
QList< Tone > * pTones
 Pointer to the list of tones held by SoundGenerator. More...
 
QVector< qint32 > mLeft
 
QVector< qint32 > mRight
 Audio signal to be constructed. More...
 

Detailed Description

Sound-generating module which plays the tones held by the SoundGenerator.

This class implements the AudioGenerator from the audio library. It has to be initialized with a pointer to the SoundGenerator which allows the sampler to access the list of tones. The Sampler itself does not hold any local information about the tone being played, all that is contained in the SoundGenerator.

PULL MODE:

As implementation of AudioGenerator the sample operates in the pull mode, that is, the generateSound function is called by the QAudioDevice whenever more data is needed. If no tones are queued the sampler simply returns as much zeroes as needed. For this reason the sampler does not provide any start/stop or mute functionality, instead this should be managed directly by the audio device.

Note
This class contains the most time-critical part for sound generation. It is called by the audio-device in pull mode, i.e., the code is executed in the thread of the audio device.
See also
SoundGenerator

Definition at line 57 of file sampler.h.

Constructor & Destructor Documentation

Sampler::Sampler ( )

Constructor of the Sampler without functionality.

Definition at line 37 of file sampler.cpp.

Member Function Documentation

void Sampler::exit ( )
inline

Definition at line 62 of file sampler.h.

Here is the call graph for this function:

size_t Sampler::generateSound ( char *  buffer,
size_t  maxSize 
)
finaloverrideprivatevirtual

Essential sound-generating function of the sampler.

This is the essential time-critical function of the sampler which generates the actual sound. The audio device calls this function whenever the audio stream needs more PCM values.

Parameters
buffer: Pointer to the array where the PCM values are stored.
maxSize: Maximal allowed number of bytes to be generated.
Returns
: size of the generated PCM stream.

Reimplemented from AudioGenerator.

Definition at line 81 of file sampler.cpp.

Here is the call graph for this function:

size_t AudioGenerator::getMaxPacketSize ( )
inlineinherited

Definition at line 50 of file audiogenerator.h.

Here is the call graph for this function:

int AudioGenerator::getSampleRate ( )
inlineinherited

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 Sampler::init ( SoundGenerator soundgenerator)

Initialization of the sampler.

Parameters
soundgenerator: Pointer to the SoundGenerator from where the sampler is controlled.

Definition at line 56 of file sampler.cpp.

void AudioGenerator::setMaxPacketSize ( int  n)
inlineinherited

Definition at line 49 of file audiogenerator.h.

void AudioGenerator::setParameters ( const AudioParameters parameters)
inherited

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

QVector<qint32> Sampler::mLeft
private

Definition at line 70 of file sampler.h.

size_t AudioGenerator::mMaxNumberOfFrames
protectedinherited

Maximal number of frames per buffer.

Definition at line 59 of file audiogenerator.h.

AudioParameters AudioGenerator::mParameters
protectedinherited

Local copy of the audio parameters.

Definition at line 58 of file audiogenerator.h.

QVector<qint32> Sampler::mRight
private

Audio signal to be constructed.

Definition at line 70 of file sampler.h.

SoundGenerator* Sampler::pSoundGenerator
private

Pointer to the SoundGenerator.

Definition at line 67 of file sampler.h.

QList<Tone>* Sampler::pTones
private

Pointer to the list of tones held by SoundGenerator.

Definition at line 68 of file sampler.h.


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