Public Types | Public Member Functions | List of all members
ModulatorSynth Class Reference

The base class for all sound generators in HISE. More...

Inheritance diagram for ModulatorSynth:
Processor RoutableProcessor SafeChangeBroadcaster RestorableObject ControlledObject Dispatchable AudioLooper GlobalModulatorContainer ModulatorSampler ModulatorSynthChain ModulatorSynthGroup NoiseSynth SineSynth WaveSynth WavetableSynth

Public Types

enum  InternalChains
 These are the three Chains that the ModulatorSynth uses. More...
 
enum  Parameters { Gain = 0, Balance, VoiceLimit, KillFadeTime }
 
- Public Types inherited from Processor
enum  InternalChains
 Overwrite this enum and list all internal chains. More...
 
enum  SpecialParameters
 Overwrite this enum and add new parameters. More...
 

Public Member Functions

virtual void addProcessorsWhenEmpty ()
 Adds a SimpleEnvelope to a empty ModulatorSynth to prevent clicks. More...
 
virtual bool areVoicesActive () const
 Call this from the message thread and it'll kill all voices at the next buffer. More...
 
virtual int collectSoundsToBeStarted (const HiseEvent &m)
 This method should go through all sounds that are playable and fill the soundsToBeStarted array. More...
 
float getBalance (bool getRightChannelGain) const
 Returns the calculated (equal power) pan value for either the left or the right channel. More...
 
const float * getConstantPitchValues () const
 Returns the pointer to the calculated pitch buffers for the ModulatorSynthVoice's render callback. More...
 
ModulatorSynthVoicegetFreeVoice (SynthesiserSound *s, int midiChannel, int midiNoteNumber)
 Returns a read pointer to the calculated pitch values. More...
 
float getGain () const
 Returns the gain of the ModulatorSynth from 0.0 to 1.0. More...
 
ModulatorSynthGroupgetGroup () const
 Returns the ModulatorSynthGroup that this ModulatorSynth belongs to. More...
 
int getIndexInGroup () const
 Returns the index of the child synth if it resides in a group and -1 if not. More...
 
float * getPitchValuesForVoice () const
 Returns a read pointer to the calculated pitch values. More...
 
ModulatorSynthgetPlayingSynth ()
 Returns either itself or the group that is playing its voices. More...
 
int getVoiceIndex (const SynthesiserVoice *v) const
 Returns the voice index for the voice (the index in the internal voice array). More...
 
void handleHiseEvent (const HiseEvent &e)
 Same functionality as Synthesiser::handleMidiEvent(), but sends the midi event to all Modulators in the chains. More...
 
virtual void handleRetriggeredNote (ModulatorSynthVoice *voice)
 specifies the behaviour when a note is started that is already ringing. More...
 
virtual void initRenderCallback ()
 Clears the internal buffer. More...
 
bool isInGroup () const
 Checks if the Synth was added to a group. More...
 
void killAllVoicesWithNoteNumber (int noteNumber)
 Kills the note with the specified note number. More...
 
int killLastVoice (bool allowTailOff=true)
 Kills the voice that is playing for the longest time. More...
 
void noteOn (const HiseEvent &m)
 Same functionality as Synthesiser::noteOn(), but calls calculateVoiceStartValue() if a new voice is started. More...
 
void postVoiceRendering (int startSample, int numThisTime)
 This method is called to handle all modulatorchains after the voice rendering and handles the GUI metering. More...
 
virtual void prepareToPlay (double sampleRate, int samplesPerBlock)
 This sets up the synth and the ModulatorChains. More...
 
virtual void preVoiceRendering (int startSample, int numThisTime)
 This method is called to handle all modulatorchains just before the voice rendering. More...
 
virtual void renderNextBlockWithModulators (AudioSampleBuffer &outputAudio, const HiseEventBuffer &inputMidi)
 Call this instead of Synthesiser::renderNextBlock to let the ModulatorChains to their work. More...
 
void renderVoice (int startSample, int numThisTime)
 This method is called to actually render all voices. More...
 
void setBalance (float newBalance)
 sets the balance from -1.0 (left) to 1.0 (right) and applies a equal power pan rule. More...
 
void setClockSpeed (ClockSpeed newClockSpeed)
 Sets the interval for the internal clock callback. More...
 
void setGain (float newGain)
 sets the gain of the ModulatorSynth from 0.0 to 1.0. More...
 
void setGroup (ModulatorSynthGroup *parent)
 Sets the parent group. More...
 
virtual bool soundCanBePlayed (ModulatorSynthSound *sound, int midiChannel, int midiNoteNumber, float velocity)
 Checks if the message fits the sound, but can be overriden to implement other group start logic. More...
 
- Public Member Functions inherited from Processor
void enableConsoleOutput (bool shouldBeEnabled)
 Enables the Processor to output messages to the Console. More...
 
