Mema
Memory Matrix — multi-channel audio matrix monitor and router
Loading...
Searching...
No Matches
Mema::MemaProcessor Class Reference

Core audio processor — owns the AudioDeviceManager, routing matrix, plugin host, and IPC server. More...

#include <MemaProcessor.h>

+ Inheritance diagram for Mema::MemaProcessor:
+ Collaboration diagram for Mema::MemaProcessor:

Public Member Functions

 MemaProcessor (XmlElement *stateXml)
 Constructs the processor, optionally restoring state from XML.
 
 ~MemaProcessor ()
 
void addInputListener (ProcessorDataAnalyzer::Listener *listener)
 Registers a listener to receive input-channel level/spectrum data from the input analyzer.
 
void removeInputListener (ProcessorDataAnalyzer::Listener *listener)
 Unregisters a previously added input analyzer listener.
 
void addOutputListener (ProcessorDataAnalyzer::Listener *listener)
 Registers a listener to receive output-channel level/spectrum data from the output analyzer.
 
void removeOutputListener (ProcessorDataAnalyzer::Listener *listener)
 Unregisters a previously added output analyzer listener.
 
void addInputCommander (MemaInputCommander *commander)
 Adds an input commander and immediately pushes the current mute states to it.
 
void initializeInputCommander (MemaInputCommander *commander)
 Pushes the current input mute states to a commander that was already registered.
 
void removeInputCommander (MemaInputCommander *commander)
 Removes a previously registered input commander.
 
void addOutputCommander (MemaOutputCommander *commander)
 Adds an output commander and immediately pushes the current mute states to it.
 
void initializeOutputCommander (MemaOutputCommander *commander)
 Pushes the current output mute states to an already-registered commander.
 
void removeOutputCommander (MemaOutputCommander *comander)
 Removes a previously registered output commander.
 
void addCrosspointCommander (MemaCrosspointCommander *commander)
 Adds a crosspoint commander and immediately pushes the full crosspoint state to it.
 
void initializeCrosspointCommander (MemaCrosspointCommander *commander)
 Pushes the current crosspoint enable/gain matrix to an already-registered commander.
 
void removeCrosspointCommander (MemaCrosspointCommander *comander)
 Removes a previously registered crosspoint commander.
 
void addPluginCommander (MemaPluginCommander *commander)
 Adds a plugin commander and immediately pushes the current parameter infos and values.
 
void initializePluginCommander (MemaPluginCommander *commander)
 Pushes the current plugin parameter descriptors and values to an already-registered commander.
 
void removePluginCommander (MemaPluginCommander *commander)
 Removes a previously registered plugin commander.
 
void updateCommanders ()
 Forces all registered commanders to re-synchronise with the current processor state.
 
bool getInputMuteState (std::uint16_t channelNumber)
 Returns the mute state of a specific input channel.
 
void setInputMuteState (std::uint16_t channelNumber, bool muted, MemaChannelCommander *sender=nullptr, int userId=-1)
 Sets the mute state of an input channel and notifies all commanders except the sender.
 
bool getMatrixCrosspointEnabledValue (std::uint16_t inputNumber, std::uint16_t outputNumber)
 Returns whether a specific crosspoint node is enabled (routing active).
 
void setMatrixCrosspointEnabledValue (std::uint16_t inputNumber, std::uint16_t outputNumber, bool enabled, MemaChannelCommander *sender=nullptr, int userId=-1)
 Enables or disables a crosspoint routing node.
 
float getMatrixCrosspointFactorValue (std::uint16_t inputNumber, std::uint16_t outputNumber)
 Returns the linear gain factor of a crosspoint node.
 
void setMatrixCrosspointFactorValue (std::uint16_t inputNumber, std::uint16_t outputNumber, float factor, MemaChannelCommander *sender=nullptr, int userId=-1)
 Sets the linear gain factor of a crosspoint node.
 
float getPluginParameterValue (std::uint16_t pluginParameterIndex) const
 Returns the current normalised value of a hosted plugin parameter.
 
void setPluginParameterValue (std::uint16_t pluginParameterIndex, std::string id, float normalizedValue, MemaPluginCommander *sender=nullptr, int userId=-1)
 Sets a hosted plugin parameter to a normalised value.
 
bool getOutputMuteState (std::uint16_t channelNumber)
 Returns the mute state of a specific output channel.
 
void setOutputMuteState (std::uint16_t channelNumber, bool muted, MemaChannelCommander *sender=nullptr, int userId=-1)
 Sets the mute state of an output channel and notifies all commanders except the sender.
 
void setChannelCounts (std::uint16_t inputChannelCount, std::uint16_t outputChannelCount)
 Resizes all internal routing structures for a new input/output channel count.
 
bool setPlugin (const juce::PluginDescription &pluginDescription)
 Loads and instantiates a plugin from the given description.
 
juce::PluginDescription getPluginDescription ()
 Returns the JUCE description of the currently loaded plugin.
 
void setPluginEnabledState (bool enabled)
 Enables or disables plugin processing without unloading the plugin instance.
 
bool isPluginEnabled ()
 Returns true when a plugin is loaded and its processing is enabled.
 
void setPluginPrePostState (bool post)
 Selects whether the plugin processes audio before or after the crosspoint matrix.
 
bool isPluginPost ()
 Returns true when the plugin is inserted post-matrix.
 
void clearPlugin ()
 Unloads the hosted plugin, closes its editor window, and resets all plugin commander state.
 
void openPluginEditor ()
 Opens (or raises) the plugin's editor UI in a floating ResizeableWindowWithTitleBarAndCloseCallback window.
 
void closePluginEditor (bool deleteEditorWindow=true)
 Closes the plugin editor window.
 
