I’m building a plugin that allows me to convert a single incoming MIDI note into multiple outgoing MIDI notes with specific velocities. I’m using this to quickly set up lighting for songs using a MIDI->DMX box I have.
I have the basic structure working. Basically, I have a map from midi note to output notes. There’s a single level of indirection though. Each note maps to a set of Light/Colors. So a single incoming note can output multiple notes per light. I’ll paste my map structs below.
struct Light {
//Defines notes used for each light
//Master dimmer note
int dimmer;
//Red note
int r;
//Green note
int g;
//Blue note
int b;
Light(int dimmer, int r, int g, int b) : dimmer(dimmer), r(r), g(g), b(b) {};
};
struct LightColor {
float dimmer;
float r;
float g;
float b;
LightColor(float dimmer, float r, float g, float b) : dimmer(dimmer),r(r), g(g), b(b) {};
};
struct HotkeyOutput {
std::string lightID;
LightColor color;
HotkeyOutput(std::string lightID, LightColor color) : lightID(lightID), color(color) { };
};
struct RawHotkeyOutput {
int note;
float velocity;
RawHotkeyOutput(int note, float velocity) : note(note), velocity(velocity) {};
};
class HotkeyMap {
public:
std::unordered_map<int, std::vector<HotkeyOutput>> entries;
std::unordered_map<std::string, Light> lights;
HotkeyMap();
std::vector<RawHotkeyOutput> getOutputs(int note);
};
This set up works well so far. I can hardcode in some lights and hotkeys, and when I build and test the plugin it works great. One note becomes either 4 or 8 depending on how many lights I have defined for that specific hotkey.
What I need help with is serializing this data somehow. I plan on making a gui for creating these hotkeys and light definitions inside the plugin. The top level struct I need to serialize/deserialize is HotkeyMap. It contains all the hotkey and light definitions.
Is there a built in way to save this struct to disk, or do I need to do this myself?
Edit: I’m beginning to work on the gui now too. I’m looking at the PropertiesDemo to see how to populate listboxes, and I’m seeing a lot of uses of juce::Array. Will I need to change my HotkeyMap to use juce collections instead of std::unordered_map and std::vector in order to make the GUI possible?
Thanks in advance!