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

Class managing the generation of sound. More...

#include <soundgenerator.h>

Inheritance diagram for SoundGenerator:
Inheritance graph
Collaboration diagram for SoundGenerator:
Collaboration graph

Public Slots

void receiveTuningCorrections (QMap< int, double > corrections)
 
void setSustainPedal (bool pressed)
 
void setSostenutoPedal (bool pressed)
 
void setSoftPedal (bool pressed)
 

Signals

void forceImmediateProcessing ()
 

Public Member Functions

 SoundGenerator ()
 
void init (Application *application, Voice *voice)
 Initialize the SoundGenerator. More...
 
bool init () override
 Virtual initialization function (no functionality here) More...
 
void suspend () override final
 Mark the thread as suspended. More...
 
void setMaxPacketSize (int n)
 
size_t getMaxPacketSize ()
 
void registerRequest (Request &request)
 Register a single request to play a note in the queue. More...
 
void registerAllNotesOff ()
 
SamplergetSampler ()
 
QList< Tone > * getTones ()
 
void lockTones ()
 
void unlockTones ()
 
ApplicationgetApplication ()
 
quint32 getIncrement (int key)
 
void setIncrement (int key, quint32 increment)
 
void clearIncrements ()
 
virtual bool exit ()
 Virtual exit function (no functionality here) More...
 
virtual bool start ()
 Start the thread. More...
 
virtual bool stop ()
 Stop the thread. More...
 
virtual void resume ()
 Resume from the suspend mode. More...
 
bool isActive () const
 Return true if thread is running and not suspended. More...
 
void setVerbosity (int verbosity)
 Set verbosity level of messages. More...
 
int getVerbosity ()
 Get verbosity level. More...
 
QString getThreadName () const
 Get thread name. More...
 

Protected Member Functions

virtual void initiallyCalledWorker ()
 Virtual worker function called when the thread is starting. More...
 
virtual void finallyCalledWorker ()
 Virtual worker function called when the thread stops. More...
 
virtual void periodicallyCalledWorker ()
 Virtual worker function called periodically from the timer. More...
 
void setPriority (const QThread::Priority p)
 Set thread priority. More...
 
void setTimerInterval (const int msec, const int firstMsec=0)
 Set timer interval for the periodically called worker. More...
 
void setThreadName (const QString name)
 Set thread name (Linux only) More...
 
bool isInterruptionRequested () const
 Return true if the thread was requested to interrupt or terminate. More...
 

Private Types

using State = Tone::State
 

Private Slots

void timeout () override final
 Private thread worker function. More...
 

Private Member Functions

void handleRequest (Request &request)
 
void manageToneDynamics ()
 
bool queueFilled ()
 

Private Attributes

QQueue< RequestmQueue
 
QMutex mQueueMutex
 
QList< TonemTones
 
QMutex mToneMutex
 
QVector< quint32 > mIncrements
 
QMutex mIncrementMutex
 
Sampler mSampler
 
VoicepVoice
 
ApplicationpApplication
 
bool mSustainPedeal
 
bool mSostenutoPedal
 
bool mSoftPedal
 

Detailed Description

Class managing the generation of sound.

Definition at line 42 of file soundgenerator.h.

Member Typedef Documentation

Definition at line 88 of file soundgenerator.h.

Constructor & Destructor Documentation

SoundGenerator::SoundGenerator ( )

Definition at line 38 of file soundgenerator.cpp.

Member Function Documentation

void SoundGenerator::clearIncrements ( )

Definition at line 365 of file soundgenerator.cpp.

virtual bool ThreadBase::exit ( )
inlinevirtualinherited

Virtual exit function (no functionality here)

Reimplemented in AudioOutput.

Definition at line 71 of file threadbase.h.

Here is the call graph for this function:

virtual void ThreadBase::finallyCalledWorker ( )
inlineprotectedvirtualinherited

Virtual worker function called when the thread stops.

Reimplemented in Tuner, and AudioOutput.

Definition at line 87 of file threadbase.h.