std::vector< PluginParameterInfo > & getPluginParameterInfos ()
 Returns a mutable reference to the loaded plugin's parameter descriptor list.
 
void setPluginParameterRemoteControlInfos (int pluginParameterIndex, bool remoteControllable, ParameterControlType type, int steps)
 Marks a plugin parameter as remotely controllable (or not) and sets its control widget type.
 
bool isPluginParameterRemoteControllable (int parameterIndex)
 Returns true if the given parameter is flagged as remotely controllable.
 
juce::AudioProcessorParameter * getPluginParameter (int parameterIndex) const
 Returns a pointer to the underlying JUCE AudioProcessorParameter at the given index.
 
AudioDeviceManager * getDeviceManager ()
 Returns a raw pointer to the JUCE AudioDeviceManager. Used by the audio-setup UI component.
 
std::map< int, std::pair< double, bool > > getNetworkHealth ()
 Returns per-client network health metrics.
 
JUCEAppBasics::SessionServiceTopology getDiscoveredServicesTopology ()
 Returns the most recent multicast service topology snapshot from ServiceTopologyManager.
 
const String getName () const override
 Returns the processor name ("Mema").
 
void prepareToPlay (double sampleRate, int maximumExpectedSamplesPerBlock) override
 Called by the JUCE audio engine before playback starts.
 
void releaseResources () override
 Called when playback stops; releases audio processing resources.
 
void processBlock (AudioBuffer< float > &buffer, MidiBuffer &midiMessages) override
 Standard JUCE AudioProcessor entry point — not used for live audio.
 
double getTailLengthSeconds () const override
 
bool acceptsMidi () const override
 
bool producesMidi () const override
 
AudioProcessorEditor * createEditor () override
 
bool hasEditor () const override
 
int getNumPrograms () override
 
int getCurrentProgram () override
 
void setCurrentProgram (int index) override
 
const String getProgramName (int index) override
 
void changeProgramName (int index, const String &newName) override
 
void getStateInformation (juce::MemoryBlock &destData) override
 
void setStateInformation (const void *data, int sizeInBytes) override
 
void audioDeviceIOCallbackWithContext (const float *const *inputChannelData, int numInputChannels, float *const *outputChannelData, int numOutputChannels, int numSamples, const AudioIODeviceCallbackContext &context) override
 Hot audio callback — implements the complete Mema signal chain.
 
void audioDeviceAboutToStart (AudioIODevice *device) override
 Called when the audio device is about to start streaming.
 
void audioDeviceStopped () override
 Called when the audio device stops; notifies analyzers to clear their state.
 
void changeListenerCallback (ChangeBroadcaster *source) override
 Receives notifications from the AudioDeviceManager when the device configuration changes.
 
void handleMessage (const Message &message) override
 Dispatches JUCE messages posted to the message thread.
 
void parameterValueChanged (int parameterIndex, float newValue) override
 Called by the hosted plugin when a parameter value changes.
 
void parameterGestureChanged (int parameterIndex, bool gestureIsStarting) override
 Called by the hosted plugin when a gesture (e.g. mouse drag) starts or ends.
 
std::unique_ptr< XmlElement > createStateXml () override
 Serialises the current processor state (mutes, crosspoints, plugin settings) to XML.
 
bool setStateXml (XmlElement *stateXml) override
 Restores the processor state from a previously serialised <PROCESSORCONFIG> XmlElement.
 
void environmentChanged ()
 Called when the OS look-and-feel or palette changes; broadcasts EnvironmentParametersMessage to all connected clients.
 
void triggerIOUpdate ()
 Forces a full re-broadcast of device parameters and routing state to all connected clients.
 
void setTrafficTypesForConnectionId (const std::vector< SerializableMessage::SerializableMessageType > &trafficTypes, int connectionId)
 Updates the set of message types a specific TCP client has subscribed to receive.
 
bool isTimedConfigurationDumpPending ()
 Returns true when a deferred XML configuration dump has been scheduled.
 
void setTimedConfigurationDumpPending ()
 Schedules a deferred XML configuration dump (called on state change to avoid excessive disk I/O).
 
void resetTimedConfigurationDumpPending ()
 Clears the deferred dump flag after the dump has been performed.
 
void initializeCtrlValuesToUnity ()
 Resets all crosspoint gains to 1.0 (unity) and enables all crosspoints. Used when creating a default configuration.
 

Public Attributes

std::function< void(const juce::PluginDescription &)> onPluginSet
 Invoked on the message thread after a new plugin has been successfully loaded.
 
std::function< void(int pluginParameterIndex, float newValue)> onPluginParameterChanged
 Fired (on the message thread) when a hosted plugin parameter value changes; receives the zero-based index and new normalised value.
 
std::function< void()> onPluginParameterInfosChanged
 Fired when the set of exposed plugin parameters changes (plugin load/unload or controllability settings change).
 

Static Public Attributes

static constexpr int s_maxChannelCount = 64
 Maximum number of input or output channels supported by the routing matrix.
 
static constexpr int s_maxNumSamples = 1024
 Maximum audio block size in samples.
 
static constexpr int s_minInputsCount = 1
 Minimum number of input channels (always at least 1).
 
static constexpr int s_minOutputsCount = 1
 Minimum number of output channels (always at least 1).
 

Protected Member Functions

void initializeCtrlValues (int inputCount, int outputCount)
 
void initializeCtrlValuesToUnity (int inputCount, int outputCount)
 

Detailed Description

Core audio processor — owns the AudioDeviceManager, routing matrix, plugin host, and IPC server.

MemaProcessor is the heart of the Mema tool. It owns and coordinates all subsystems:

Audio signal flow

