Jamba  3.0.2
pongasoft::VST::RT::RTState Class Reference

#include <RTState.h>

Inherits pongasoft::VST::IMessageHandler.

Public Member Functions

RTRawVstParam add (RawVstParam iParamDef)
 
template<typename T >
RTVstParam< T > add (VstParam< T > iParamDef)
 
template<typename T >
RTJmbInParam< T > addJmbIn (JmbParam< T > iParamDef)
 
template<typename T >
RTJmbOutParam< T > addJmbOut (JmbParam< T > iParamDef)
 
virtual void afterProcessing ()
 
virtual bool applyParameterChanges (IParameterChanges &inputParameterChanges)
 
virtual bool beforeProcessing ()
 
std::vector< ParamID > const & getAllRegistrationOrder () const
 
virtual int32 getParamUpdateSampleOffset (ProcessData &iData, ParamID iParamID)
 
tresult handleMessage (Message const &iMessage) override
 
virtual tresult init ()
 
bool isMessagingEnabled () const
 
virtual tresult readNewState (IBStreamer &iStreamer)
 
 RTState (Parameters const &iParameters)
 
virtual tresult sendPendingMessages (IMessageProducer *iMessageProducer)
 
virtual tresult writeLatestState (IBStreamer &oStreamer)
 
- Public Member Functions inherited from pongasoft::VST::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)
 
virtual void beforeWriteNewState (NormalizedState const *iState)
 
virtual void computeLatestState (NormalizedState *oLatestState) const
 
virtual bool onNewState (NormalizedState const *iLatestState)
 
virtual bool resetPreviousValues ()
 

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()

pongasoft::VST::RT::RTState::RTState ( Parameters const &  iParameters)
explicit

Member Function Documentation

◆ add() [1/2]

RTRawVstParam pongasoft::VST::RT::RTState::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]

template<typename T >
RTVstParam< T > pongasoft::VST::RT::RTState::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 pongasoft::VST::RT::RTState::addInboundMessagingParameter ( std::unique_ptr< IRTJmbInParameter iParameter)
protected

◆ addJmbIn()

template<typename T >
RTJmbInParam< T > pongasoft::VST::RT::RTState::addJmbIn ( JmbParam< T >  iParamDef)

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

◆ addJmbOut()

template<typename T >
RTJmbOutParam< T > pongasoft::VST::RT::RTState::addJmbOut ( JmbParam< T >  iParamDef)

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

◆ addOutboundMessagingParameter()

tresult pongasoft::VST::RT::RTState::addOutboundMessagingParameter ( std::unique_ptr< IRTJmbOutParameter iParameter)
protected

◆ addRawParameter()

tresult pongasoft::VST::RT::RTState::addRawParameter ( std::unique_ptr< RTRawVstParameter iParameter)
protected

◆ afterProcessing()

void pongasoft::VST::RT::RTState::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 pongasoft::VST::RT::RTState::afterReadNewState ( NormalizedState const *  iState)
inlineprotectedvirtual

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

◆ applyParameterChanges()

bool pongasoft::VST::RT::RTState::applyParameterChanges ( IParameterChanges &  inputParameterChanges)
virtual

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

◆ beforeProcessing()

bool pongasoft::VST::RT::RTState::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 pongasoft::VST::RT::RTState::beforeWriteNewState ( NormalizedState const *  iState)
inlineprotectedvirtual

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

◆ computeLatestState() [1/2]

void pongasoft::VST::RT::RTState::computeLatestState ( NormalizedState oLatestState) const
protectedvirtual

Called from the RT thread from afterProcessing to compute the latest state. Can be overridden

◆ computeLatestState() [2/2]

void pongasoft::VST::RT::RTState::computeLatestState ( )
private

◆ getAllRegistrationOrder()

std::vector<ParamID> const& pongasoft::VST::RT::RTState::getAllRegistrationOrder ( ) const
inline

◆ getParamUpdateSampleOffset()

int32 pongasoft::VST::RT::RTState::getParamUpdateSampleOffset ( ProcessData &  iData,
ParamID  iParamID 
)
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 pongasoft::VST::RT::RTState::handleMessage ( Message const &  iMessage)
overridevirtual

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

Implements pongasoft::VST::IMessageHandler.

◆ init()

tresult pongasoft::VST::RT::RTState::init ( )
virtual

Call this method after adding all the parameters. If using the RT processor, it will happen automatically.

◆ isMessagingEnabled()

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

◆ onNewState()

bool pongasoft::VST::RT::RTState::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 pongasoft::VST::RT::RTState::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 pongasoft::VST::RT::RTState::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 pongasoft::VST::RT::RTState::sendPendingMessages ( IMessageProducer iMessageProducer)
virtual

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

◆ writeLatestState()

tresult pongasoft::VST::RT::RTState::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> pongasoft::VST::RT::RTState::fAllRegistrationOrder {}
protected

◆ fInboundMessagingParameters

std::map<ParamID, std::unique_ptr<IRTJmbInParameter> > pongasoft::VST::RT::RTState::fInboundMessagingParameters {}
protected

◆ fLatestState

Concurrent::LockFree::AtomicValue<NormalizedState> pongasoft::VST::RT::RTState::fLatestState
private

◆ fMessageHandler

MessageHandler pongasoft::VST::RT::RTState::fMessageHandler {}
protected

◆ fOutboundMessagingParameters

std::map<ParamID, std::unique_ptr<IRTJmbOutParameter> > pongasoft::VST::RT::RTState::fOutboundMessagingParameters {}
protected

◆ fPluginParameters

Parameters const& pongasoft::VST::RT::RTState::fPluginParameters
protected

◆ fStateUpdate

Concurrent::LockFree::SingleElementQueue<NormalizedState> pongasoft::VST::RT::RTState::fStateUpdate
private

◆ fVstParameters

std::map<ParamID, std::unique_ptr<RTRawVstParameter> > pongasoft::VST::RT::RTState::fVstParameters {}
protected

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