void SoundGenerator::forceImmediateProcessing ( )
signal
Application* SoundGenerator::getApplication ( )
inline

Definition at line 64 of file soundgenerator.h.

Here is the call graph for this function:

quint32 SoundGenerator::getIncrement ( int  key)

Definition at line 353 of file soundgenerator.cpp.

size_t SoundGenerator::getMaxPacketSize ( )
inline

Definition at line 53 of file soundgenerator.h.

Here is the call graph for this function:

Sampler& SoundGenerator::getSampler ( )
inline

Definition at line 59 of file soundgenerator.h.

QString ThreadBase::getThreadName ( ) const
inherited

Get thread name.

Definition at line 132 of file threadbase.cpp.

Here is the call graph for this function:

QList<Tone>* SoundGenerator::getTones ( )
inline

Definition at line 60 of file soundgenerator.h.

int ThreadBase::getVerbosity ( )
inlineinherited

Get verbosity level.

Definition at line 80 of file threadbase.h.

Here is the call graph for this function:

void SoundGenerator::handleRequest ( Request request)
private

Definition at line 158 of file soundgenerator.cpp.

Here is the call graph for this function:

void SoundGenerator::init ( Application application,
Voice voice 
)

Initialize the SoundGenerator.

Parameters
application: Pointer to the main application
voice: Pointer to the Voice (the collection of scales describing an instrument)

Definition at line 64 of file soundgenerator.cpp.

Here is the call graph for this function:

bool SoundGenerator::init ( )
inlineoverridevirtual

Virtual initialization function (no functionality here)

Reimplemented from ThreadBase.

Definition at line 49 of file soundgenerator.h.

Here is the call graph for this function:

virtual void ThreadBase::initiallyCalledWorker ( )
inlineprotectedvirtualinherited

Virtual worker function called when the thread is starting.

Reimplemented in Tuner, and AudioOutput.

Definition at line 85 of file threadbase.h.

bool ThreadBase::isActive ( ) const
inherited

Return true if thread is running and not suspended.

Definition at line 136 of file threadbase.cpp.

bool ThreadBase::isInterruptionRequested ( ) const
protectedinherited

Return true if the thread was requested to interrupt or terminate.

Definition at line 128 of file threadbase.cpp.

void SoundGenerator::lockTones ( )
inline

Definition at line 61 of file soundgenerator.h.

void SoundGenerator::manageToneDynamics ( )
private

Definition at line 247 of file soundgenerator.cpp.

Here is the call graph for this function:

virtual void ThreadBase::periodicallyCalledWorker ( )
inlineprotectedvirtualinherited

Virtual worker function called periodically from the timer.

Reimplemented in Tuner, and AudioDeviceGuard.

Definition at line 89 of file threadbase.h.

Here is the call graph for this function:

bool SoundGenerator::queueFilled ( )
private

Definition at line 347 of file soundgenerator.cpp.

void SoundGenerator::receiveTuningCorrections ( QMap< int, double >  corrections)
slot

Definition at line 378 of file soundgenerator.cpp.

Here is the call graph for this function:

void SoundGenerator::registerAllNotesOff ( )

Definition at line 111 of file soundgenerator.cpp.

void SoundGenerator::registerRequest ( Request request)

Register a single request to play a note in the queue.

This function is thread-safe and appends a request in the local mQueue.

Parameters
request: Reference to the Request to be registered
See also
Request

Definition at line 102 of file soundgenerator.cpp.

Here is the call graph for this function:

void ThreadBase::resume ( )
virtualinherited

Resume from the suspend mode.

Restart the timer and clear the mSuspended flag

Reimplemented in MidiPlayer.

Definition at line 99 of file threadbase.cpp.

void SoundGenerator::setIncrement ( int  key,
quint32  increment 
)

Definition at line 359 of file soundgenerator.cpp.

void SoundGenerator::setMaxPacketSize ( int  n)
inline

Definition at line 52 of file soundgenerator.h.

Here is the call graph for this function:

