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

Base message carrying a serialised audio buffer and its flow-direction metadata. More...

#include <MemaMessages.h>

+ Inheritance diagram for Mema::AudioBufferMessage:
+ Collaboration diagram for Mema::AudioBufferMessage:

Public Types

enum  FlowDirection {
  Invalid ,
  Input ,
  Output
}
 Identifies whether the buffer contains pre-matrix input or post-matrix output samples. More...
 
- Public Types inherited from Mema::SerializableMessage
enum  SerializableMessageType {
  None = 0 ,
  EnvironmentParameters ,
  AnalyzerParameters ,
  ReinitIOCount ,
  AudioInputBuffer ,
  AudioOutputBuffer ,
  DataTrafficTypeSelection ,
  ControlParameters ,
  PluginParameterInfos ,
  PluginParameterValue
}
 

Public Member Functions

 AudioBufferMessage ()=default
 
 AudioBufferMessage (juce::AudioBuffer< float > &buffer)
 
 ~AudioBufferMessage ()=default
 
const juce::AudioBuffer< float > & getAudioBuffer () const
 Returns a const reference to the decoded audio buffer.
 
const FlowDirection getFlowDirection () const
 Returns the flow direction encoded in the message.
 
- Public Member Functions inherited from Mema::SerializableMessage
 SerializableMessage ()=default
 
virtual ~SerializableMessage ()=default
 
void setId (int id)
 Tags the message with a connection-id used for echo-suppression on the server.
 
int getId () const
 Returns the connection-id tag, or -1 if not set.
 
bool hasUserId () const
 Returns true when a non-default connection-id has been assigned.
 
const SerializableMessageType getType () const
 Returns the concrete message type discriminator.
 
juce::MemoryBlock getSerializedMessage () const
 Serialises the message to a MemoryBlock ready to send over the socket.
 

Protected Member Functions

juce::MemoryBlock createSerializedContent (size_t &contentSize) const
 Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).
 
- Protected Member Functions inherited from Mema::SerializableMessage
std::uint32_t ReadUint32 (const char *buffer)
 Reads a big-endian uint32 from buffer.
 
std::uint16_t ReadUint16 (const char *buffer)
 Reads a big-endian uint16 from buffer.
 

Protected Attributes

FlowDirection m_direction { FlowDirection::Invalid }
 Input or output flow direction.
 
juce::AudioBuffer< float > m_buffer
 Decoded float audio buffer.
 
- Protected Attributes inherited from Mema::SerializableMessage
SerializableMessageType m_type = SerializableMessageType::None
 Type discriminator stored in the first 4 bytes of every serialised frame.
 
int m_userId = -1
 Optional connection-id tag for echo-suppression (-1 = not set).
 

Additional Inherited Members

- Static Public Member Functions inherited from Mema::SerializableMessage
static SerializableMessageinitFromMemoryBlock (const juce::MemoryBlock &blob)
 Deserialises a raw TCP frame into the correct concrete SerializableMessage subclass.
 
static void freeMessageData (SerializableMessage *message)
 Type-correctly destroys a SerializableMessage* returned by initFromMemoryBlock().
 

Detailed Description

Base message carrying a serialised audio buffer and its flow-direction metadata.

The audio buffer is flattened channel-by-channel into the wire payload as raw IEEE-754 float samples. Clients use the received buffer to feed their local ProcessorDataAnalyzer for level metering and spectrum analysis.

Wire payload: FlowDirection (4 B) + numChannels (uint16) + numSamples (uint16)

  • numChannels × numSamples × 4 B of float sample data.
Note
Audio buffers are streamed continuously at the audio device's block rate. Clients must subscribe via DataTrafficTypeSelectionMessage to opt in to receiving AudioInputBuffer or AudioOutputBuffer messages; without a subscription Mema will not send audio data to that client.

Definition at line 407 of file MemaMessages.h.

Member Enumeration Documentation

◆ FlowDirection

Identifies whether the buffer contains pre-matrix input or post-matrix output samples.

Enumerator
Invalid 

Uninitialised direction.

Input 

Pre-matrix input samples (as seen by the input analyzers).

Output 

Post-matrix output samples (as seen by the output analyzers).

Definition at line 411 of file MemaMessages.h.

Constructor & Destructor Documentation

◆ AudioBufferMessage() [1/2]

Mema::AudioBufferMessage::AudioBufferMessage ( )
default

◆ AudioBufferMessage() [2/2]

Mema::AudioBufferMessage::AudioBufferMessage ( juce::AudioBuffer< float > &  buffer)
inline

Definition at line 420 of file MemaMessages.h.

References m_buffer.

◆ ~AudioBufferMessage()

Mema::AudioBufferMessage::~AudioBufferMessage ( )
default

Member Function Documentation

◆ createSerializedContent()

juce::MemoryBlock Mema::AudioBufferMessage::createSerializedContent ( size_t &  contentSize) const
inlineprotectedvirtual

Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).

Parameters
contentSizeSet by the implementation to the byte count of the returned block.
Returns
A MemoryBlock containing only the payload (no type prefix).

Implements Mema::SerializableMessage.

Definition at line 429 of file MemaMessages.h.

References m_buffer, and m_direction.

◆ getAudioBuffer()

const juce::AudioBuffer< float > & Mema::AudioBufferMessage::getAudioBuffer ( ) const
inline

Returns a const reference to the decoded audio buffer.

Definition at line 424 of file MemaMessages.h.

References m_buffer.

◆ getFlowDirection()

const FlowDirection Mema::AudioBufferMessage::getFlowDirection ( ) const
inline

Returns the flow direction encoded in the message.

Definition at line 426 of file MemaMessages.h.

References m_direction.

Member Data Documentation

◆ m_buffer

juce::AudioBuffer<float> Mema::AudioBufferMessage::m_buffer
protected

◆ m_direction


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