|
wavelength 1.0.0
|
One SPU2 voice and the note it plays. More...
#include <voice.h>

Public Member Functions | |
| Voice () | |
| Construct a free voice with no descriptor. | |
| void | Init () |
| Free the voice. | |
| void | Dump () const |
| Print the voice's descriptor to the console. | |
| void | ComputeVolume (unsigned int *left, unsigned int *right) const |
| Compute the voice's volume registers from its channel, bank, program, and descriptor. | |
| unsigned int | ComputePitch () const |
| Compute the voice's pitch register from its channel, program, and descriptor, without vibrato. | |
Static Public Member Functions | |
| static int | FindFree (Voice *voices, int count, int *stealIndex) |
| Find the first free voice of a core, or else the best voice to steal. | |
| static void | CalculateVolume (unsigned char velocity, unsigned char bankVolume, unsigned char programVolume, unsigned char sampleVolume, unsigned char channelVolume, unsigned char channelExpression, unsigned char pan, unsigned int *left, unsigned int *right, signed char surround) |
| Compute the left and right volume registers of a note. | |
| static unsigned int | CalculatePitch (unsigned char note, unsigned char baseKey, int semitones, int cents, int sampleRate) |
| Compute the pitch register of a note. | |
Public Attributes | |
| unsigned char | mChannel |
| unsigned char | mNote |
| unsigned short | mBank |
| unsigned char | mVelocity |
| int | mPitch |
| int | mVibratoPhase |
| int | mVibratoTable |
| unsigned int | mAge |
| int | mState |
| BankSampleDesc * | mSampleDesc |
| unsigned char | mPriority |
One SPU2 voice and the note it plays.
The class has no RTTI, and its name is inferred from its role. The synthesiser has one per hardware voice of each core and a list of retired copies of voices whose one-shot waveform ended before the note-off.
|
inline |
Construct a free voice with no descriptor.
| void Voice::Init | ( | ) |
Free the voice.
| void Voice::Dump | ( | ) | const |
Print the voice's descriptor to the console.
|
static |
Find the first free voice of a core, or else the best voice to steal.
The steal candidate is the playing voice with the lowest priority, the oldest among equals. The search starts from the first voice whatever its state.
| voices | The core's voices. |
| count | Number of voices. |
| stealIndex | Receives -1 when a voice is free, otherwise the steal candidate. |
|
static |
Compute the left and right volume registers of a note.
Every level is an index into the volume curve. With surround set, one side is inverted for the surround decoder.
| velocity | Note velocity. |
| bankVolume | Bank volume. |
| programVolume | Program volume. |
| sampleVolume | Descriptor volume. |
| channelVolume | Channel volume. |
| channelExpression | Channel expression. |
| pan | Combined pan, zero to 127. |
| left | Receives the left volume. |
| right | Receives the right volume. |
| surround | Nonzero to invert one side. |
|
static |
Compute the pitch register of a note.
| note | Note to play. |
| baseKey | Note at which the sample plays at its sample rate. |
| semitones | Transposition in semitones. |
| cents | Transposition in cents, borrowed into semitones when negative. |
| sampleRate | Rate of the sample in hertz. |
sampleRate. | void Voice::ComputeVolume | ( | unsigned int * | left, |
| unsigned int * | right ) const |
Compute the voice's volume registers from its channel, bank, program, and descriptor.
The outputs are not written when the channel has no program.
| left | Receives the left volume. |
| right | Receives the right volume. |
| unsigned int Voice::ComputePitch | ( | ) | const |
Compute the voice's pitch register from its channel, program, and descriptor, without vibrato.
| unsigned char Voice::mChannel |
MIDI channel of the note.
| unsigned char Voice::mNote |
Note number.
| unsigned short Voice::mBank |
Bank slot of the note's program.
| unsigned char Voice::mVelocity |
Note velocity.
| int Voice::mPitch |
Pitch register value before vibrato.
| int Voice::mVibratoPhase |
Offset into the vibrato table, or -1 for no vibrato.
| int Voice::mVibratoTable |
Zero for the fast table, one for the slow one.
| unsigned int Voice::mAge |
Note-on serial; smaller is older.
| int Voice::mState |
A VoiceState.
| BankSampleDesc* Voice::mSampleDesc |
Descriptor of the note.
| unsigned char Voice::mPriority |
Channel priority at the note-on.