bool getEditorState (int state) const
 Restores the state of the Processor's editor. More...
 
const String & getId () const
 Returns the unique id of the Processor instance (!= the Processor name). More...
 
virtual Identifier getIdentifierForParameterIndex (int parameterIndex) const
 This returns a Identifier with the name of the parameter. More...
 
float getInputValue () const
 This can be used to display the Processors input value. More...
 
int getLargestBlockSize () const
 Returns the block size. More...
 
virtual const String getName () const
 Overwrite this and return a pretty name. More...
 
int getNumParameters () const
 This returns the number of (named) parameters. More...
 
float getOutputValue () const
 This can be used to display the Processors output value. More...
 
double getSampleRate () const
 Returns the sample rate. More...
 
const Path getSymbol () const
 Returns the symbol of the Processor. More...
 
virtual const Identifier getType () const =0
 Overwrite this method to specify the name. More...
 
int getVoiceAmount () const noexcept
 getNumVoices() is occupied by the Synthesiser class, d'oh!
 
bool isBypassed () const noexcept
 Returns true if the processor is bypassed. More...
 
 Processor (MainController *m, const String &id_, int numVoices)
 Creates a new Processor with the given Identifier. More...
 
void restoreCompleteEditorState (const XmlElement *storedState)
 Restores the EditorState from a BigInteger that was retrieved using getCompleteEditorState. More...
 
void setAttribute (int parameterIndex, float newValue, juce::NotificationType notifyEditor)
 Changes a Processor parameter. More...
 
void setEditorState (int state, bool isOn, NotificationType notifyView=sendNotification)
 Saves the state of the Processor's editor. More...
 
void setIsOnAir (bool isBeingProcessedInAudioThread)
 Call this method after inserting the processor in the signal chain. More...
 
void setSymbol (Path newSymbol)
 Sets a special symbol for the Processor. More...
 
virtual ~Processor ()
 Overwrite this if you need custom destruction behaviour. More...
 
- Public Member Functions inherited from SafeChangeBroadcaster
void addChangeListener (SafeChangeListener *listener)
 Registers a listener to receive change callbacks from this broadcaster. More...
 
void removeAllChangeListeners ()
 Removes all listeners from the list. More...
 
void removeChangeListener (SafeChangeListener *listener)
 Unregisters a listener from the list. More...
 
void sendAllocationFreeChangeMessage ()
 This will send a message without allocating a message slot. More...
 
void sendChangeMessage (const String &=String())
 Causes an asynchronous change message to be sent to all the registered listeners. More...
 
void sendSynchronousChangeMessage ()
 Sends a synchronous change message to all the registered listeners. More...
 
- Public Member Functions inherited from ControlledObject
 ControlledObject (MainController *m)
 Creates a new ControlledObject. More...
 
const MainControllergetMainController () const noexcept
 Provides read-only access to the main controller. More...
 
MainControllergetMainController () noexcept
 Provides write access to the main controller. More...
 
- Public Member Functions inherited from RoutableProcessor
void editRouting (Component *childComponent)
 Opens a routing editor in the quasi modal popup. More...
 
int getLeftDestinationChannel () const
 Quick way to get the left target channel. More...
 
int getLeftSourceChannel () const
 Quick way to get the left channel for processing. More...
 
int getRightDestinationChannel () const
 Quick way to get the right target channel. More...
 
int getRightSourceChannel () const
 Quick way to get the right channel for processing. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Processor
virtual Path getSpecialSymbol () const
 Overwrite this method if you want to supply a custom symbol for the Processor. More...
 
void setInputValue (float newValue, NotificationType notify=sendNotification)
 Call this from the baseclass whenever you want its editor to display a input value change. More...
 
void setOutputValue (float newValue)
 Call this from the baseclass whenever you want its editor to display a value change. More...
 

Detailed Description

The base class for all sound generators in HISE.

It is a extension of the juce::Synthesiser class with the following additions:

If you're know your way around writing a sound generator based on the juce::Synthesiser class, the adaption to this class should be very straight forward.

Member Enumeration Documentation

These are the three Chains that the ModulatorSynth uses.

enum Parameters
Enumerator
Gain 

the volume as gain factor from 0...1

Balance 

the stereo balance from -100 to 100

VoiceLimit 

the amount of voices

KillFadeTime 

the fade time when voices are killed module_list

Member Function Documentation

void addProcessorsWhenEmpty ( )
virtual

Adds a SimpleEnvelope to a empty ModulatorSynth to prevent clicks.

bool areVoicesActive ( ) const
virtual

Call this from the message thread and it'll kill all voices at the next buffer.

Pass in a lambda and it will execute this asynchronously as soon as all voices are killed