void ThreadBase::setPriority ( const QThread::Priority  p)
protectedinherited

Set thread priority.

Definition at line 109 of file threadbase.cpp.

Here is the call graph for this function:

void SoundGenerator::setSoftPedal ( bool  pressed)
slot

Definition at line 406 of file soundgenerator.cpp.

void SoundGenerator::setSostenutoPedal ( bool  pressed)
slot

Definition at line 400 of file soundgenerator.cpp.

void SoundGenerator::setSustainPedal ( bool  pressed)
slot

Definition at line 394 of file soundgenerator.cpp.

void ThreadBase::setThreadName ( const QString  name)
protectedinherited

Set thread name (Linux only)

Definition at line 121 of file threadbase.cpp.

Here is the call graph for this function:

void ThreadBase::setTimerInterval ( const int  msec,
const int  firstMsec = 0 
)
protectedinherited

Set timer interval for the periodically called worker.

Definition at line 117 of file threadbase.cpp.

Here is the call graph for this function:

void ThreadBase::setVerbosity ( int  verbosity)
inherited

Set verbosity level of messages.

Definition at line 113 of file threadbase.cpp.

Here is the call graph for this function:

bool ThreadBase::start ( )
virtualinherited

Start the thread.

Starts the thread. If the thread is suspended it will resume. If the thread is already started the function does nothing.

Returns
True on succes

Reimplemented in Tuner, and AudioOutput.

Definition at line 64 of file threadbase.cpp.

Here is the call graph for this function:

bool ThreadBase::stop ( )
virtualinherited

Stop the thread.

Send a termination request to the execution loop. Wait for the thread to terminate. The active components of the thread should call isInterruptionRequested() and quit immediately if this function is true.

Returns
If the thread terminates regularly return true. If the thread does not terminate after a timeout of 2 secs return false.

Reimplemented in MidiPlayer, AudioOutput, and Instrument.

Definition at line 152 of file threadbase.cpp.

Here is the call graph for this function:

void SoundGenerator::suspend ( )
finaloverridevirtual

Mark the thread as suspended.

Calling this function tells the thread that it has to wait in some sort of standby. Note that the thread itself is not terminated and that the event loop is still active. Calling this function stops the timer so that the periodicallyCalledWorker() is not active any more. In addition the mSuspended flag is set.

Reimplemented from ThreadBase.

Definition at line 77 of file soundgenerator.cpp.

Here is the call graph for this function:

void SoundGenerator::timeout ( )
finaloverrideprivateslot

Private thread worker function.

Definition at line 138 of file soundgenerator.cpp.

Here is the call graph for this function:

void SoundGenerator::unlockTones ( )
inline

Definition at line 62 of file soundgenerator.h.

Member Data Documentation

QMutex SoundGenerator::mIncrementMutex
private

Definition at line 97 of file soundgenerator.h.

QVector<quint32> SoundGenerator::mIncrements
private

Definition at line 96 of file soundgenerator.h.

QQueue<Request> SoundGenerator::mQueue
private

Definition at line 90 of file soundgenerator.h.

QMutex SoundGenerator::mQueueMutex
private

Definition at line 91 of file soundgenerator.h.

Sampler SoundGenerator::mSampler
private

Definition at line 99 of file soundgenerator.h.

bool SoundGenerator::mSoftPedal
private

Definition at line 107 of file soundgenerator.h.

bool SoundGenerator::mSostenutoPedal
private

Definition at line 106 of file soundgenerator.h.

bool SoundGenerator::mSustainPedeal
private

Definition at line 105 of file soundgenerator.h.

QMutex SoundGenerator::mToneMutex
private

Definition at line 94 of file soundgenerator.h.

QList<Tone> SoundGenerator::mTones
private

Definition at line 93 of file soundgenerator.h.

Application* SoundGenerator::pApplication
private

Definition at line 102 of file soundgenerator.h.

Voice* SoundGenerator::pVoice
private

Definition at line 101 of file soundgenerator.h.


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