AudioDeviceManager ──► audioDeviceIOCallbackWithContext()
├─► [if plugin pre-matrix] AudioPluginInstance::processBlock()
├─► Input mutes (m_inputMuteStates)
├─► Crosspoint matrix (m_matrixCrosspointStates × m_matrixCrosspointValues)
├─► Output mutes (m_outputMuteStates)
├─► [if plugin post-matrix] AudioPluginInstance::processBlock()
├─► Input ProcessorDataAnalyzerInputControlComponent (editor)
└─► Output ProcessorDataAnalyzerOutputControlComponent (editor) + TCP clients
Input-channel control strip — shows level meters and mute buttons for all input channels.
void audioDeviceIOCallbackWithContext(const float *const *inputChannelData, int numInputChannels, float *const *outputChannelData, int numOutputChannels, int numSamples, const AudioIODeviceCallbackContext &context) override
Hot audio callback — implements the complete Mema signal chain.
void processBlock(AudioBuffer< float > &buffer, MidiBuffer &midiMessages) override
Standard JUCE AudioProcessor entry point — not used for live audio.
Output-channel control strip — shows level meters and mute buttons for all output channels.
Analyses a stream of audio buffers and broadcasts level and spectrum data to registered listeners.

Commander pattern

UI components that need to read or write routing state register themselves as commanders:

Each set* method accepts an optional sender commander and userId. When a change originates from a network client (Mema.Re), the userId carries the client's connection-id so that the update is echoed to all other clients but not reflected back to the originator.

Network server

InterprocessConnectionServerImpl listens on port 55668. On connect, MemaProcessor sends:

  1. EnvironmentParametersMessage — current palette style.
  2. AnalyzerParametersMessage — current sample rate and block size.
  3. ReinitIOCountMessage — current input/output channel counts.
  4. ControlParametersMessage — full routing-matrix state snapshot.
  5. PluginParameterInfosMessage — plugin name + parameter descriptors (if a plugin is loaded).

Audio data is only streamed to clients that have subscribed via DataTrafficTypeSelectionMessage.

Threading

  • Audio I/O: audioDeviceIOCallbackWithContext() runs on the audio thread; protected by m_audioDeviceIOCallbackLock.
  • Plugin processing: additionally protected by m_pluginProcessingLock.
  • Network / message dispatch: handleMessage() runs on the JUCE message thread.
  • Plugin parameter changes: parameterValueChanged() runs on whichever thread the plugin calls it from; posted to the message thread.
See also
MemaMessages.h — all TCP message types.
ProcessorDataAnalyzer — level/spectrum analysis fed by the audio callback.
MemaNetworkClientCommanderWrapper — bridges incoming ControlParametersMessage data to the commander pattern.

Definition at line 150 of file MemaProcessor.h.

Constructor & Destructor Documentation

◆ MemaProcessor()

Mema::MemaProcessor::MemaProcessor ( XmlElement *  stateXml)

◆ ~MemaProcessor()

Mema::MemaProcessor::~MemaProcessor ( )

Member Function Documentation

◆ acceptsMidi()

bool Mema::MemaProcessor::acceptsMidi ( ) const
override

Definition at line 1531 of file MemaProcessor.cpp.

◆ addCrosspointCommander()

void Mema::MemaProcessor::addCrosspointCommander ( MemaCrosspointCommander commander)

Adds a crosspoint commander and immediately pushes the full crosspoint state to it.

Parameters
commanderThe commander to register.

Definition at line 696 of file MemaProcessor.cpp.

References initializeCrosspointCommander(), Mema::MemaCrosspointCommander::setCrosspointEnabledChangeCallback(), Mema::MemaCrosspointCommander::setCrosspointFactorChangeCallback(), setMatrixCrosspointEnabledValue(), and setMatrixCrosspointFactorValue().

Referenced by MemaProcessor().

◆ addInputCommander()

void Mema::MemaProcessor::addInputCommander ( MemaInputCommander commander)

Adds an input commander and immediately pushes the current mute states to it.

Parameters
commanderThe commander to register. Ownership stays with the caller.

Definition at line 628 of file MemaProcessor.cpp.

References initializeInputCommander(), Mema::MemaInputCommander::setInputMuteChangeCallback(), and setInputMuteState().

Referenced by MemaProcessor().

◆ addInputListener()

void Mema::MemaProcessor::addInputListener ( ProcessorDataAnalyzer::Listener listener)

Registers a listener to receive input-channel level/spectrum data from the input analyzer.

Parameters
listenerThe listener to add; must remain valid until removeInputListener() is called.

Definition at line 604 of file MemaProcessor.cpp.

◆ addOutputCommander()

void Mema::MemaProcessor::addOutputCommander ( MemaOutputCommander commander)

Adds an output commander and immediately pushes the current mute states to it.

Parameters
commanderThe commander to register.

Definition at line 662 of file MemaProcessor.cpp.

References initializeOutputCommander(), Mema::MemaOutputCommander::setOutputMuteChangeCallback(), and setOutputMuteState().

Referenced by MemaProcessor().

◆ addOutputListener()

void Mema::MemaProcessor::addOutputListener ( ProcessorDataAnalyzer::Listener listener)

Registers a listener to receive output-channel level/spectrum data from the output analyzer.

Parameters
listenerThe listener to add.

Definition at line 616 of file MemaProcessor.cpp.

◆ addPluginCommander()

void Mema::MemaProcessor::addPluginCommander ( MemaPluginCommander commander)

Adds a plugin commander and immediately pushes the current parameter infos and values.

Parameters
commanderThe commander to register.

Definition at line 755 of file MemaProcessor.cpp.

References initializePluginCommander(), setPluginParameterValue(), and Mema::MemaPluginCommander::setPluginParameterValueChangeCallback().

Referenced by MemaProcessor().

◆ audioDeviceAboutToStart()

void Mema::MemaProcessor::audioDeviceAboutToStart ( AudioIODevice *  device)
override

