Entropy Piano Tuner  1.1.3 (documentation not yet complete) An open-source experimental software for piano tuning by entropy minimization
SoundGenerator Class Reference

Class for managing the sound generation in the EPT. More...

#include <soundgenerator.h>

Inheritance diagram for SoundGenerator:
Collaboration diagram for SoundGenerator:

## Public Types

enum  SoundGeneratorMode { SGM_DEACTIVATED, SGM_SYNTHESIZE_KEY, SGM_REFERENCE_TONE }
Mode for sound generation. More...

## Public Member Functions

Constructor, initializes the member variables. More...

~SoundGenerator ()

void init ()
Initialize (no functionality) More...

void exit ()
Synthesizer shutdown. More...

Public Member Functions inherited from MessageListener
MessageListener (bool defaultActivation=true)

virtual ~MessageListener ()

bool isMessageListenerActive () const

void activateMessageListener ()

void deactivateMessageListener ()

## Private Member Functions

void handleMessage (MessagePtr m) overridefinal
Sound generator message listener and dispatcher. More...

Handle MIDI keypress. More...

void playResonatingSineWave (int keynumber, double frequency, double volume)
Play a permanent sine wave as a resonating background sound for tuning. More...

void playResonatingReferenceSound (int keynumber)
Play a resonating reference sound in the tuning mode. More...

void stopResonatingReferenceSound ()
Stop the resonating reference sound. More...

void changeVolumeOfResonatingReferenceSound (double level)
Change the volume of the resonating reference sound. More...

void preCalculateSoundOfKey (const int keynumber)
Calculate the sound of a given key in advance, using the spectrum of the given key. More...

void preCalculateSoundOfKey (const int keynumber, Synthesizer::Spectrum &spectrum)
Calculate the sound of a given key in advance, using an explicit spectrum passed as a parameter. More...

void preCalculateSoundOfAllKeys ()
Calculate the sound of all keys in advance. More...

## Private Attributes

Synthesizer mSynthesizer
Instance of the synthesizer. More...

const PianomPiano
Pointer to the piano. More...

OperationMode mOperationMode
Copy of the operation mode. More...

int mNumberOfKeys
Copy of the number of keys. More...

int mKeyNumberOfA4
Copy of A-key position. More...

int mSelectedKey
Copy of selected key. More...

int mResonatingKey
Keynumber of the resonating sound. More...

double mResonatingVolume
Volume of the resonating sound. More...

## Detailed Description

Class for managing the sound generation in the EPT.

This class manages and composes the sound to be played by the synthesizer. It is completely driven by messages. It is some kind of SoundGenerationManager.

Definition at line 41 of file soundgenerator.h.

## Member Enumeration Documentation

Mode for sound generation.

Enumerator
SGM_DEACTIVATED

No sound generation.

SGM_SYNTHESIZE_KEY

Produce a sound which imitates the string.

SGM_REFERENCE_TONE

Produce a simple sine wave as reference.

Definition at line 51 of file soundgenerator.h.

## Constructor & Destructor Documentation

Constructor, initializes the member variables.

Parameters
 audioadapter : Pointer to the audio output implementation

Definition at line 54 of file soundgenerator.cpp.

Here is the call graph for this function:

 SoundGenerator::~SoundGenerator ( )
inline

Definition at line 45 of file soundgenerator.h.

## Member Function Documentation

 void SoundGenerator::changeVolumeOfResonatingReferenceSound ( double level )
private

Change the volume of the resonating reference sound.

In order to produce an efficient interference, the volume of the resonating reference sound is adjusted automatically to the actual volume of the piano. To this end the 'level' sent to the VU meter is mapped back to a volume and the sustain level of the reference sound in the synthesizer is changed accordingly.

Parameters
 level : Level between 0 and 1

Definition at line 395 of file soundgenerator.cpp.

Here is the call graph for this function:

 void SoundGenerator::exit ( )
inline

Synthesizer shutdown.

Definition at line 48 of file soundgenerator.h.

Here is the call graph for this function:

 void SoundGenerator::handleMessage ( MessagePtr m )
finaloverrideprivatevirtual

Sound generator message listener and dispatcher.

The sound generator is exclusively driven by messages. The present function listens to the messages and takes action accordingly.

