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

Scale - a set of PCM waves with a characteristic intensity and length. More...

#include <scale.h>

Collaboration diagram for Scale:
Collaboration graph

Public Member Functions

 Scale ()
 Constructor, creates N=128 empty wave objects. More...
 
WavegetWave (int &key)
 Get the wave corresponding to a given key. More...
 
bool write (QIODevice &iodevice, Voice *voice=nullptr)
 Write scale to device. More...
 
bool read (QIODevice &iodevice, Voice *voice=nullptr)
 Read data of a scale from a device. More...
 
void printInfo ()
 Scale::printInfo. More...
 
void generateArtificialSound (Voice *voice=nullptr, int samplerate=44100)
 Generate a scale of artificial sounds in equal temperament. More...
 
void cancel ()
 
bool insert (const int key, const QVector< qint32 > &L, const QVector< qint32 > &R, const bool release, const double amplification)
 Insert a newly recorded or generated waveform into the scale. This function checks the parameters and calls the insert function of the corresponding wave object. More...
 

Private Attributes

QVector< WavemWaves
 This is the actual vector of waves. More...
 
const int ctag = 0x78563412
 Tag to recognize a scale in a file. More...
 
bool mCancellationRequested
 Cancel loading. More...
 

Static Private Attributes

static constexpr int N = 128
 Maximal number of waves in a scale. More...
 

Detailed Description

Scale - a set of PCM waves with a characteristic intensity and length.

This class describes a scale of sounds of an instrument. It contains a vector of up to 128 Wave objects, enumerated from 0 to 127 according to the MIDI norm. Not all these objects contain an actual sound. For example, a piano scale runs only from 21 to 108. Nevertheless it is assumed that all 128 wave objects exist.

A given instrument can have different scales. For example, one could have a forte scale and a piano scale as well as a scale for release sounds.

Definition at line 46 of file scale.h.

Constructor & Destructor Documentation

Scale::Scale ( )

Constructor, creates N=128 empty wave objects.

Definition at line 44 of file scale.cpp.

Member Function Documentation

void Scale::cancel ( )
inline

Definition at line 61 of file scale.h.

Here is the call graph for this function:

void Scale::generateArtificialSound ( Voice voice = nullptr,
int  samplerate = 44100 
)

Generate a scale of artificial sounds in equal temperament.

Parameters
voice: Pointer back to the voice, needed to report progress
samplerate: Sample rate used for generation, 44100 by default

Definition at line 70 of file scale.cpp.

Wave & Scale::getWave ( int &  key)

Get the wave corresponding to a given key.

Parameters
key: Index of the key in the range 0...127
Returns
Reference to the wave object

Definition at line 57 of file scale.cpp.

bool Scale::insert ( const int  key,
const QVector< qint32 > &  L,
const QVector< qint32 > &  R,
const bool  release,
const double  amplification 
)

Insert a newly recorded or generated waveform into the scale. This function checks the parameters and calls the insert function of the corresponding wave object.

Parameters
key: Index of the key according to MIDI norm in the range 0..127
L: int32 vector containing the PCM wave of the left channel
R: int32 vector containing the PCM wave of the right channel
release: True if the sound is a release sound (the sound that you hear when the key is released, e.g. how the damper settles)
amplification: Overall amplification factor
Returns
: True on success

Definition at line 103 of file scale.cpp.

void Scale::printInfo ( )

Scale::printInfo.

Definition at line 207 of file scale.cpp.

bool Scale::read ( QIODevice &  iodevice,
Voice voice = nullptr 
)

Read data of a scale from a device.

Parameters
iodevice: Reference to the QIODevice, opened for reading
voice
Returns

Definition at line 176 of file scale.cpp.

Here is the call graph for this function:

bool Scale::write ( QIODevice &  iodevice,
Voice voice = nullptr 
)

Write scale to device.

This function writes the entire scale to a QIODevice, e.g. to a file. It writes a tag (named ctag) followed by all 128 wave objects.

Parameters
iodevice: QIODevice to which the data is written
voice: Pointer back to the voice, needed to report progress
Returns

Definition at line 145 of file scale.cpp.

Here is the call graph for this function:

Member Data Documentation

const int Scale::ctag = 0x78563412
private

Tag to recognize a scale in a file.

Definition at line 73 of file scale.h.

bool Scale::mCancellationRequested
private

Cancel loading.

Definition at line 74 of file scale.h.

QVector<Wave> Scale::mWaves
private

This is the actual vector of waves.

Definition at line 71 of file scale.h.

constexpr int Scale::N = 128
staticprivate

Maximal number of waves in a scale.

Definition at line 72 of file scale.h.


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