Called when the audio device is about to start streaming.

Broadcasts AnalyzerParametersMessage and ReinitIOCountMessage to all connected clients.

Parameters
deviceThe audio device that is starting.

Definition at line 1639 of file MemaProcessor.cpp.

References prepareToPlay(), and setChannelCounts().

◆ audioDeviceIOCallbackWithContext()

void Mema::MemaProcessor::audioDeviceIOCallbackWithContext ( const float *const *  inputChannelData,
int  numInputChannels,
float *const *  outputChannelData,
int  numOutputChannels,
int  numSamples,
const AudioIODeviceCallbackContext &  context 
)
override

Hot audio callback — implements the complete Mema signal chain.

This method runs on the dedicated audio thread at every audio device block:

  1. Copies device input channels into m_processorChannels.
  2. Optionally passes them through the hosted plugin (pre-matrix mode).
  3. Applies per-channel input mutes.
  4. Applies the crosspoint gain matrix (input × output).
  5. Applies per-channel output mutes.
  6. Optionally passes the result through the hosted plugin (post-matrix mode).
  7. Writes the result to the device output channels.
  8. Feeds both pre- and post-matrix buffers into the respective ProcessorDataAnalyzer instances.
  9. Serialises and sends AudioInputBufferMessage / AudioOutputBufferMessage to subscribed clients.
    Note
    Protected by m_audioDeviceIOCallbackLock to prevent concurrent plugin load/unload.

Definition at line 1594 of file MemaProcessor.cpp.

References processBlock(), and s_maxChannelCount.

◆ audioDeviceStopped()

void Mema::MemaProcessor::audioDeviceStopped ( )
override

Called when the audio device stops; notifies analyzers to clear their state.

Definition at line 1657 of file MemaProcessor.cpp.

References releaseResources().

◆ changeListenerCallback()

void Mema::MemaProcessor::changeListenerCallback ( ChangeBroadcaster *  source)
override

Receives notifications from the AudioDeviceManager when the device configuration changes.

Parameters
sourceThe broadcaster that posted the change.

Definition at line 1662 of file MemaProcessor.cpp.

References setTimedConfigurationDumpPending().

◆ changeProgramName()

void Mema::MemaProcessor::changeProgramName ( int  index,
const String &  newName 
)
override

Definition at line 1577 of file MemaProcessor.cpp.

◆ clearPlugin()

void Mema::MemaProcessor::clearPlugin ( )

Unloads the hosted plugin, closes its editor window, and resets all plugin commander state.

Definition at line 1065 of file MemaProcessor.cpp.

References closePluginEditor(), onPluginSet, and setPluginEnabledState().

◆ closePluginEditor()

void Mema::MemaProcessor::closePluginEditor ( bool  deleteEditorWindow = true)

Closes the plugin editor window.

Parameters
deleteEditorWindowIf true, also deletes the window object; pass false when the window is closing itself.

Definition at line 1098 of file MemaProcessor.cpp.

Referenced by clearPlugin(), openPluginEditor(), and setPlugin().

◆ createEditor()

AudioProcessorEditor * Mema::MemaProcessor::createEditor ( )
override

Definition at line 1541 of file MemaProcessor.cpp.

References initializeCtrlValuesToUnity().

◆ createStateXml()

◆ environmentChanged()

void Mema::MemaProcessor::environmentChanged ( )

Called when the OS look-and-feel or palette changes; broadcasts EnvironmentParametersMessage to all connected clients.

Definition at line 589 of file MemaProcessor.cpp.

◆ getCurrentProgram()

int Mema::MemaProcessor::getCurrentProgram ( )
override

Definition at line 1561 of file MemaProcessor.cpp.

◆ getDeviceManager()

AudioDeviceManager * Mema::MemaProcessor::getDeviceManager ( )

Returns a raw pointer to the JUCE AudioDeviceManager. Used by the audio-setup UI component.

Definition at line 1207 of file MemaProcessor.cpp.

◆ getDiscoveredServicesTopology()

JUCEAppBasics::SessionServiceTopology Mema::MemaProcessor::getDiscoveredServicesTopology ( )

Returns the most recent multicast service topology snapshot from ServiceTopologyManager.

Definition at line 1223 of file MemaProcessor.cpp.

◆ getInputMuteState()

bool Mema::MemaProcessor::getInputMuteState ( std::uint16_t  channelNumber)

Returns the mute state of a specific input channel.

Parameters
channelNumber1-based input channel index.
Returns
true if the channel is muted (audio is silenced before the crosspoint matrix).

Definition at line 812 of file MemaProcessor.cpp.

◆ getMatrixCrosspointEnabledValue()

bool Mema::MemaProcessor::getMatrixCrosspointEnabledValue ( std::uint16_t  inputNumber,
std::uint16_t  outputNumber 
)

Returns whether a specific crosspoint node is enabled (routing active).

Parameters
inputNumber1-based input channel index.
outputNumber1-based output channel index.
Returns
true if the crosspoint is enabled and audio flows from that input to that output.

Definition at line 837 of file MemaProcessor.cpp.

◆ getMatrixCrosspointFactorValue()

float Mema::MemaProcessor::getMatrixCrosspointFactorValue ( std::uint16_t  inputNumber,
std::uint16_t  outputNumber 
)

Returns the linear gain factor of a crosspoint node.

Parameters
inputNumber1-based input channel index.
outputNumber1-based output channel index.
Returns
Linear gain in [0, 1]. Note: 1.0 = unity gain, 0.0 = silence.

Definition at line 876 of file MemaProcessor.cpp.

◆ getName()

const String Mema::MemaProcessor::getName ( ) const
override

Returns the processor name ("Mema").

Definition at line 1232 of file MemaProcessor.cpp.

