iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Friends | List of all members
SynthVoice Class Referenceabstract

Public Member Functions

virtual bool GetBusy () const =0
 
virtual void Trigger (double level, bool isRetrigger)
 Trigger is called by the VoiceAllocator when a new voice should start, or if the voice limit has been hit and an existing voice needs to re-trigger. More...
 
virtual void Release ()
 As with Trigger, called to do optional tasks when a voice is released. More...
 
virtual void ProcessSamplesAccumulating (sample **inputs, sample **outputs, int nInputs, int nOutputs, int startIdx, int nFrames)
 Process a block of audio data for the voice. More...
 
virtual void SetSampleRateAndBlockSize (double sampleRate, int blockSize)
 Implement this if you need to do work when the sample rate or block size changes. More...
 
virtual void SetProgramNumber (int pgm)
 Implement this to allow picking a sound program from an integer index, as with MIDI. More...
 
virtual void SetControl (int controlNumber, float value)
 Implement this to respond to control numbers for which there are not ramps. More...
 

Protected Attributes

VoiceInputs mInputs
 
int64_t mLastTriggeredTime {-1}
 
uint8_t mVoiceNumber {0}
 
uint8_t mZone {0}
 
uint8_t mChannel {0}
 
uint8_t mKey {0}
 
double mBasePitch {0.}
 
double mGain {0.}
 

Friends

class MidiSynth
 
class VoiceAllocator
 

Detailed Description

Definition at line 54 of file SynthVoice.h.

Constructor & Destructor Documentation

◆ ~SynthVoice()

virtual SynthVoice::~SynthVoice ( )
inlinevirtual

Definition at line 58 of file SynthVoice.h.

Member Function Documentation

◆ GetBusy()

virtual bool SynthVoice::GetBusy ( ) const
pure virtual
Returns
true if voice is generating any audio.

Referenced by MidiSynth::ProcessBlock().

◆ ProcessSamplesAccumulating()

virtual void SynthVoice::ProcessSamplesAccumulating ( sample **  inputs,
sample **  outputs,
int  nInputs,
int  nOutputs,
int  startIdx,
int  nFrames 
)
inlinevirtual

Process a block of audio data for the voice.

Parameters
inputsPointer to input channel arrays. Sometimes synthesisers have audio inputs. Alternatively you can pass in modulation from global LFOs etc here.
outputsPointer to output channel arrays. You should add to the existing data in these arrays (so that all the voices get summed)
nInputsThe number of input channels that contain valid data
nOutputsThe number of output channels that contain valid data
startIdxThe start index of the block of samples to process
nFramesThe number of samples to process in this block

Definition at line 78 of file SynthVoice.h.

◆ Release()

virtual void SynthVoice::Release ( )
inlinevirtual

As with Trigger, called to do optional tasks when a voice is released.

Definition at line 69 of file SynthVoice.h.

◆ SetControl()

virtual void SynthVoice::SetControl ( int  controlNumber,
float  value 
)
inlinevirtual

Implement this to respond to control numbers for which there are not ramps.

A synthesizer could use its own ramps internally if needed.

Parameters
controlNumberThe MIDI controller number
valueThe normalized value

Definition at line 102 of file SynthVoice.h.

◆ SetProgramNumber()

virtual void SynthVoice::SetProgramNumber ( int  pgm)
inlinevirtual

Implement this to allow picking a sound program from an integer index, as with MIDI.

Parameters
pgmThe new program number

Definition at line 96 of file SynthVoice.h.

◆ SetSampleRateAndBlockSize()

virtual void SynthVoice::SetSampleRateAndBlockSize ( double  sampleRate,
int  blockSize 
)
inlinevirtual

Implement this if you need to do work when the sample rate or block size changes.

Parameters
sampleRateThe new sample rate
blockSizeThe new block size in samples

Definition at line 92 of file SynthVoice.h.

◆ Trigger()

virtual void SynthVoice::Trigger ( double  level,
bool  isRetrigger 
)
inlinevirtual

Trigger is called by the VoiceAllocator when a new voice should start, or if the voice limit has been hit and an existing voice needs to re-trigger.

While the VoiceInputs are sufficient to control a voice from the VoiceAllocator, this method can be used to do additional tasks like resetting oscillators.

Parameters
levelNormalised starting level for this voice, derived from the velocity of the keypress, or in the case of a re-trigger the existing level
Todo:
check
Parameters
isRetriggerIf this is true it means the voice is being re-triggered, and you should accommodate for this in your algorithm

Definition at line 66 of file SynthVoice.h.

Friends And Related Function Documentation

◆ MidiSynth

friend class MidiSynth
friend

Definition at line 114 of file SynthVoice.h.

◆ VoiceAllocator

friend class VoiceAllocator
friend

Definition at line 115 of file SynthVoice.h.

Member Data Documentation

◆ mBasePitch

double SynthVoice::mBasePitch {0.}
protected

Definition at line 111 of file SynthVoice.h.

◆ mChannel

uint8_t SynthVoice::mChannel {0}
protected

Definition at line 109 of file SynthVoice.h.

◆ mGain

double SynthVoice::mGain {0.}
protected

Definition at line 112 of file SynthVoice.h.

◆ mInputs

VoiceInputs SynthVoice::mInputs
protected

Definition at line 105 of file SynthVoice.h.

◆ mKey

uint8_t SynthVoice::mKey {0}
protected

Definition at line 110 of file SynthVoice.h.

◆ mLastTriggeredTime

int64_t SynthVoice::mLastTriggeredTime {-1}
protected

Definition at line 106 of file SynthVoice.h.

◆ mVoiceNumber

uint8_t SynthVoice::mVoiceNumber {0}
protected

Definition at line 107 of file SynthVoice.h.

◆ mZone

uint8_t SynthVoice::mZone {0}
protected

Definition at line 108 of file SynthVoice.h.


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