21#include <JuceHeader.h>
23#include <CustomLookAndFeel.h>
35class EnvironmentParametersMessage;
36class AnalyzerParametersMessage;
37class ReinitIOCountMessage;
38class AudioInputBufferMessage;
39class AudioOutputBufferMessage;
40class DataTrafficTypeSelectionMessage;
41class ControlParametersMessage;
42class PluginParameterInfosMessage;
43class PluginParameterValueMessage;
114 size_t contentSize = 0;
115 juce::MemoryBlock blob;
118 blob.append(sc.getData(), contentSize);
132 jassert(blob.getSize() >= minSize);
133 if (blob.getSize() < minSize)
140 return reinterpret_cast<SerializableMessage*
>(std::make_unique<EnvironmentParametersMessage>(blob).release());
142 return reinterpret_cast<SerializableMessage*
>(std::make_unique<AnalyzerParametersMessage>(blob).release());
144 return reinterpret_cast<SerializableMessage*
>(std::make_unique<ReinitIOCountMessage>(blob).release());
146 return reinterpret_cast<SerializableMessage*
>(std::make_unique<AudioInputBufferMessage>(blob).release());
148 return reinterpret_cast<SerializableMessage*
>(std::make_unique<AudioOutputBufferMessage>(blob).release());
150 return reinterpret_cast<SerializableMessage*
>(std::make_unique<DataTrafficTypeSelectionMessage>(blob).release());
152 return reinterpret_cast<SerializableMessage*
>(std::make_unique<ControlParametersMessage>(blob).release());
154 return reinterpret_cast<SerializableMessage*
>(std::make_unique<PluginParameterInfosMessage>(blob).release());
156 return reinterpret_cast<SerializableMessage*
>(std::make_unique<PluginParameterValueMessage>(blob).release());
170 if (
nullptr != message)
181 auto riocm = std::unique_ptr<ReinitIOCountMessage>(
reinterpret_cast<ReinitIOCountMessage*
>(message));
234 return (((
static_cast<std::uint8_t
>(buffer[0]) << 24) & 0xff000000) +
235 ((
static_cast<std::uint8_t
>(buffer[1]) << 16) & 0x00ff0000) +
236 ((
static_cast<std::uint8_t
>(buffer[2]) << 8) & 0x0000ff00) +
237 static_cast<std::uint8_t
>(buffer[3]));
242 return (((
static_cast<std::uint8_t
>(buffer[0]) << 8) & 0xff00) +
243 static_cast<std::uint8_t
>(buffer[1]));
273 blob.copyTo(&m_paletteStyle,
sizeof(
SerializableMessageType),
sizeof(JUCEAppBasics::CustomLookAndFeel::PaletteStyle));
279 JUCEAppBasics::CustomLookAndFeel::PaletteStyle
getPaletteStyle()
const {
return m_paletteStyle; };
284 juce::MemoryBlock blob;
285 blob.append(&m_paletteStyle,
sizeof(JUCEAppBasics::CustomLookAndFeel::PaletteStyle));
286 contentSize = blob.getSize();
291 JUCEAppBasics::CustomLookAndFeel::PaletteStyle m_paletteStyle = JUCEAppBasics::CustomLookAndFeel::PS_Dark;
317 blob.copyTo(&m_maximumExpectedSamplesPerBlock,
sizeof(
SerializableMessageType) +
sizeof(std::uint16_t),
sizeof(std::uint16_t));
330 juce::MemoryBlock blob;
331 blob.append(&m_sampleRate,
sizeof(std::uint16_t));
332 blob.append(&m_maximumExpectedSamplesPerBlock,
sizeof(std::uint16_t));
333 contentSize = blob.getSize();
338 std::uint16_t m_sampleRate = 0;
339 std::uint16_t m_maximumExpectedSamplesPerBlock = 0;
378 juce::MemoryBlock blob;
379 blob.append(&m_inputCount,
sizeof(std::uint16_t));
380 blob.append(&m_outputCount,
sizeof(std::uint16_t));
381 contentSize = blob.getSize();
386 std::uint16_t m_inputCount = 0;
387 std::uint16_t m_outputCount = 0;
430 auto numChannels = std::uint16_t(
m_buffer.getNumChannels());
431 auto numSamples = std::uint16_t(
m_buffer.getNumSamples());
432 juce::MemoryBlock blob;
434 blob.append(&numChannels,
sizeof(std::uint16_t));
435 blob.append(&numSamples,
sizeof(std::uint16_t));
436 for (
int channelNumber = 0; channelNumber < numChannels; channelNumber++)
437 blob.append(
m_buffer.getReadPointer(channelNumber),
sizeof(
float) * numSamples);
438 contentSize = blob.getSize();
474 auto numChannels = std::uint16_t(0);
475 blob.copyTo(&numChannels, readPos,
sizeof(std::uint16_t));
476 readPos +=
sizeof(std::uint16_t);
477 auto numSamples = std::uint16_t(0);
478 blob.copyTo(&numSamples, readPos,
sizeof(std::uint16_t));
479 readPos +=
sizeof(std::uint16_t);
480 auto data =
reinterpret_cast<const float*
>(blob.begin() + readPos);
482 m_buffer = juce::AudioBuffer<float>(numChannels, numSamples);
484 for (
int i = 0; i < numChannels; i++)
486 m_buffer.copyFrom(i, 0, data + samplePos, numSamples);
487 samplePos += numSamples;
517 auto numChannels = std::uint16_t(0);
518 blob.copyTo(&numChannels, readPos,
sizeof(std::uint16_t));
519 readPos +=
sizeof(std::uint16_t);
520 auto numSamples = std::uint16_t(0);
521 blob.copyTo(&numSamples, readPos,
sizeof(std::uint16_t));
522 readPos +=
sizeof(std::uint16_t);
523 auto data =
reinterpret_cast<const float*
>(blob.begin() + readPos);
525 m_buffer = juce::AudioBuffer<float>(numChannels, numSamples);
527 for (
int i = 0; i < numChannels; i++)
529 m_buffer.copyFrom(i, 0, data + samplePos, numSamples);
530 samplePos += numSamples;
565 std::uint16_t typesCount;
566 blob.copyTo(&typesCount, readPos,
sizeof(std::uint16_t));
567 readPos +=
sizeof(std::uint16_t);
568 m_trafficTypes.resize(typesCount);
569 for (
int i = 0; i < typesCount; i++)
579 const std::vector<SerializableMessageType>&
getTrafficTypes()
const {
return m_trafficTypes; };
584 juce::MemoryBlock blob;
585 auto typesCount = std::uint16_t(m_trafficTypes.size());
586 blob.append(&typesCount,
sizeof(std::uint16_t));
587 for (
auto& trafficType : m_trafficTypes)
589 contentSize = blob.getSize();
594 std::vector<SerializableMessageType> m_trafficTypes;
630 ControlParametersMessage(
const std::map<std::uint16_t, bool>& inputMuteStates,
const std::map<std::uint16_t, bool>& outputMuteStates,
631 const std::map<std::uint16_t, std::map<std::uint16_t, bool>>& crosspointStates,
const std::map<std::uint16_t, std::map<std::uint16_t, float>>& crosspointValues)
635 auto crosspointStateOutCount = size_t(0);
636 if (0 != crosspointStates.size())
638 crosspointStateOutCount = crosspointStates.begin()->second.size();
639 for (
auto const& cpStatKV : crosspointStates)
641 jassert(crosspointStateOutCount == cpStatKV.second.size());
646 auto crosspointValOutCount = size_t(0);
647 if (0 != crosspointValues.size())
649 crosspointValOutCount = crosspointValues.begin()->second.size();
650 for (
auto const& cpValKV : crosspointValues)
652 jassert(crosspointValOutCount == cpValKV.second.size());
658 m_inputMuteStates = inputMuteStates;
659 m_outputMuteStates = outputMuteStates;
660 m_crosspointStates = crosspointStates;
661 m_crosspointValues = crosspointValues;
671 std::uint16_t inputMuteStatesCount;
672 blob.copyTo(&inputMuteStatesCount, readPos,
sizeof(std::uint16_t));
673 readPos +=
sizeof(inputMuteStatesCount);
674 for (
int i = 0; i < inputMuteStatesCount; i++)
676 std::pair<std::uint16_t, bool> inputMuteState;
677 blob.copyTo(&inputMuteState.first, readPos,
sizeof(inputMuteState.first));
678 readPos +=
sizeof(inputMuteState.first);
679 blob.copyTo(&inputMuteState.second, readPos,
sizeof(inputMuteState.second));
680 readPos +=
sizeof(inputMuteState.second);
682 m_inputMuteStates[inputMuteState.first] = inputMuteState.second;
685 std::uint16_t outputMuteStatesCount;
686 blob.copyTo(&outputMuteStatesCount, readPos,
sizeof(std::uint16_t));
687 readPos +=
sizeof(outputMuteStatesCount);
688 for (
int i = 0; i < outputMuteStatesCount; i++)
690 std::pair<std::uint16_t, bool> outputMuteState;
691 blob.copyTo(&outputMuteState.first, readPos,
sizeof(outputMuteState.first));
692 readPos +=
sizeof(outputMuteState.first);
693 blob.copyTo(&outputMuteState.second, readPos,
sizeof(outputMuteState.second));
694 readPos +=
sizeof(outputMuteState.second);
696 m_outputMuteStates[outputMuteState.first] = outputMuteState.second;
699 std::uint16_t crosspointStatesCount;
700 blob.copyTo(&crosspointStatesCount, readPos,
sizeof(std::uint16_t));
701 readPos +=
sizeof(crosspointStatesCount);
702 for (
int i = 0; i < crosspointStatesCount; i++)
704 std::uint16_t in, out;
706 blob.copyTo(&in, readPos,
sizeof(in));
707 readPos +=
sizeof(in);
708 blob.copyTo(&out, readPos,
sizeof(out));
709 readPos +=
sizeof(out);
710 blob.copyTo(&state, readPos,
sizeof(state));
711 readPos +=
sizeof(state);
713 m_crosspointStates[in][out] = state;
716 std::uint16_t crosspointValuesCount;
717 blob.copyTo(&crosspointValuesCount, readPos,
sizeof(std::uint16_t));
718 readPos +=
sizeof(crosspointValuesCount);
719 for (
int i = 0; i < crosspointValuesCount; i++)
721 std::uint16_t in, out;
723 blob.copyTo(&in, readPos,
sizeof(in));
724 readPos +=
sizeof(in);
725 blob.copyTo(&out, readPos,
sizeof(out));
726 readPos +=
sizeof(out);
727 blob.copyTo(&value, readPos,
sizeof(value));
728 readPos +=
sizeof(value);
730 m_crosspointValues[in][out] = value;
740 const std::map<std::uint16_t, std::map<std::uint16_t, bool>>&
getCrosspointStates()
const {
return m_crosspointStates; };
742 const std::map<std::uint16_t, std::map<std::uint16_t, float>>&
getCrosspointValues()
const {
return m_crosspointValues; };
747 juce::MemoryBlock blob;
749 auto inputMuteStatesCount = std::uint16_t(m_inputMuteStates.size());
750 blob.append(&inputMuteStatesCount,
sizeof(inputMuteStatesCount));
751 for (
auto& inputMuteStateKV : m_inputMuteStates)
753 blob.append(&inputMuteStateKV.first,
sizeof(inputMuteStateKV.first));
754 blob.append(&inputMuteStateKV.second,
sizeof(inputMuteStateKV.second));
757 auto outputMuteStatesCount = std::uint16_t(m_outputMuteStates.size());
758 blob.append(&outputMuteStatesCount,
sizeof(outputMuteStatesCount));
759 for (
auto& outputMuteStateKV : m_outputMuteStates)
761 blob.append(&outputMuteStateKV.first,
sizeof(outputMuteStateKV.first));
762 blob.append(&outputMuteStateKV.second,
sizeof(outputMuteStateKV.second));
765 auto crosspointStatesCount = std::uint16_t(0);
766 if (0 < m_crosspointStates.size())
767 crosspointStatesCount = std::uint16_t(m_crosspointStates.size() * m_crosspointStates.begin()->second.size());
768 blob.append(&crosspointStatesCount,
sizeof(crosspointStatesCount));
769 auto crosspointStatesCountRef = std::uint16_t(0);
770 for (
auto& crosspointStatesFirstDKV : m_crosspointStates)
772 for (
auto& crosspointStatesSecDKV : crosspointStatesFirstDKV.second)
774 auto& in = crosspointStatesFirstDKV.first;
775 blob.append(&in,
sizeof(in));
776 auto& out = crosspointStatesSecDKV.first;
777 blob.append(&out,
sizeof(out));
778 auto& state = crosspointStatesSecDKV.second;
779 blob.append(&state,
sizeof(state));
780 crosspointStatesCountRef++;
783 jassert(crosspointStatesCount == crosspointStatesCountRef);
785 auto crosspointValuesCount = std::uint16_t(0);
786 if (0 < m_crosspointValues.size())
787 crosspointValuesCount = std::uint16_t(m_crosspointValues.size() * m_crosspointValues.begin()->second.size());
788 blob.append(&crosspointValuesCount,
sizeof(crosspointValuesCount));
789 auto crosspointValuesCountRef = std::uint16_t(0);
790 for (
auto& crosspointValuesFirstDKV : m_crosspointValues)
792 for (
auto& crosspointValuesSecDKV : crosspointValuesFirstDKV.second)
794 auto& in = crosspointValuesFirstDKV.first;
795 blob.append(&in,
sizeof(in));
796 auto& out = crosspointValuesSecDKV.first;
797 blob.append(&out,
sizeof(out));
798 auto& value = crosspointValuesSecDKV.second;
799 blob.append(&value,
sizeof(value));
800 crosspointValuesCountRef++;
803 jassert(crosspointValuesCount == crosspointValuesCountRef);
805 contentSize = blob.getSize();
810 std::map<std::uint16_t, bool> m_inputMuteStates;
811 std::map<std::uint16_t, bool> m_outputMuteStates;
812 std::map<std::uint16_t, std::map<std::uint16_t, bool>> m_crosspointStates;
813 std::map<std::uint16_t, std::map<std::uint16_t, float>> m_crosspointValues;
842 m_parameterInfos = parameterInfos;
843 m_pluginName = pluginName;
855 std::uint16_t pluginNameLength;
856 blob.copyTo(&pluginNameLength, readPos,
sizeof(std::uint16_t));
857 readPos +=
sizeof(std::uint16_t);
858 m_pluginName = juce::String(juce::CharPointer_UTF8(
static_cast<const char*
>(blob.begin()) + readPos), pluginNameLength);
859 readPos += pluginNameLength;
861 std::uint16_t paramCount;
862 blob.copyTo(¶mCount, readPos,
sizeof(std::uint16_t));
863 readPos +=
sizeof(std::uint16_t);
865 m_parameterInfos.reserve(paramCount);
867 for (
int i = 0; i < paramCount; i++)
873 blob.copyTo(&index, readPos,
sizeof(std::int32_t));
875 readPos +=
sizeof(std::int32_t);
878 std::uint16_t idLength;
879 blob.copyTo(&idLength, readPos,
sizeof(std::uint16_t));
880 readPos +=
sizeof(std::uint16_t);
881 info.
id = juce::String(juce::CharPointer_UTF8(
static_cast<const char*
>(blob.begin()) + readPos), idLength);
885 std::uint16_t nameLength;
886 blob.copyTo(&nameLength, readPos,
sizeof(std::uint16_t));
887 readPos +=
sizeof(std::uint16_t);
888 info.
name = juce::String(juce::CharPointer_UTF8(
static_cast<const char*
>(blob.begin()) + readPos), nameLength);
889 readPos += nameLength;
892 blob.copyTo(&info.
defaultValue, readPos,
sizeof(
float));
893 readPos +=
sizeof(float);
894 blob.copyTo(&info.
currentValue, readPos,
sizeof(
float));
895 readPos +=
sizeof(float);
898 std::uint16_t labelLength;
899 blob.copyTo(&labelLength, readPos,
sizeof(std::uint16_t));
900 readPos +=
sizeof(std::uint16_t);
901 info.
label = juce::String(juce::CharPointer_UTF8(
static_cast<const char*
>(blob.begin()) + readPos), labelLength);
902 readPos += labelLength;
906 readPos +=
sizeof(bool);
908 readPos +=
sizeof(bool);
911 std::int32_t categoryInt;
912 blob.copyTo(&categoryInt, readPos,
sizeof(std::int32_t));
913 info.
category =
static_cast<juce::AudioProcessorParameter::Category
>(categoryInt);
914 readPos +=
sizeof(std::int32_t);
917 blob.copyTo(&info.
minValue, readPos,
sizeof(
float));
918 readPos +=
sizeof(float);
919 blob.copyTo(&info.
maxValue, readPos,
sizeof(
float));
920 readPos +=
sizeof(float);
921 blob.copyTo(&info.
stepSize, readPos,
sizeof(
float));
922 readPos +=
sizeof(float);
923 blob.copyTo(&info.
isDiscrete, readPos,
sizeof(
bool));
924 readPos +=
sizeof(bool);
927 blob.copyTo(&info.
type, readPos,
sizeof(ParameterControlType));
928 readPos +=
sizeof(ParameterControlType);
931 std::int32_t stepCount;
932 blob.copyTo(&stepCount, readPos,
sizeof(std::int32_t));
934 readPos +=
sizeof(std::int32_t);
937 for (
int s = 0; s < stepCount; s++)
939 std::uint16_t stepNameLength;
940 blob.copyTo(&stepNameLength, readPos,
sizeof(std::uint16_t));
941 readPos +=
sizeof(std::uint16_t);
942 auto stepName = juce::String(juce::CharPointer_UTF8(
943 static_cast<const char*
>(blob.begin()) + readPos), stepNameLength);
944 readPos += stepNameLength;
945 info.
stepNames.push_back(stepName.toStdString());
948 m_parameterInfos.push_back(info);
962 juce::MemoryBlock blob;
965 auto pluginNameUtf8 = m_pluginName.toUTF8();
966 std::uint16_t pluginNameLength = std::uint16_t(strlen(pluginNameUtf8));
967 blob.append(&pluginNameLength,
sizeof(std::uint16_t));
968 blob.append(pluginNameUtf8, pluginNameLength);
970 auto paramCount = std::uint16_t(m_parameterInfos.size());
971 blob.append(¶mCount,
sizeof(std::uint16_t));
973 for (
const auto& info : m_parameterInfos)
976 std::int32_t index = info.index;
977 blob.append(&index,
sizeof(std::int32_t));
980 auto idUtf8 = info.id.toUTF8();
981 std::uint16_t idLength = std::uint16_t(strlen(idUtf8));
982 blob.append(&idLength,
sizeof(std::uint16_t));
983 blob.append(idUtf8, idLength);
986 auto nameUtf8 = info.name.toUTF8();
987 std::uint16_t nameLength = std::uint16_t(strlen(nameUtf8));
988 blob.append(&nameLength,
sizeof(std::uint16_t));
989 blob.append(nameUtf8, nameLength);
992 blob.append(&info.defaultValue,
sizeof(
float));
993 blob.append(&info.currentValue,
sizeof(
float));
996 auto labelUtf8 = info.label.toUTF8();
997 std::uint16_t labelLength = std::uint16_t(strlen(labelUtf8));
998 blob.append(&labelLength,
sizeof(std::uint16_t));
999 blob.append(labelUtf8, labelLength);
1002 blob.append(&info.isAutomatable,
sizeof(
bool));
1003 blob.append(&info.isRemoteControllable,
sizeof(
bool));
1006 std::int32_t categoryInt =
static_cast<std::int32_t
>(info.category);
1007 blob.append(&categoryInt,
sizeof(std::int32_t));
1010 blob.append(&info.minValue,
sizeof(
float));
1011 blob.append(&info.maxValue,
sizeof(
float));
1012 blob.append(&info.stepSize,
sizeof(
float));
1013 blob.append(&info.isDiscrete,
sizeof(
bool));
1016 blob.append(&info.type,
sizeof(ParameterControlType));
1019 std::int32_t stepCount = info.stepCount;
1020 blob.append(&stepCount,
sizeof(std::int32_t));
1023 for (
const auto& stepName : info.stepNames)
1025 juce::String juceStepName(stepName);
1026 auto stepNameUtf8 = juceStepName.toUTF8();
1027 std::uint16_t stepNameLength = std::uint16_t(strlen(stepNameUtf8));
1028 blob.append(&stepNameLength,
sizeof(std::uint16_t));
1029 blob.append(stepNameUtf8, stepNameLength);
1033 contentSize = blob.getSize();
1038 std::vector<PluginParameterInfo> m_parameterInfos;
1039 juce::String m_pluginName;
1064 m_parameterIndex = parameterIndex;
1065 m_parameterId = parameterId;
1066 m_currentValue = value;
1078 blob.copyTo(&m_parameterIndex, readPos,
sizeof(std::uint16_t));
1079 readPos +=
sizeof(std::uint16_t);
1082 std::uint16_t idLength;
1083 blob.copyTo(&idLength, readPos,
sizeof(std::uint16_t));
1084 readPos +=
sizeof(std::uint16_t);
1085 m_parameterId = juce::String(juce::CharPointer_UTF8(
static_cast<const char*
>(blob.begin()) + readPos), idLength);
1086 readPos += idLength;
1089 blob.copyTo(&m_currentValue, readPos,
sizeof(
float));
1090 readPos +=
sizeof(float);
1105 juce::MemoryBlock blob;
1108 blob.append(&m_parameterIndex,
sizeof(std::uint16_t));
1111 auto idUtf8 = m_parameterId.toUTF8();
1112 std::uint16_t idLength = std::uint16_t(strlen(idUtf8));
1113 blob.append(&idLength,
sizeof(std::uint16_t));
1114 blob.append(idUtf8, idLength);
1117 blob.append(&m_currentValue,
sizeof(
float));
1119 contentSize = blob.getSize();
1124 std::uint16_t m_parameterIndex = 0;
1125 juce::String m_parameterId;
1126 float m_currentValue = 0.0f;
1131#define RUN_MESSAGE_TESTS
1133#ifdef RUN_MESSAGE_TESTS
1134static void runTests()
1138 auto buffer = juce::AudioBuffer<float>();
1139 auto refSample = 11.11f;
1144 auto apm = std::make_unique<AnalyzerParametersMessage>(sr, mespb);
1145 auto apmb = apm->getSerializedMessage();
1146 auto apmcpy = AnalyzerParametersMessage(apmb);
1147 auto test5 = apmcpy.getSampleRate();
1148 auto test6 = apmcpy.getMaximumExpectedSamplesPerBlock();
1149 jassert(test5 == sr);
1150 jassert(test6 == mespb);
1153 auto rcm = std::make_unique<ReinitIOCountMessage>(inputs, outputs);
1154 auto rcmb = rcm->getSerializedMessage();
1155 auto rcmcpy = ReinitIOCountMessage(rcmb);
1156 auto test7 = rcmcpy.getInputCount();
1157 auto test8 = rcmcpy.getOutputCount();
1158 jassert(test7 == inputs);
1159 jassert(test8 == outputs);
1162 auto channelCount = 2;
1163 auto sampleCount = 6;
1164 buffer.setSize(channelCount, sampleCount,
false,
true,
false);
1165 for (
int i = 0; i < channelCount; i++)
1167 for (
int j = 0; j < sampleCount; j++)
1169 buffer.setSample(i, j, ++refSample);
1172 auto rrefSample1 = refSample;
1173 auto aibm1 = std::make_unique<AudioInputBufferMessage>(buffer);
1174 for (
int i = channelCount - 1; i >= 0; i--)
1176 for (
int j = sampleCount - 1; j >= 0; j--)
1178 auto test1 = aibm1->getAudioBuffer().getSample(i, j);
1179 jassert(
int(test1) ==
int(refSample));
1183 auto aibmb1 = aibm1->getSerializedMessage();
1184 auto aibmcpy1 = AudioInputBufferMessage(aibmb1);
1185 for (
int i = channelCount - 1; i >= 0; i--)
1187 for (
int j = sampleCount - 1; j >= 0; j--)
1189 auto test1 = aibmcpy1.getAudioBuffer().getSample(i, j);
1190 jassert(
int(test1) ==
int(rrefSample1));
1196 buffer.setSize(channelCount, sampleCount,
false,
true,
false);
1197 for (
int i = 0; i < channelCount; i++)
1199 for (
int j = 0; j < sampleCount; j++)
1201 buffer.setSample(i, j, ++refSample);
1204 auto rrefSample2 = refSample;
1205 auto aibm2 = std::make_unique<AudioOutputBufferMessage>(buffer);
1206 for (
int i = channelCount - 1; i >= 0; i--)
1208 for (
int j = sampleCount - 1; j >= 0; j--)
1210 auto test2 = aibm2->getAudioBuffer().getSample(i, j);
1211 jassert(
int(test2) ==
int(rrefSample2));
1215 auto aibmb2 = aibm2->getSerializedMessage();
1216 auto aibmcpy2 = AudioOutputBufferMessage(aibmb2);
1217 for (
int i = channelCount - 1; i >= 0; i--)
1219 for (
int j = sampleCount - 1; j >= 0; j--)
1221 auto test2 = aibmcpy2.getAudioBuffer().getSample(i, j);
1222 jassert(
int(test2) ==
int(refSample));
1228 auto paletteStyle = JUCEAppBasics::CustomLookAndFeel::PaletteStyle::PS_Light;
1229 auto epm = std::make_unique<EnvironmentParametersMessage>(paletteStyle);
1230 auto epmb = epm->getSerializedMessage();
1231 auto epmcpy = EnvironmentParametersMessage(epmb);
1232 auto test9 = epmcpy.getPaletteStyle();
1233 jassert(test9 == paletteStyle);
1237 auto dttm = std::make_unique<DataTrafficTypeSelectionMessage>(trafficTypes);
1238 auto dttmb = dttm->getSerializedMessage();
1239 auto dttmcpy = DataTrafficTypeSelectionMessage(dttmb);
1240 auto test10 = dttmcpy.getTrafficTypes();
1241 jassert(test10 == trafficTypes);
1244 auto inputMuteStates = std::map<std::uint16_t, bool>{ { std::uint16_t(1),
true}, { std::uint16_t(2),
false}, { std::uint16_t(3),
true} };
1245 auto outputMuteStates = std::map<std::uint16_t, bool>{ { std::uint16_t(4),
false}, { std::uint16_t(5),
true}, { std::uint16_t(6),
false} };
1246 auto crosspointStates = std::map<std::uint16_t, std::map<std::uint16_t, bool>>();
1247 auto crosspointValues = std::map<std::uint16_t, std::map<std::uint16_t, float>>();
1248 crosspointStates[1][1] =
false;
1249 crosspointStates[1][2] =
true;
1250 crosspointStates[2][1] =
true;
1251 crosspointStates[2][2] =
true;
1252 crosspointValues[1][1] = 0.0f;
1253 crosspointValues[1][2] = 1.0f;
1254 crosspointValues[2][1] = 0.5f;
1255 crosspointValues[2][2] = 0.7f;
1256 auto cpm = std::make_unique<ControlParametersMessage>(inputMuteStates, outputMuteStates, crosspointStates, crosspointValues);
1257 auto cpmb = cpm->getSerializedMessage();
1258 auto cpmcpy = ControlParametersMessage(cpmb);
1259 auto test11 = cpmcpy.getInputMuteStates();
1260 auto test12 = cpmcpy.getOutputMuteStates();
1261 auto test13 = cpmcpy.getCrosspointStates();
1262 auto test14 = cpmcpy.getCrosspointValues();
1263 jassert(test11 == inputMuteStates);
1264 jassert(test12 == outputMuteStates);
1265 jassert(test13 == crosspointStates);
1266 jassert(test14 == crosspointValues);
Carries audio-device parameters (sample rate, block size) from Mema to clients.
int getSampleRate() const
Returns the audio device sample rate in Hz.
int getMaximumExpectedSamplesPerBlock() const
Returns the maximum number of samples per processing block.
AnalyzerParametersMessage()=default
AnalyzerParametersMessage(int sampleRate, int maximumExpectedSamplesPerBlock)
juce::MemoryBlock createSerializedContent(size_t &contentSize) const override
Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).
AnalyzerParametersMessage(const juce::MemoryBlock &blob)
~AnalyzerParametersMessage()=default
Base message carrying a serialised audio buffer and its flow-direction metadata.
juce::MemoryBlock createSerializedContent(size_t &contentSize) const
Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).
FlowDirection
Identifies whether the buffer contains pre-matrix input or post-matrix output samples.
@ 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).
~AudioBufferMessage()=default
FlowDirection m_direction
Input or output flow direction.
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.
AudioBufferMessage()=default
juce::AudioBuffer< float > m_buffer
Decoded float audio buffer.
AudioBufferMessage(juce::AudioBuffer< float > &buffer)
Carries a post-matrix output audio buffer streamed continuously from Mema to subscribed clients.
AudioOutputBufferMessage(const juce::MemoryBlock &blob)
~AudioOutputBufferMessage()=default
AudioOutputBufferMessage()=default
AudioOutputBufferMessage(juce::AudioBuffer< float > &buffer)
Full routing-matrix state snapshot exchanged bidirectionally between Mema and Mema....
const std::map< std::uint16_t, std::map< std::uint16_t, bool > > & getCrosspointStates() const
Returns the crosspoint enable matrix (input index → output index → enabled).
const std::map< std::uint16_t, bool > & getOutputMuteStates() const
Returns the per-output mute states (channel index → muted).
ControlParametersMessage(const juce::MemoryBlock &blob)
ControlParametersMessage()=default
~ControlParametersMessage()=default
const std::map< std::uint16_t, std::map< std::uint16_t, float > > & getCrosspointValues() const
Returns the crosspoint gain matrix (input index → output index → linear gain [0, 1]).
ControlParametersMessage(const std::map< std::uint16_t, bool > &inputMuteStates, const std::map< std::uint16_t, bool > &outputMuteStates, const std::map< std::uint16_t, std::map< std::uint16_t, bool > > &crosspointStates, const std::map< std::uint16_t, std::map< std::uint16_t, float > > &crosspointValues)
const std::map< std::uint16_t, bool > & getInputMuteStates() const
Returns the per-input mute states (channel index → muted).
juce::MemoryBlock createSerializedContent(size_t &contentSize) const override
Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).
Sent by a client to opt in to receiving specific message types from Mema.
DataTrafficTypeSelectionMessage(const juce::MemoryBlock &blob)
juce::MemoryBlock createSerializedContent(size_t &contentSize) const override
Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).
DataTrafficTypeSelectionMessage(const std::vector< SerializableMessageType > &trafficTypes)
const std::vector< SerializableMessageType > & getTrafficTypes() const
Returns the list of message types this client wants to receive.
DataTrafficTypeSelectionMessage()=default
~DataTrafficTypeSelectionMessage()=default
Carries the active look-and-feel palette style from Mema to connected clients.
~EnvironmentParametersMessage()=default
EnvironmentParametersMessage(JUCEAppBasics::CustomLookAndFeel::PaletteStyle paletteStyle)
juce::MemoryBlock createSerializedContent(size_t &contentSize) const override
Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).
EnvironmentParametersMessage(const juce::MemoryBlock &blob)
EnvironmentParametersMessage()=default
JUCEAppBasics::CustomLookAndFeel::PaletteStyle getPaletteStyle() const
Returns the palette style carried by this message.
Carries the plugin name and complete parameter descriptor list from Mema to Mema.Re clients.
const std::vector< PluginParameterInfo > & getParameterInfos() const
Returns the ordered list of parameter descriptors for the loaded plugin.
PluginParameterInfosMessage()=default
PluginParameterInfosMessage(const std::string &pluginName, const std::vector< PluginParameterInfo > ¶meterInfos)
PluginParameterInfosMessage(const juce::MemoryBlock &blob)
~PluginParameterInfosMessage()=default
const juce::String & getPluginName() const
Returns the display name of the currently loaded plugin.
juce::MemoryBlock createSerializedContent(size_t &contentSize) const override
Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).
Carries a single normalised plugin parameter value from Mema.Re to Mema.
float getCurrentValue() const
Returns the normalised parameter value in [0, 1].
juce::MemoryBlock createSerializedContent(size_t &contentSize) const override
Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).
const juce::String & getParameterId() const
Returns the stable string identifier of the parameter (used for cross-session safety).
PluginParameterValueMessage(std::uint16_t parameterIndex, const juce::String ¶meterId, float value)
~PluginParameterValueMessage()=default
PluginParameterValueMessage()=default
std::uint16_t getParameterIndex() const
Returns the zero-based parameter index within the plugin's parameter list.
PluginParameterValueMessage(const juce::MemoryBlock &blob)
Instructs clients to tear down and rebuild their UI for a new channel count.
ReinitIOCountMessage(const juce::MemoryBlock &blob)
ReinitIOCountMessage(int inputs, int outputs)
std::uint16_t getInputCount() const
Returns the new number of active input channels.
~ReinitIOCountMessage()=default
std::uint16_t getOutputCount() const
Returns the new number of active output channels.
juce::MemoryBlock createSerializedContent(size_t &contentSize) const override
Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).
ReinitIOCountMessage()=default
Base class for all messages exchanged between Mema, Mema.Mo, and Mema.Re over TCP.
juce::MemoryBlock getSerializedMessage() const
Serialises the message to a MemoryBlock ready to send over the socket.
virtual juce::MemoryBlock createSerializedContent(size_t &contentSize) const =0
Subclass hook — produces the type-specific payload bytes (everything after the type discriminator).
const SerializableMessageType getType() const
Returns the concrete message type discriminator.
std::uint32_t ReadUint32(const char *buffer)
Reads a big-endian uint32 from buffer.
static void freeMessageData(SerializableMessage *message)
Type-correctly destroys a SerializableMessage* returned by initFromMemoryBlock().
void setId(int id)
Tags the message with a connection-id used for echo-suppression on the server.
int m_userId
Optional connection-id tag for echo-suppression (-1 = not set).
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.
static SerializableMessage * initFromMemoryBlock(const juce::MemoryBlock &blob)
Deserialises a raw TCP frame into the correct concrete SerializableMessage subclass.
std::uint16_t ReadUint16(const char *buffer)
Reads a big-endian uint16 from buffer.
SerializableMessage()=default
@ None
Sentinel / uninitialised type.
@ PluginParameterValue
Single parameter value update sent from Mema.Re to Mema.
@ DataTrafficTypeSelection
Sent by a client to opt in/out of specific message types (bandwidth control).
@ AnalyzerParameters
Audio device sample rate and block size; lets clients initialise their local ProcessorDataAnalyzer.
@ ReinitIOCount
New input/output channel count; clients must rebuild their UI accordingly.
@ ControlParameters
Full routing-matrix state snapshot; sent by Mema on connect and echoed by Mema.Re on change.
@ AudioInputBuffer
Raw PCM input buffer streamed from Mema to subscribed clients.
@ AudioOutputBuffer
Raw PCM output buffer streamed from Mema to subscribed clients.
@ EnvironmentParameters
Look-and-feel palette sent by Mema to clients on connect.
@ PluginParameterInfos
Plugin name and full parameter descriptor list; sent by Mema when a plugin is loaded or changed.
virtual ~SerializableMessage()=default
SerializableMessageType m_type
Type discriminator stored in the first 4 bytes of every serialised frame.
Metadata describing a single plugin parameter exposed for remote control.
std::vector< std::string > stepNames
Display names for each discrete step.
juce::String name
Human-readable parameter name.
bool isRemoteControllable
Whether this parameter is exposed for remote control.
int stepCount
Number of discrete steps (0 if continuous).
bool isAutomatable
Whether the host can automate this parameter.
int index
Zero-based parameter index within the plugin.
ParameterControlType type
Control widget type (slider, combo, toggle).
float defaultValue
Factory default value (normalised 0..1).
juce::String id
Unique string identifier of the parameter.
float stepSize
Step interval for discrete parameters (0 = continuous).
float minValue
Minimum value in the parameter's native range.
float currentValue
Current parameter value (normalised 0..1).
float maxValue
Maximum value in the parameter's native range.
bool isDiscrete
True if the parameter has a finite set of steps.
juce::AudioProcessorParameter::Category category
JUCE parameter category.
juce::String label
Unit label (e.g. "dB", "Hz").