Jamba C++ API  4.1.0
RTState Class Reference

Manages the state used by the processor: you add all the parameters that the state manages using the add method. More...

#include <RTState.h>

Inherits IMessageHandler.

Public Member Functions

RTRawVstParam add (RawVstParam iParamDef)
 This method is called for each parameter managed by RTState. More...
 
template<typename T >
RTVstParam< T > add (VstParam< T > iParamDef)
 This method is called for each parameter managed by RTState. More...
 
template<typename T >
RTJmbInParam< T > addJmbIn (JmbParam< T > iParamDef)
 This method should be called to add an rt inbound jmb parameter. More...
 
template<typename T >
RTJmbOutParam< T > addJmbOut (JmbParam< T > iParamDef)
 This method should be called to add an rt outbound jmb parameter. More...
 
virtual void afterProcessing ()
 This method should be called at the end of process(ProcessData &data) method. More...
 
virtual bool applyParameterChanges (IParameterChanges &inputParameterChanges)
 This method should be called in every frame when there are parameter changes to update this state accordingly. More...
 
virtual bool beforeProcessing ()
 This method should be call at the beginning of the process(ProcessData &data) method before doing anything else. More...
 
std::vector< ParamID > const & getAllRegistrationOrder () const
 
virtual int32 getParamUpdateSampleOffset (ProcessData &iData, ParamID iParamID) const
 This uses the same algorithm as when the param value is updated (implemented in applyParameterChanges) for consistency. More...
 
tresult handleMessage (Message const &iMessage) override
 Called by the UI thread (from RTProcessor) to handle messages. More...
 
virtual tresult init ()
 Call this method after adding all the parameters. More...
 
bool isMessagingEnabled () const
 
virtual tresult readNewState (IBStreamer &iStreamer)
 This method should be called from Processor::setState to update this state to the state stored in the stream. More...
 
 RTState (Parameters const &iParameters)
 
virtual tresult sendPendingMessages (IMessageProducer *iMessageProducer)
 Called (from a GUI timer) to send the messages to the GUI (JmbParam for the moment) More...
 
virtual tresult writeLatestState (IBStreamer &oStreamer)
 This method should be called from Processor::getState to store the latest state to the stream. More...
 
- Public Member Functions inherited from IMessageHandler
virtual ~IMessageHandler ()=default
 

Protected Member Functions

tresult addInboundMessagingParameter (std::unique_ptr< IRTJmbInParameter > iParameter)
 
tresult addOutboundMessagingParameter (std::unique_ptr< IRTJmbOutParameter > iParameter)
 
tresult addRawParameter (std::unique_ptr< RTRawVstParameter > iParameter)
 
virtual void afterReadNewState (NormalizedState const *iState)
 Gives a chance to subclasses to tweak and/or display the state after being read. More...
 
virtual void beforeWriteNewState (NormalizedState const *iState)
 Gives a chance to subclasses to tweak and/or display the state before being written. More...
 
virtual void computeLatestState (NormalizedState *oLatestState) const
 Called from the RT thread from afterProcessing to compute the latest state. More...
 
virtual bool onNewState (NormalizedState const *iLatestState)
 Called from the RT thread from beforeProcessing to set the new state. More...
 
virtual bool resetPreviousValues ()
 Called from the RT thread from afterProcessing to reset previous values (copy current value to previous). More...
 

Protected Attributes

std::vector< ParamID > fAllRegistrationOrder {}
 
std::map< ParamID, std::unique_ptr< IRTJmbInParameter > > fInboundMessagingParameters {}
 
MessageHandler fMessageHandler {}
 
std::map< ParamID, std::unique_ptr< IRTJmbOutParameter > > fOutboundMessagingParameters {}
 
Parameters const & fPluginParameters
 
std::map< ParamID, std::unique_ptr< RTRawVstParameter > > fVstParameters {}
 

Private Member Functions

void computeLatestState ()
 

Private Attributes

Concurrent::LockFree::AtomicValue< NormalizedStatefLatestState
 
Concurrent::LockFree::SingleElementQueue< NormalizedStatefStateUpdate
 

Friends

class Debug::ParamDisplay
 

Detailed Description

Manages the state used by the processor: you add all the parameters that the state manages using the add method.

Combined with the RTProcessor class, everything will be handled for you (reading/writing the state, updating previous value, etc...).

Constructor & Destructor Documentation

◆ RTState()

RTState ( Parameters const &  iParameters)
explicit

Member Function Documentation

◆ add() [1/2]

RTRawVstParam add ( RawVstParam  iParamDef)

This method is called for each parameter managed by RTState.

The order in which this method is called is important and reflects the order that will be used when reading/writing state to the stream

◆ add() [2/2]

RTVstParam< T > add ( VstParam< T >  iParamDef)

This method is called for each parameter managed by RTState.

The order in which this method is called is important and reflects the order that will be used when reading/writing state to the stream

◆ addInboundMessagingParameter()

tresult addInboundMessagingParameter ( std::unique_ptr< IRTJmbInParameter iParameter)
protected

