Just Intonation  Version 1.3.0 (18)
Explore scale-independent dynamically adapting tuning in just intonation
Wave Class Reference

Class holding the sampled sound for one key. More...

#include <wave.h>

Collaboration diagram for Wave:
Collaboration graph

Public Member Functions

 Wave ()
 Constructor, resetting member variables. More...
 
bool read (QIODevice &iodevice)
 Read a wave from disk. More...
 
bool write (QIODevice &iodevice)
 Write a PCM wave to disk (QIODevice) More...
 
bool insert (const QVector< qint32 > &L, const QVector< qint32 > &R, const bool release, const double amplitude)
 
void printInfo (int keynumber=0)
 Debugging function: Write a short summary of the wave data to qDebug() More...
 
quint32 getRepetitionIndex ()
 
double getRepetitionFactor ()
 
const QVector< qint16 > * getSustainSample ()
 
const QVector< qint16 > * getReleaseSample ()
 
int getReleaseShift ()
 
int getSustainShift ()
 
double getEnvelope (int index)
 
bool envelopeExists ()
 
bool waveFormExists ()
 
bool releaseExists ()
 
void computeTriangularWave (double frequency, int samplerate, double stereo)
 Compute a synthetic triangular wave. More...
 

Private Member Functions

void computeEnvelope (int samplerate)
 Determine the envelope of the sustain wave. More...
 
void automaticCyclicMorphing ()
 Function defined externally (Importer) More...
 

Private Attributes

quint32 mRepetitionIndex
 Index from where on the sample is repeated. More...
 
double mRepetitionFactor
 Amplitude decrease factor upon repetition. More...
 
QVector< qint16 > mSustainSample
 Sound sample when key is pressed. More...
 
QVector< qint16 > mReleaseSample
 Sound sample when key is releasek. More...
 
int mSustainShift
 PCM amplitudes shifted # bits to the left. More...
 
int mReleaseShift
 PCM amplitedes shifted # bits to the left. More...
 
QVector< double > mEnvelope
 Amplitude envelope. More...
 
const int maxNumberOfFrames = (1<<20)-2
 Maximal number of frames. More...
 
const int envelopeWidth = 0x1000
 Frames per envelope point. More...
 

Detailed Description

Class holding the sampled sound for one key.

A sample is essentially an array of N left-right stereo pairs of signed 16-bit PCM values. This class contains two samples, namely, a long mSustainSample (up to 23.8 sec) for the sound of the instrument while the key is pressed, and a short mReleaseSample for the sound of the instrument in the moment when the key is released (usually about a few seconds).

The sustain sample is limited by the maxNumberOfFrames which is defined here as 20 bits or 1048576 frames. With a standard sample rate of 44100Hz this corresponds to a duration of 23.77 sec. Thus the maximum size of a sample is about 4MB. 88 keys would make up about 350MB of sample data.

See also
Scale, Voice, Instrument

Definition at line 49 of file wave.h.

Constructor & Destructor Documentation

Wave::Wave ( )

Constructor, resetting member variables.

Definition at line 46 of file wave.cpp.

Member Function Documentation

void Wave::automaticCyclicMorphing ( )
private

Function defined externally (Importer)

Definition at line 1028 of file application.cpp.

void Wave::computeEnvelope ( int  samplerate)
private

Determine the envelope of the sustain wave.

Parameters
samplerate

Definition at line 283 of file wave.cpp.

void Wave::computeTriangularWave ( double  frequency,
int  samplerate,
double  stereo 
)

Compute a synthetic triangular wave.

Parameters
frequency: Frequency in Hz
samplerate: Sampling rate
stereo: Parameter contolling the stereo position (0...1)

Definition at line 67 of file wave.cpp.

Here is the call graph for this function:

bool Wave::envelopeExists ( )
inline

Definition at line 73 of file wave.h.

double Wave::getEnvelope ( int  index)
inline

Definition at line 71 of file wave.h.

const QVector<qint16>* Wave::getReleaseSample ( )
inline

Definition at line 67 of file wave.h.

int Wave::getReleaseShift ( )
inline

Definition at line 68 of file wave.h.

double Wave::getRepetitionFactor ( )
inline

Definition at line 65 of file wave.h.

quint32 Wave::getRepetitionIndex ( )
inline

Definition at line 64 of file wave.h.

const QVector<qint16>* Wave::getSustainSample ( )
inline

Definition at line 66 of file wave.h.

int Wave::getSustainShift ( )
inline

Definition at line 69 of file wave.h.

bool Wave::insert ( const QVector< qint32 > &  L,
const QVector< qint32 > &  R,
const bool  release,
const double  amplitude 
)

Definition at line 95 of file wave.cpp.

Here is the call graph for this function:

void Wave::printInfo ( int  keynumber = 0)

Debugging function: Write a short summary of the wave data to qDebug()

Parameters
keynumber: Number of the key to be displayed

Definition at line 266 of file wave.cpp.

bool Wave::read ( QIODevice &  iodevice)

Read a wave from disk.

This function reads the member functions of the class Wave from the given QIODevice. The reading is aborted as soon as the QThread::isInterruptionRequested() flag is turned on.

Parameters
iodevice: Reference to the QIODevice opened for reading
Returns
True if successful

Definition at line 211 of file wave.cpp.

Here is the call graph for this function:

bool Wave::releaseExists ( )
inline

Definition at line 75 of file wave.h.

Here is the call graph for this function:

bool Wave::waveFormExists ( )
inline

Definition at line 74 of file wave.h.

bool Wave::write ( QIODevice &  iodevice)

Write a PCM wave to disk (QIODevice)

Parameters
iodevice: Reference to the QIODevice opened for writing
Returns
True if successful

Definition at line 159 of file wave.cpp.

Here is the call graph for this function:

Member Data Documentation

const int Wave::envelopeWidth = 0x1000
private

Frames per envelope point.

Definition at line 92 of file wave.h.

const int Wave::maxNumberOfFrames = (1<<20)-2
private

Maximal number of frames.

Definition at line 91 of file wave.h.

QVector<double> Wave::mEnvelope
private

Amplitude envelope.

Definition at line 85 of file wave.h.

QVector<qint16> Wave::mReleaseSample
private

Sound sample when key is releasek.

Definition at line 82 of file wave.h.

int Wave::mReleaseShift
private

PCM amplitedes shifted # bits to the left.

Definition at line 84 of file wave.h.

double Wave::mRepetitionFactor
private

Amplitude decrease factor upon repetition.

Definition at line 80 of file wave.h.

quint32 Wave::mRepetitionIndex
private

Index from where on the sample is repeated.

Definition at line 79 of file wave.h.

QVector<qint16> Wave::mSustainSample
private

Sound sample when key is pressed.

Definition at line 81 of file wave.h.

int Wave::mSustainShift
private

PCM amplitudes shifted # bits to the left.

Definition at line 83 of file wave.h.


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