Classes | Public Member Functions | List of all members
ModulatorChain Class Reference

A chain of Modulators that can be processed serially. More...

Inheritance diagram for ModulatorChain:
Chain EnvelopeModulator Modulator VoiceModulation TimeModulation Processor Modulation Modulation SafeChangeBroadcaster RestorableObject ControlledObject Dispatchable

Classes

class  ModulatorChainHandler
 This class handles the Modulators within the specified ModulatorChain. More...
 

Public Member Functions

void calculateBlock (int, int) override
 Does nothing (the complete renderNextBlock method is overwritten. More...
 
ProcessorgetChildProcessor (int processorIndex) override
 Wraps the handlers method. More...
 
const ProcessorgetChildProcessor (int processorIndex) const override
 Wraps the handlers method. More...
 
float getConstantVoiceValue (int voiceIndex) const
 Iterates all voice start modulators and returns the value either between 0.0 and 1.0 (GainMode) or -1.0 ... More...
 
Chain::HandlergetHandler () override
 Returns the handler that is used to add / delete Modulators in the chain. More...
 
int getNumChildProcessors () const override
 Wraps the handlers method. More...
 
void handleHiseEvent (const HiseEvent &m) override
 Sends the midi message all modulators. More...
 
bool isPlaying (int voiceIndex) const override
 Checks if any of the EnvelopeModulators wants to keep the voice from being killed. More...
 
 ModulatorChain (MainController *mc, const String &id, int numVoices, Modulation::Mode m, Processor *p)
 Creates a new modulator chain. More...
 
void newRenderMonophonicValues (int startSample, int numSamples)
 This overrides the TimeVariant::renderNextBlock method and only calculates the TimeVariant modulators. More...
 
void prepareToPlay (double sampleRate, int samplesPerBlock) override
 Sets the sample rate for all modulators in the chain and initialized the UpdateMerger. More...
 
void reset (int voiceIndex) override
 Resets all envelopes. More...
 
void setIsVoiceStartChain (bool isVoiceStartChain_)
 If you want the chain to only process voice start modulators, set this to true. More...
 
float startVoice (int voiceIndex) override
 Calls the start voice function for all voice start modulators and envelope modulators and sends a display message. More...
 
void stopVoice (int voiceIndex) override
 Calls the stopVoice function for all envelope modulators. More...
 
- Public Member Functions inherited from Chain
bool restoreChain (const ValueTree &v)
 Restores a Chain from a ValueTree. More...
 
- Public Member Functions inherited from Modulator
 Modulator (MainController *m, const String &id, int numVoices)
 Creates a new modulator with the given Identifier. More...
 
virtual void setColour (Colour c)
 Sets the colour of the modulator. 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...
 
virtual int getNumInternalChains () const
 If your processor uses internal chains, you can return the number here. 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...
 
virtual void setBypassed (bool shouldBeBypassed, NotificationType notifyChangeHandler=dontSendNotification) noexcept
 This bypasses the processor. 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 Modulation
void applyModulationValue (float calculatedModulationValue, float &destinationValue) const noexcept
 This applies the previously calculated value to the supplied destination value depending on the modulation mode (adding or multiplying). More...
 
float calcIntensityValue (float calculatedModulationValue) const noexcept
 This applies the intensity to the given value and returns the applied value. More...
 
float getDisplayIntensity () const noexcept
 Returns the actual intensity of the Modulation. More...
 
float getIntensity () const noexcept
 Returns the intensity. More...
 
Mode getMode () const noexcept
 returns the mode the Modulator is operating. More...
 
void setIntensity (float newIntensity) noexcept
 Sets the intensity of the modulation. More...
 
void setIntensityFromSlider (float sliderValue) noexcept
 Use this method to set the intensity from the ModulatorEditorHeader's intensity slider converting linear -12 ... More...
 
- Public Member Functions inherited from TimeModulation
void applyTimeModulation (float *destinationBuffer, int startIndex, int samplesToCopy)
 This applies the intensity to the calculated values. More...
 
virtual const float * getCalculatedValues (int)
 Returns a read pointer to the calculated values. More...
 

Additional Inherited Members

- 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 Types inherited from Modulation
enum  Mode { GainMode = 0, PitchMode, PanMode }
 There are two modes that Modulation can work: GainMode and PitchMode. More...
 
- Protected Member Functions inherited from Processor
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...
 
- Protected Member Functions inherited from TimeModulation
void applyGainModulation (float *calculatedModulationValues, float *destinationValues, float fixedIntensity, int numValues) const noexcept
 a vectorized version of the calcIntensityValue() and applyModulationValue() for Gain modulation with a fixed intensity value. More...
 
void applyGainModulation (float *calculatedModulationValues, float *destinationValues, float fixedIntensity, const float *intensityValues, int numValues) const noexcept
 A vectorized version of the calcIntensityValue() and applyModulationValue() for Gain modulation with varying intensities. More...
 
void applyPitchModulation (float *calculatedModulationValues, float *destinationValues, float fixedIntensity, const float *intensityValues, int numValues) const noexcept
 A vectorized version of the calcIntensityValue() and applyModulationValue() for Pitch modulation with varying intensities. More...
 
void applyPitchModulation (float *calculatedModulationValues, float *destinationValues, float fixedIntensity, int numValues) const noexcept
 a vectorized version of the calcIntensityValue() and applyModulationValue() for Pitch modulation with a fixed intensity value. More...
 
virtual bool isInitialized ()
 Checks if the prepareToPlay method has been called. More...
 
virtual void prepareToModulate (double, int samplesPerBlock)
 Creates the internal buffer with double the size of the expected buffer block size.
 
- Protected Attributes inherited from EnvelopeModulator
OwnedArray< ModulatorStatestates
 Use this array to access the state. More...
 

Detailed Description

A chain of Modulators that can be processed serially.

A ModulatorChain can hold three different types of Modulators:

In order to make a ModulatorChain work, you have to

In your code you have to call all these methods at the appropriate time / place:

You might want to use the functions shouldBeProcessed(), isPlaying(), getVoiceValues()

For an example usage of an polyphonic ModulatorChain, take a look at the WavetableSynth class. For an example usage of an monophonic ModulatorChain, the LfoModulator class is your friend.

Constructor & Destructor Documentation

ModulatorChain ( MainController mc,
const String &  id,
int  numVoices,
Modulation::Mode  m,
Processor p 
)

Creates a new modulator chain.

You have to specify the voice amount and the Modulation::Mode

Member Function Documentation

void calculateBlock ( int  ,
int   
)
inlineoverridevirtual

Does nothing (the complete renderNextBlock method is overwritten.

Implements TimeModulation.

Processor* getChildProcessor ( int  processorIndex)
inlineoverridevirtual

Wraps the handlers method.

Implements Processor.

const Processor* getChildProcessor ( int  processorIndex) const
inlineoverridevirtual

Wraps the handlers method.

Implements Processor.

float getConstantVoiceValue ( int  voiceIndex) const

Iterates all voice start modulators and returns the value either between 0.0 and 1.0 (GainMode) or -1.0 ...

1.0 (Pitch Mode).

Chain::Handler * getHandler ( )
overridevirtual

Returns the handler that is used to add / delete Modulators in the chain.

Use this if you want to change the modulator.

Implements Chain.

int getNumChildProcessors ( ) const
inlineoverridevirtual

Wraps the handlers method.

Reimplemented from Modulator.

void handleHiseEvent ( const HiseEvent m)
overridevirtual

Sends the midi message all modulators.

You can't use the voice index here, since it is not guaranteed if the message starts a note.

Implements Modulator.

bool isPlaying ( int  voiceIndex) const
overridevirtual

Checks if any of the EnvelopeModulators wants to keep the voice from being killed.

If no envelopes are active, it checks if the voice was recently started or stopped using an internal array.

Implements EnvelopeModulator.

void newRenderMonophonicValues ( int  startSample,
int  numSamples 
)

This overrides the TimeVariant::renderNextBlock method and only calculates the TimeVariant modulators.

It assumes that the other modulators are calculated before with renderVoice().

Parameters
bufferthe buffer that will be filled with the values of the timevariant modulation result.
void prepareToPlay ( double  sampleRate,
int  samplesPerBlock 
)
overridevirtual

Sets the sample rate for all modulators in the chain and initialized the UpdateMerger.

Reimplemented from EnvelopeModulator.

void reset ( int  voiceIndex)
overridevirtual

Resets all envelopes.

This can be used for envelopes that do not control the main gain value and therefore do not switch back to IDLE if the note stops playing before the envelope is finished.

Also their display is updated to clear remaining tails (that aren't cleared because of a missing update call to UpdateMerger.

Reimplemented from EnvelopeModulator.

void setIsVoiceStartChain ( bool  isVoiceStartChain_)

If you want the chain to only process voice start modulators, set this to true.

float startVoice ( int  voiceIndex)
overridevirtual

Calls the start voice function for all voice start modulators and envelope modulators and sends a display message.

Implements VoiceModulation.

void stopVoice ( int  voiceIndex)
overridevirtual

Calls the stopVoice function for all envelope modulators.

Implements VoiceModulation.

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