◆ addJmbIn()

RTJmbInParam< T > addJmbIn ( JmbParam< T >  iParamDef)

This method should be called to add an rt inbound jmb parameter.

◆ addJmbOut()

RTJmbOutParam< T > addJmbOut ( JmbParam< T >  iParamDef)

This method should be called to add an rt outbound jmb parameter.

◆ addOutboundMessagingParameter()

tresult addOutboundMessagingParameter ( std::unique_ptr< IRTJmbOutParameter iParameter)
protected

◆ addRawParameter()

tresult addRawParameter ( std::unique_ptr< RTRawVstParameter iParameter)
protected

◆ afterProcessing()

void afterProcessing ( )
virtual

This method should be called at the end of process(ProcessData &data) method.

It will update the previous state to the current one and save the latest changes (if necessary) so that it is accessible via writeLatestState.

◆ afterReadNewState()

virtual void afterReadNewState ( NormalizedState const *  iState)
inlineprotectedvirtual

Gives a chance to subclasses to tweak and/or display the state after being read.

◆ applyParameterChanges()

bool applyParameterChanges ( IParameterChanges &  inputParameterChanges)
virtual

This method should be called in every frame when there are parameter changes to update this state accordingly.

◆ beforeProcessing()

bool beforeProcessing ( )
virtual

This method should be call at the beginning of the process(ProcessData &data) method before doing anything else.

The goal of this method is to update the current state with a state set by the UI (typical use case is to initialize the plugin when being loaded)

Returns
true if the state of the plugin changed

◆ beforeWriteNewState()

virtual void beforeWriteNewState ( NormalizedState const *  iState)
inlineprotectedvirtual

Gives a chance to subclasses to tweak and/or display the state before being written.

◆ computeLatestState() [1/2]

void computeLatestState ( NormalizedState oLatestState) const
protectedvirtual

Called from the RT thread from afterProcessing to compute the latest state.

Can be overridden

◆ computeLatestState() [2/2]

void computeLatestState ( )
private

◆ getAllRegistrationOrder()

std::vector<ParamID> const& getAllRegistrationOrder ( ) const
inline

◆ getParamUpdateSampleOffset()

int32 getParamUpdateSampleOffset ( ProcessData &  iData,
ParamID  iParamID 
) const
virtual

This uses the same algorithm as when the param value is updated (implemented in applyParameterChanges) for consistency.

If the param changes more than once in a frame, only the last value is taken into account.

Returns
the offset at which the param changed (-1 if it did not change)

◆ handleMessage()

tresult handleMessage ( Message const &  iMessage)
overridevirtual

Called by the UI thread (from RTProcessor) to handle messages.

Implements IMessageHandler.

◆ init()

tresult init ( )
virtual

Call this method after adding all the parameters.

If using the RT processor, it will happen automatically.

◆ isMessagingEnabled()

bool isMessagingEnabled ( ) const
inline
Returns
true if messaging is enabled (which at this moment is whether any JmbParam was added)

◆ onNewState()

bool onNewState ( NormalizedState const *  iLatestState)
protectedvirtual

Called from the RT thread from beforeProcessing to set the new state.

Can be overridden

Returns
true if the state has changed, false otherwise

◆ readNewState()

tresult readNewState ( IBStreamer &  iStreamer)
virtual

This method should be called from Processor::setState to update this state to the state stored in the stream.

Note that this method is called from the UI thread so the update is queued until the next frame.

◆ resetPreviousValues()

bool resetPreviousValues ( )
protectedvirtual

Called from the RT thread from afterProcessing to reset previous values (copy current value to previous).

Can be overridden.

Returns
true if the state has changed, false otherwise

◆ sendPendingMessages()

tresult sendPendingMessages ( IMessageProducer iMessageProducer)
virtual

Called (from a GUI timer) to send the messages to the GUI (JmbParam for the moment)

◆ writeLatestState()

tresult writeLatestState ( IBStreamer &  oStreamer)
virtual

This method should be called from Processor::getState to store the latest state to the stream.

Note that this method is called from the UI thread and gets the "latest" state as of the end of the last frame.

Friends And Related Function Documentation

◆ Debug::ParamDisplay

friend class Debug::ParamDisplay
friend

Member Data Documentation

◆ fAllRegistrationOrder

std::vector<ParamID> fAllRegistrationOrder {}
protected

◆ fInboundMessagingParameters

std::map<ParamID, std::unique_ptr<IRTJmbInParameter> > fInboundMessagingParameters {}
protected

◆ fLatestState

◆ fMessageHandler

MessageHandler fMessageHandler {}
protected

◆ fOutboundMessagingParameters

std::map<ParamID, std::unique_ptr<IRTJmbOutParameter> > fOutboundMessagingParameters {}
protected

◆ fPluginParameters

Parameters const& fPluginParameters
protected

◆ fStateUpdate

◆ fVstParameters

std::map<ParamID, std::unique_ptr<RTRawVstParameter> > fVstParameters {}
protected

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