: a lambda that will be executed as soon as the voices are killed : if true, the lambda will be synchronously called on the audio thread

int collectSoundsToBeStarted ( const HiseEvent m)
virtual

This method should go through all sounds that are playable and fill the soundsToBeStarted array.

float getBalance ( bool  getRightChannelGain) const
inline

Returns the calculated (equal power) pan value for either the left or the right channel.

const float* getConstantPitchValues ( ) const
inline

Returns the pointer to the calculated pitch buffers for the ModulatorSynthVoice's render callback.

ModulatorSynthVoice * getFreeVoice ( SynthesiserSound *  s,
int  midiChannel,
int  midiNoteNumber 
)

Returns a read pointer to the calculated pitch values.

Used by Synthgroups to render their pitch values on the voice value.

float getGain ( ) const
inline

Returns the gain of the ModulatorSynth from 0.0 to 1.0.

ModulatorSynthGroup* getGroup ( ) const
inline

Returns the ModulatorSynthGroup that this ModulatorSynth belongs to.

int getIndexInGroup ( ) const

Returns the index of the child synth if it resides in a group and -1 if not.

float* getPitchValuesForVoice ( ) const
inline

Returns a read pointer to the calculated pitch values.

ModulatorSynth * getPlayingSynth ( )

Returns either itself or the group that is playing its voices.

int getVoiceIndex ( const SynthesiserVoice *  v) const

Returns the voice index for the voice (the index in the internal voice array).

This is needed for the ModulatorChains to know which voice is started.

void handleHiseEvent ( const HiseEvent e)

Same functionality as Synthesiser::handleMidiEvent(), but sends the midi event to all Modulators in the chains.

void handleRetriggeredNote ( ModulatorSynthVoice voice)
virtual

specifies the behaviour when a note is started that is already ringing.

By default, it is killed, but you can overwrite it to make something else.

virtual void initRenderCallback ( )
inlinevirtual

Clears the internal buffer.

This must be called by subclasses for every renderNextBlockWithModulators.

Reimplemented in ModulatorSynthGroup.

bool isInGroup ( ) const
inline

Checks if the Synth was added to a group.

void killAllVoicesWithNoteNumber ( int  noteNumber)

Kills the note with the specified note number.

This stops the note with a small fade out (instead of noteoff which can result in very long release times if the envelope says so

int killLastVoice ( bool  allowTailOff = true)

Kills the voice that is playing for the longest time.

void noteOn ( const HiseEvent m)

Same functionality as Synthesiser::noteOn(), but calls calculateVoiceStartValue() if a new voice is started.

void postVoiceRendering ( int  startSample,
int  numThisTime 
)

This method is called to handle all modulatorchains after the voice rendering and handles the GUI metering.

It assumes stereo mode.

The rendered buffer is supplied as reference to be able to apply changes here after all voices are rendered (eg. gain).

void prepareToPlay ( double  sampleRate,
int  samplesPerBlock 
)
virtual

This sets up the synth and the ModulatorChains.

Call this instead of Synthesiser::setCurrentPlaybackSampleRate(). It also sets the ModulatorChain's voice amount, so be sure you add all SynthesiserVoices before you call this function.

Reimplemented from Processor.

Reimplemented in ModulatorSynthGroup, and ModulatorSynthChain.

void preVoiceRendering ( int  startSample,
int  numThisTime 
)
virtual

This method is called to handle all modulatorchains just before the voice rendering.

void renderNextBlockWithModulators ( AudioSampleBuffer &  outputAudio,
const HiseEventBuffer inputMidi 
)
virtual

Call this instead of Synthesiser::renderNextBlock to let the ModulatorChains to their work.

This only renders the TimeVariantModulators (like a master effect) and calculates the voice modulation, so make sure you actually apply the voice modulation in the subclassed ModulatorSynthVoice callback.

Reimplemented in ModulatorSynthChain.

void renderVoice ( int  startSample,
int  numThisTime 
)

This method is called to actually render all voices.

It operates on the internal buffer of the ModulatorSynth.

void setBalance ( float  newBalance)
inline

sets the balance from -1.0 (left) to 1.0 (right) and applies a equal power pan rule.

void setClockSpeed ( ClockSpeed  newClockSpeed)
inline

Sets the interval for the internal clock callback.

void setGain ( float  newGain)
inline

sets the gain of the ModulatorSynth from 0.0 to 1.0.

void setGroup ( ModulatorSynthGroup parent)
inline

Sets the parent group.

This can only be called once, since synths are not supposed to change their parents.

bool soundCanBePlayed ( ModulatorSynthSound *  sound,
int  midiChannel,
int  midiNoteNumber,
float  velocity 
)
virtual

Checks if the message fits the sound, but can be overriden to implement other group start logic.

©2017 HISE. This documentation is autogenerated from the HISE source code using Doxygen.