iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Attributes | List of all members
MidiSynth Class Reference

A monophonic/polyphonic synthesiser base class which can be supplied with a custom voice. More...

#include <MidiSynth.h>

Public Member Functions

 MidiSynth (VoiceAllocator::EPolyMode mode, int blockSize=kDefaultBlockSize)
 
 MidiSynth (const MidiSynth &)=delete
 
MidiSynthoperator= (const MidiSynth &)=delete
 
void Reset ()
 
void SetSampleRateAndBlockSize (double sampleRate, int blockSize)
 
void SetVoicesActive (bool active)
 If you are using this class in a non-traditional mode of polyphony (e.g.to stack loads of voices) you might want to manually SetVoicesActive() usually this would happen when you trigger notes. More...
 
void InitBasicMPE ()
 
void SetPitchBendRange (int pitchBendRange)
 Set the pitch bend range for non-MPE mode. More...
 
void SetPolyMode (VoiceAllocator::EPolyMode mode)
 
void SetATMode (VoiceAllocator::EATMode mode)
 
void SetKeyToPitchFn (const std::function< float(int)> &fn)
 Set this function to something other than the default if you need to implement a tuning table for microtonal support. More...
 
void SetNoteOffset (double offset)
 
void SetNoteGlideTime (double t)
 
void SetControlGlideTime (double t)
 
SynthVoiceGetVoice (int voiceIdx)
 
void ForEachVoice (std::function< void(SynthVoice &voice)> func)
 
size_t NVoices () const
 
void AddVoice (SynthVoice *pVoice, uint8_t zone)
 adds a SynthVoice to this MidiSynth, taking ownership of the object. More...
 
void AddMidiMsgToQueue (const IMidiMsg &msg)
 
bool ProcessBlock (sample **inputs, sample **outputs, int nInputs, int nOutputs, int nFrames)
 Processes a block of audio samples. More...
 

Static Public Attributes

static constexpr int kDefaultBlockSize = 32
 This defines the size in samples of a single block of processing that will be done by the synth. More...
 
static constexpr int kDefaultPitchBendRange = 12
 

Detailed Description

A monophonic/polyphonic synthesiser base class which can be supplied with a custom voice.

Supports different kinds of after touch, pitch bend, velocity and after touch curves, unison (currently monophonic mode only)

Definition at line 37 of file MidiSynth.h.

Constructor & Destructor Documentation

◆ MidiSynth()

MidiSynth::MidiSynth ( VoiceAllocator::EPolyMode  mode,
int  blockSize = kDefaultBlockSize 
)

Definition at line 15 of file MidiSynth.cpp.

◆ ~MidiSynth()

MidiSynth::~MidiSynth ( )

Definition at line 34 of file MidiSynth.cpp.

Member Function Documentation

◆ AddMidiMsgToQueue()

void MidiSynth::AddMidiMsgToQueue ( const IMidiMsg msg)
inline

Definition at line 143 of file MidiSynth.h.

◆ AddVoice()

void MidiSynth::AddVoice ( SynthVoice pVoice,
uint8_t  zone 
)
inline

adds a SynthVoice to this MidiSynth, taking ownership of the object.

Definition at line 138 of file MidiSynth.h.

References VoiceAllocator::AddVoice().

◆ ForEachVoice()

void MidiSynth::ForEachVoice ( std::function< void(SynthVoice &voice)>  func)
inline

Definition at line 126 of file MidiSynth.h.

◆ GetVoice()

SynthVoice * MidiSynth::GetVoice ( int  voiceIdx)
inline

Definition at line 121 of file MidiSynth.h.

◆ InitBasicMPE()

void MidiSynth::InitBasicMPE ( )
inline

Definition at line 68 of file MidiSynth.h.

◆ NVoices()

size_t MidiSynth::NVoices ( ) const
inline

Definition at line 132 of file MidiSynth.h.

◆ ProcessBlock()

bool MidiSynth::ProcessBlock ( sample **  inputs,
sample **  outputs,
int  nInputs,
int  nOutputs,
int  nFrames 
)

Processes a block of audio samples.

Parameters
inputsPointer to input Arrays
outputsPointer to output Arrays
nInputsThe number of input channels that contain valid data
nOutputsinput channels that contain valid data
nFramesThe number of sample frames to process
Returns
true if the synth is silent

Definition at line 402 of file MidiSynth.cpp.

References VoiceAllocator::AddEvent(), SynthVoice::GetBusy(), and VoiceAllocator::ProcessEvents().

◆ Reset()

void MidiSynth::Reset ( )
inline

Definition at line 52 of file MidiSynth.h.

◆ SetATMode()

void MidiSynth::SetATMode ( VoiceAllocator::EATMode  mode)
inline

Definition at line 92 of file MidiSynth.h.

◆ SetControlGlideTime()

void MidiSynth::SetControlGlideTime ( double  t)
inline

Definition at line 116 of file MidiSynth.h.

◆ SetKeyToPitchFn()

void MidiSynth::SetKeyToPitchFn ( const std::function< float(int)> &  fn)
inline

Set this function to something other than the default if you need to implement a tuning table for microtonal support.

Parameters
fnA function taking an integer key value and returning a double-precision pitch value, where 0.5 = 220Hz, 1.0 = 440 Hz, 2.0 = 880 Hz ("1v / octave").

Definition at line 101 of file MidiSynth.h.

◆ SetNoteGlideTime()

void MidiSynth::SetNoteGlideTime ( double  t)
inline

Definition at line 111 of file MidiSynth.h.

◆ SetNoteOffset()

void MidiSynth::SetNoteOffset ( double  offset)
inline

Definition at line 106 of file MidiSynth.h.

◆ SetPitchBendRange()

void MidiSynth::SetPitchBendRange ( int  pitchBendRange)
inline

Set the pitch bend range for non-MPE mode.

Definition at line 74 of file MidiSynth.h.

◆ SetPolyMode()

void MidiSynth::SetPolyMode ( VoiceAllocator::EPolyMode  mode)
inline

Definition at line 87 of file MidiSynth.h.

◆ SetSampleRateAndBlockSize()

void MidiSynth::SetSampleRateAndBlockSize ( double  sampleRate,
int  blockSize 
)

Definition at line 477 of file MidiSynth.cpp.

◆ SetVoicesActive()

void MidiSynth::SetVoicesActive ( bool  active)
inline

If you are using this class in a non-traditional mode of polyphony (e.g.to stack loads of voices) you might want to manually SetVoicesActive() usually this would happen when you trigger notes.

Parameters
activeshould the class report that voices are active

Definition at line 63 of file MidiSynth.h.

Member Data Documentation

◆ kDefaultBlockSize

constexpr int MidiSynth::kDefaultBlockSize = 32
staticconstexpr

This defines the size in samples of a single block of processing that will be done by the synth.

Definition at line 41 of file MidiSynth.h.

◆ kDefaultPitchBendRange

constexpr int MidiSynth::kDefaultPitchBendRange = 12
staticconstexpr

Definition at line 42 of file MidiSynth.h.


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