Parameters
 m : Pointer to the message.

Implements MessageListener.

Definition at line 79 of file soundgenerator.cpp.

Here is the call graph for this function:

 void SoundGenerator::handleMidiKeypress ( MidiAdapter::Data & data )
private

Handle MIDI keypress.

This function takes action on MIDI keypress events depending on the actual operation mode. In the tuning mode the MIDI keybaord plays simple ET sine waves. In the recording mode it echos the recorded key as a confirmation of successful recording. In the calculating mode it can be used to test the computed tuning curve by playing the MIDI keyboard.

Parameters
 data : Data structure delivered by the MIDI event.

Definition at line 249 of file soundgenerator.cpp.

Here is the call graph for this function:

 void SoundGenerator::init ( )
inline

Initialize (no functionality)

Definition at line 47 of file soundgenerator.h.

 void SoundGenerator::playResonatingReferenceSound ( int keynumber )
private

Play a resonating reference sound in the tuning mode.

To support accurate tuning, the EPT generates an imitation of the recorded piano sound in the computed tune in the background. This allows the user to tune the strings according to the sound in the earphone.

The following function starts such a "resonating reference sound". To avoid interference with the MIDI playback system, which is also active in the tuning mode, the synthesizer id's of the reference sound are internally shifted by mNumberOfKeys.

Parameters
 keynumber : Number of the key.

Definition at line 325 of file soundgenerator.cpp.

Here is the call graph for this function:

 void SoundGenerator::playResonatingSineWave ( int keynumber, double frequency, double volume )
private

Play a permanent sine wave as a resonating background sound for tuning.

Parameters
 keynumber : Number of the key frequency : Frequency of the sine wave to be played. volume : Volume of the tone

Definition at line 418 of file soundgenerator.cpp.

Here is the call graph for this function:

 void SoundGenerator::preCalculateSoundOfAllKeys ( )
private

Calculate the sound of all keys in advance.

Definition at line 476 of file soundgenerator.cpp.

Here is the call graph for this function:

 void SoundGenerator::preCalculateSoundOfKey ( const int keynumber )
private

Calculate the sound of a given key in advance, using the spectrum of the given key.

Parameters
 keynumber : Number of the key

Definition at line 445 of file soundgenerator.cpp.

Here is the call graph for this function:

 void SoundGenerator::preCalculateSoundOfKey ( const int keynumber, Synthesizer::Spectrum & spectrum )
private

Calculate the sound of a given key in advance, using an explicit spectrum passed as a parameter.

Parameters
 keynumber : Number of the key spectrum : The explicit spectrum

Definition at line 462 of file soundgenerator.cpp.

Here is the call graph for this function:

 void SoundGenerator::stopResonatingReferenceSound ( )
private

Stop the resonating reference sound.

Definition at line 369 of file soundgenerator.cpp.

Here is the call graph for this function:

## Member Data Documentation

 int SoundGenerator::mKeyNumberOfA4
private

Copy of A-key position.

Definition at line 74 of file soundgenerator.h.

 int SoundGenerator::mNumberOfKeys
private

Copy of the number of keys.

Definition at line 73 of file soundgenerator.h.

 OperationMode SoundGenerator::mOperationMode
private

Copy of the operation mode.

Definition at line 72 of file soundgenerator.h.

 const Piano* SoundGenerator::mPiano
private

Pointer to the piano.

Definition at line 71 of file soundgenerator.h.

 int SoundGenerator::mResonatingKey
private

Keynumber of the resonating sound.

Definition at line 76 of file soundgenerator.h.

 double SoundGenerator::mResonatingVolume
private

Volume of the resonating sound.

Definition at line 77 of file soundgenerator.h.

 int SoundGenerator::mSelectedKey
private

Copy of selected key.

Definition at line 75 of file soundgenerator.h.

 Synthesizer SoundGenerator::mSynthesizer
private

Instance of the synthesizer.

Definition at line 70 of file soundgenerator.h.

The documentation for this class was generated from the following files:
• /home/hinrichsen/Dokumente/Aktuell/EPT/Entropy-Piano-Tuner/core/audio/player/soundgenerator.h
• /home/hinrichsen/Dokumente/Aktuell/EPT/Entropy-Piano-Tuner/core/audio/player/soundgenerator.cpp