◆ getNetworkHealth()

std::map< int, std::pair< double, bool > > Mema::MemaProcessor::getNetworkHealth ( )

Returns per-client network health metrics.

Returns
A map of {connectionId → {bytesPerSecond, isConnected}} for all currently connected TCP clients. Used by MemaUIComponent to update the network health bar.

Definition at line 1215 of file MemaProcessor.cpp.

◆ getNumPrograms()

int Mema::MemaProcessor::getNumPrograms ( )
override

Definition at line 1556 of file MemaProcessor.cpp.

◆ getOutputMuteState()

bool Mema::MemaProcessor::getOutputMuteState ( std::uint16_t  channelNumber)

Returns the mute state of a specific output channel.

Parameters
channelNumber1-based output channel index.
Returns
true if the channel is muted (audio is silenced after the crosspoint matrix).

Definition at line 915 of file MemaProcessor.cpp.

◆ getPluginDescription()

juce::PluginDescription Mema::MemaProcessor::getPluginDescription ( )

Returns the JUCE description of the currently loaded plugin.

Definition at line 1025 of file MemaProcessor.cpp.

◆ getPluginParameter()

juce::AudioProcessorParameter * Mema::MemaProcessor::getPluginParameter ( int  parameterIndex) const

Returns a pointer to the underlying JUCE AudioProcessorParameter at the given index.

Parameters
parameterIndexZero-based index.
Returns
nullptr if no plugin is loaded or the index is out of range.

Definition at line 1192 of file MemaProcessor.cpp.

Referenced by setStateXml().

◆ getPluginParameterInfos()

std::vector< PluginParameterInfo > & Mema::MemaProcessor::getPluginParameterInfos ( )

Returns a mutable reference to the loaded plugin's parameter descriptor list.

Returns
An empty vector if no plugin is loaded.

Definition at line 1106 of file MemaProcessor.cpp.

Referenced by createStateXml(), parameterValueChanged(), and setStateXml().

◆ getPluginParameterValue()

float Mema::MemaProcessor::getPluginParameterValue ( std::uint16_t  pluginParameterIndex) const

Returns the current normalised value of a hosted plugin parameter.

Parameters
pluginParameterIndexZero-based parameter index within the plugin's parameter list.
Returns
Normalised value in [0, 1], or 0.0 if no plugin is loaded or the index is out of range.

Definition at line 1146 of file MemaProcessor.cpp.

◆ getProgramName()

const String Mema::MemaProcessor::getProgramName ( int  index)
override

Definition at line 1571 of file MemaProcessor.cpp.

◆ getStateInformation()

void Mema::MemaProcessor::getStateInformation ( juce::MemoryBlock &  destData)
override

Definition at line 1583 of file MemaProcessor.cpp.

◆ getTailLengthSeconds()

double Mema::MemaProcessor::getTailLengthSeconds ( ) const
override

Definition at line 1526 of file MemaProcessor.cpp.

◆ handleMessage()

void Mema::MemaProcessor::handleMessage ( const Message &  message)
override

Dispatches JUCE messages posted to the message thread.

Handles:

Definition at line 1350 of file MemaProcessor.cpp.

References initializeCtrlValues(), Mema::AudioBufferMessage::Input, Mema::SerializableMessage::None, onPluginParameterInfosChanged, Mema::AudioBufferMessage::Output, setInputMuteState(), setMatrixCrosspointEnabledValue(), setMatrixCrosspointFactorValue(), setOutputMuteState(), setPluginParameterValue(), and setTrafficTypesForConnectionId().

◆ hasEditor()

bool Mema::MemaProcessor::hasEditor ( ) const
override

Definition at line 1551 of file MemaProcessor.cpp.

◆ initializeCrosspointCommander()

void Mema::MemaProcessor::initializeCrosspointCommander ( MemaCrosspointCommander commander)

Pushes the current crosspoint enable/gain matrix to an already-registered commander.

Parameters
commanderThe commander to initialise.

Definition at line 711 of file MemaProcessor.cpp.

References Mema::MemaCrosspointCommander::setCrosspointEnabledValue(), and Mema::MemaCrosspointCommander::setCrosspointFactorValue().

Referenced by addCrosspointCommander(), and updateCommanders().

◆ initializeCtrlValues()

void Mema::MemaProcessor::initializeCtrlValues ( int  inputCount,
int  outputCount 
)
protected

◆ initializeCtrlValuesToUnity() [1/2]

void Mema::MemaProcessor::initializeCtrlValuesToUnity ( )

Resets all crosspoint gains to 1.0 (unity) and enables all crosspoints. Used when creating a default configuration.

Definition at line 1747 of file MemaProcessor.cpp.

References initializeCtrlValuesToUnity().

Referenced by createEditor(), and initializeCtrlValuesToUnity().

◆ initializeCtrlValuesToUnity() [2/2]

void Mema::MemaProcessor::initializeCtrlValuesToUnity ( int  inputCount,
int  outputCount 
)
protected

◆ initializeInputCommander()

void Mema::MemaProcessor::initializeInputCommander ( MemaInputCommander commander)

Pushes the current input mute states to a commander that was already registered.

Called after a commander has been constructed and wired up but needs its initial state (e.g. after a configuration reload).

Parameters
commanderThe already-registered commander to initialise.

Definition at line 642 of file MemaProcessor.cpp.

References Mema::MemaInputCommander::setInputMute().

Referenced by addInputCommander(), and updateCommanders().

◆ initializeOutputCommander()

void Mema::MemaProcessor::initializeOutputCommander ( MemaOutputCommander commander)

Pushes the current output mute states to an already-registered commander.

Parameters
commanderThe commander to initialise.

Definition at line 676 of file MemaProcessor.cpp.

References Mema::MemaOutputCommander::setOutputMute().

Referenced by addOutputCommander(), and updateCommanders().

◆ initializePluginCommander()

void Mema::MemaProcessor::initializePluginCommander ( MemaPluginCommander commander)

Pushes the current plugin parameter descriptors and values to an already-registered commander.

Parameters
commanderThe commander to initialise.

Definition at line 769 of file MemaProcessor.cpp.

Referenced by addPluginCommander(), and updateCommanders().

◆ isPluginEnabled()

bool Mema::MemaProcessor::isPluginEnabled ( )

Returns true when a plugin is loaded and its processing is enabled.

Definition at line 1044 of file MemaProcessor.cpp.

◆ isPluginParameterRemoteControllable()

bool Mema::MemaProcessor::isPluginParameterRemoteControllable ( int  parameterIndex)

Returns true if the given parameter is flagged as remotely controllable.

Parameters
parameterIndexZero-based parameter index.

Definition at line 1138 of file MemaProcessor.cpp.

Referenced by createStateXml().

◆ isPluginPost()

bool Mema::MemaProcessor::isPluginPost ( )

Returns true when the plugin is inserted post-matrix.

Definition at line 1060 of file MemaProcessor.cpp.

◆ isTimedConfigurationDumpPending()

bool Mema::MemaProcessor::isTimedConfigurationDumpPending ( )
inline

Returns true when a deferred XML configuration dump has been scheduled.

Definition at line 520 of file MemaProcessor.h.

Referenced by MemaProcessor(), and ~MemaProcessor().

◆ openPluginEditor()

void Mema::MemaProcessor::openPluginEditor ( )

Opens (or raises) the plugin's editor UI in a floating ResizeableWindowWithTitleBarAndCloseCallback window.

Definition at line 1082 of file MemaProcessor.cpp.

References closePluginEditor().

◆ parameterGestureChanged()

void Mema::MemaProcessor::parameterGestureChanged ( int  parameterIndex,
bool  gestureIsStarting 
)
override

Called by the hosted plugin when a gesture (e.g. mouse drag) starts or ends.

Parameters
parameterIndexZero-based parameter index.
gestureIsStartingtrue when the gesture begins.

Definition at line 1504 of file MemaProcessor.cpp.

◆ parameterValueChanged()

void Mema::MemaProcessor::parameterValueChanged ( int  parameterIndex,
float  newValue 
)
override

Called by the hosted plugin when a parameter value changes.

Posts a message to the JUCE message thread so that onPluginParameterChanged is always fired on the UI thread.

Parameters
parameterIndexZero-based index of the changed parameter.
newValueNew normalised value in [0, 1].

Definition at line 1489 of file MemaProcessor.cpp.

References getPluginParameterInfos().

◆ prepareToPlay()

void Mema::MemaProcessor::prepareToPlay ( double  sampleRate,
int  maximumExpectedSamplesPerBlock 
)
override

Called by the JUCE audio engine before playback starts.

Broadcasts AnalyzerParametersMessage to all connected clients with the new sample rate and block size.

Parameters
sampleRateNew sample rate in Hz.
maximumExpectedSamplesPerBlockMaximum number of samples per processBlock() call.

Definition at line 1237 of file MemaProcessor.cpp.

Referenced by audioDeviceAboutToStart().

◆ processBlock()

void Mema::MemaProcessor::processBlock ( AudioBuffer< float > &  buffer,
MidiBuffer &  midiMessages 
)
override

Standard JUCE AudioProcessor entry point — not used for live audio.

MemaProcessor drives audio through audioDeviceIOCallbackWithContext() directly, not via the AudioProcessor plugin host path. This override satisfies the interface contract but is otherwise a no-op.

Definition at line 1271 of file MemaProcessor.cpp.

References s_minInputsCount, and s_minOutputsCount.

Referenced by audioDeviceIOCallbackWithContext().

◆ producesMidi()

bool Mema::MemaProcessor::producesMidi ( ) const
override

Definition at line 1536 of file MemaProcessor.cpp.

◆ releaseResources()

void Mema::MemaProcessor::releaseResources ( )
override

Called when playback stops; releases audio processing resources.

Definition at line 1256 of file MemaProcessor.cpp.

Referenced by audioDeviceStopped().

◆ removeCrosspointCommander()

void Mema::MemaProcessor::removeCrosspointCommander ( MemaCrosspointCommander comander)

Removes a previously registered crosspoint commander.

Parameters
comanderThe commander to remove.

Definition at line 745 of file MemaProcessor.cpp.

◆ removeInputCommander()

void Mema::MemaProcessor::removeInputCommander ( MemaInputCommander commander)

Removes a previously registered input commander.

Parameters
commanderThe commander to remove.

Definition at line 652 of file MemaProcessor.cpp.

◆ removeInputListener()

void Mema::MemaProcessor::removeInputListener ( ProcessorDataAnalyzer::Listener listener)

Unregisters a previously added input analyzer listener.

Parameters
listenerThe listener to remove.

Definition at line 610 of file MemaProcessor.cpp.

◆ removeOutputCommander()

void Mema::MemaProcessor::removeOutputCommander ( MemaOutputCommander comander)

Removes a previously registered output commander.

Parameters
comanderThe commander to remove.

Definition at line 686 of file MemaProcessor.cpp.

◆ removeOutputListener()

void Mema::MemaProcessor::removeOutputListener ( ProcessorDataAnalyzer::Listener listener)

Unregisters a previously added output analyzer listener.

Parameters
listenerThe listener to remove.

Definition at line 622 of file MemaProcessor.cpp.

◆ removePluginCommander()

void Mema::MemaProcessor::removePluginCommander ( MemaPluginCommander commander)

Removes a previously registered plugin commander.

Parameters
commanderThe commander to remove.

Definition at line 779 of file MemaProcessor.cpp.

◆ resetTimedConfigurationDumpPending()

void Mema::MemaProcessor::resetTimedConfigurationDumpPending ( )
inline

Clears the deferred dump flag after the dump has been performed.

Definition at line 524 of file MemaProcessor.h.

Referenced by MemaProcessor(), and ~MemaProcessor().

◆ setChannelCounts()

void Mema::MemaProcessor::setChannelCounts ( std::uint16_t  inputChannelCount,
std::uint16_t  outputChannelCount 
)

Resizes all internal routing structures for a new input/output channel count.

Called when the audio device reports a change in its channel layout. Reinitialises m_matrixCrosspointStates, m_matrixCrosspointValues, mute maps, and the commander lists, then broadcasts a ReinitIOCountMessage to all connected clients.

Parameters
inputChannelCountNew number of active input channels.
outputChannelCountNew number of active output channels.

Definition at line 940 of file MemaProcessor.cpp.

Referenced by audioDeviceAboutToStart().

◆ setCurrentProgram()

void Mema::MemaProcessor::setCurrentProgram ( int  index)
override

Definition at line 1566 of file MemaProcessor.cpp.

◆ setInputMuteState()

void Mema::MemaProcessor::setInputMuteState ( std::uint16_t  channelNumber,
bool  muted,
MemaChannelCommander sender = nullptr,
int  userId = -1 
)

Sets the mute state of an input channel and notifies all commanders except the sender.

Parameters
channelNumber1-based input channel index.
mutedtrue to mute, false to unmute.
senderThe commander that triggered the change, or nullptr if the change is internal. The sender is skipped when broadcasting the update to other commanders.
userIdConnection-id of the originating TCP client, used for echo-suppression (-1 = local).

Definition at line 819 of file MemaProcessor.cpp.

References setTimedConfigurationDumpPending().

Referenced by addInputCommander(), handleMessage(), and initializeCtrlValuesToUnity().

◆ setMatrixCrosspointEnabledValue()

void Mema::MemaProcessor::setMatrixCrosspointEnabledValue ( std::uint16_t  inputNumber,
std::uint16_t  outputNumber,
bool  enabled,
MemaChannelCommander sender = nullptr,
int  userId = -1 
)

Enables or disables a crosspoint routing node.

Parameters
inputNumber1-based input channel index.
outputNumber1-based output channel index.
enabledtrue to route audio, false to silence the node.
senderCommander that triggered the change, or nullptr.
userIdOriginating TCP client connection-id for echo-suppression (-1 = local).

Definition at line 850 of file MemaProcessor.cpp.

References setTimedConfigurationDumpPending().

Referenced by addCrosspointCommander(), handleMessage(), and initializeCtrlValuesToUnity().

◆ setMatrixCrosspointFactorValue()

void Mema::MemaProcessor::setMatrixCrosspointFactorValue ( std::uint16_t  inputNumber,
std::uint16_t  outputNumber,
float  factor,
MemaChannelCommander sender = nullptr,
int  userId = -1 
)

Sets the linear gain factor of a crosspoint node.

Parameters
inputNumber1-based input channel index.
outputNumber1-based output channel index.
factorLinear gain in [0, 1].
senderCommander that triggered the change, or nullptr.
userIdOriginating TCP client connection-id for echo-suppression (-1 = local).

Definition at line 889 of file MemaProcessor.cpp.

References setTimedConfigurationDumpPending().

Referenced by addCrosspointCommander(), handleMessage(), and initializeCtrlValuesToUnity().

◆ setOutputMuteState()

void Mema::MemaProcessor::setOutputMuteState ( std::uint16_t  channelNumber,
bool  muted,
MemaChannelCommander sender = nullptr,
int  userId = -1 
)

Sets the mute state of an output channel and notifies all commanders except the sender.

Parameters
channelNumber1-based output channel index.
mutedtrue to mute, false to unmute.
senderCommander that triggered the change, or nullptr.
userIdOriginating TCP client connection-id for echo-suppression (-1 = local).

Definition at line 922 of file MemaProcessor.cpp.

References setTimedConfigurationDumpPending().

Referenced by addOutputCommander(), handleMessage(), and initializeCtrlValuesToUnity().

◆ setPlugin()

bool Mema::MemaProcessor::setPlugin ( const juce::PluginDescription &  pluginDescription)

Loads and instantiates a plugin from the given description.

Scans the system for the matching plugin binary, creates an AudioPluginInstance, prepares it for playback, and registers MemaProcessor as a parameter listener. Triggers onPluginSet on success and broadcasts a PluginParameterInfosMessage.

Parameters
pluginDescriptionThe JUCE plugin description (obtained from a plugin scan).
Returns
true on success, false if the plugin could not be loaded.

Definition at line 964 of file MemaProcessor.cpp.

References closePluginEditor(), Mema::PluginParameterInfo::fromAudioProcessorParameter(), and onPluginSet.

Referenced by setStateXml().

◆ setPluginEnabledState()

void Mema::MemaProcessor::setPluginEnabledState ( bool  enabled)

Enables or disables plugin processing without unloading the plugin instance.

Parameters
enabledPass true to enable, false to bypass.

Definition at line 1033 of file MemaProcessor.cpp.

Referenced by clearPlugin(), and setStateXml().

◆ setPluginParameterRemoteControlInfos()

void Mema::MemaProcessor::setPluginParameterRemoteControlInfos ( int  pluginParameterIndex,
bool  remoteControllable,
ParameterControlType  type,
int  steps 
)

Marks a plugin parameter as remotely controllable (or not) and sets its control widget type.

Parameters
pluginParameterIndexZero-based parameter index.
remoteControllabletrue to expose this parameter in Mema.Re's plugin control panel.
typeControl widget type (Continuous slider, Discrete combo box, or Toggle button).
stepsNumber of discrete steps for Discrete type parameters.

Definition at line 1111 of file MemaProcessor.cpp.

Referenced by setStateXml().

◆ setPluginParameterValue()

void Mema::MemaProcessor::setPluginParameterValue ( std::uint16_t  pluginParameterIndex,
std::string  id,
float  normalizedValue,
MemaPluginCommander sender = nullptr,
int  userId = -1 
)

Sets a hosted plugin parameter to a normalised value.

Parameters
pluginParameterIndexZero-based parameter index.
idStable string ID used for cross-session safety.
normalizedValueNormalised value in [0, 1].
senderCommander that triggered the change, or nullptr.
userIdOriginating TCP client connection-id for echo-suppression (-1 = local).

Definition at line 1161 of file MemaProcessor.cpp.

References setTimedConfigurationDumpPending().

Referenced by addPluginCommander(), and handleMessage().

◆ setPluginPrePostState()

void Mema::MemaProcessor::setPluginPrePostState ( bool  post)

Selects whether the plugin processes audio before or after the crosspoint matrix.

Parameters
posttrue = post-matrix (plugin sees the fully routed mix); false = pre-matrix (plugin processes raw inputs).

Definition at line 1049 of file MemaProcessor.cpp.

Referenced by setStateXml().

◆ setStateInformation()

void Mema::MemaProcessor::setStateInformation ( const void *  data,
int  sizeInBytes 
)
override

Definition at line 1588 of file MemaProcessor.cpp.

◆ setStateXml()

◆ setTimedConfigurationDumpPending()

void Mema::MemaProcessor::setTimedConfigurationDumpPending ( )
inline

Schedules a deferred XML configuration dump (called on state change to avoid excessive disk I/O).

Definition at line 522 of file MemaProcessor.h.

Referenced by changeListenerCallback(), setInputMuteState(), setMatrixCrosspointEnabledValue(), setMatrixCrosspointFactorValue(), setOutputMuteState(), and setPluginParameterValue().

◆ setTrafficTypesForConnectionId()

void Mema::MemaProcessor::setTrafficTypesForConnectionId ( const std::vector< SerializableMessage::SerializableMessageType > &  trafficTypes,
int  connectionId 
)

Updates the set of message types a specific TCP client has subscribed to receive.

Called by InterprocessConnectionServerImpl when a DataTrafficTypeSelectionMessage arrives from a client. Only message types listed in trafficTypes will subsequently be forwarded to that connection.

Parameters
trafficTypesThe complete subscription list replacing any previous subscription.
connectionIdThe unique ID of the TCP client connection.

Definition at line 1752 of file MemaProcessor.cpp.

Referenced by handleMessage().

◆ triggerIOUpdate()

void Mema::MemaProcessor::triggerIOUpdate ( )

Forces a full re-broadcast of device parameters and routing state to all connected clients.

Sends AnalyzerParametersMessage, ReinitIOCountMessage, ControlParametersMessage, and (if applicable) PluginParameterInfosMessage to every connected TCP client. Called after a device reconfiguration or configuration reload.

Definition at line 599 of file MemaProcessor.cpp.

◆ updateCommanders()

void Mema::MemaProcessor::updateCommanders ( )

Forces all registered commanders to re-synchronise with the current processor state.

Definition at line 789 of file MemaProcessor.cpp.

References initializeCrosspointCommander(), initializeInputCommander(), initializeOutputCommander(), and initializePluginCommander().

Member Data Documentation

◆ onPluginParameterChanged

std::function<void(int pluginParameterIndex, float newValue)> Mema::MemaProcessor::onPluginParameterChanged

Fired (on the message thread) when a hosted plugin parameter value changes; receives the zero-based index and new normalised value.

Definition at line 368 of file MemaProcessor.h.

◆ onPluginParameterInfosChanged

std::function<void()> Mema::MemaProcessor::onPluginParameterInfosChanged

Fired when the set of exposed plugin parameters changes (plugin load/unload or controllability settings change).

Definition at line 369 of file MemaProcessor.h.

Referenced by handleMessage().

◆ onPluginSet

std::function<void(const juce::PluginDescription&)> Mema::MemaProcessor::onPluginSet

Invoked on the message thread after a new plugin has been successfully loaded.

Definition at line 352 of file MemaProcessor.h.

Referenced by clearPlugin(), and setPlugin().

◆ s_maxChannelCount

constexpr int Mema::MemaProcessor::s_maxChannelCount = 64
staticconstexpr

Maximum number of input or output channels supported by the routing matrix.

Definition at line 512 of file MemaProcessor.h.

Referenced by audioDeviceIOCallbackWithContext(), Mema::Mema::Mema(), MemaProcessor(), setStateXml(), and ~MemaProcessor().

◆ s_maxNumSamples

constexpr int Mema::MemaProcessor::s_maxNumSamples = 1024
staticconstexpr

Maximum audio block size in samples.

Definition at line 513 of file MemaProcessor.h.

Referenced by MemaProcessor().

◆ s_minInputsCount

constexpr int Mema::MemaProcessor::s_minInputsCount = 1
staticconstexpr

Minimum number of input channels (always at least 1).

Definition at line 515 of file MemaProcessor.h.

Referenced by initializeCtrlValues(), initializeCtrlValuesToUnity(), Mema::Mema::Mema(), and processBlock().

◆ s_minOutputsCount

constexpr int Mema::MemaProcessor::s_minOutputsCount = 1
staticconstexpr

Minimum number of output channels (always at least 1).

Definition at line 516 of file MemaProcessor.h.

Referenced by initializeCtrlValues(), initializeCtrlValuesToUnity(), Mema::Mema::Mema(), and processBlock().


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