Hi, I’ve recently returned to C++ after a long holiday in Javascript. I am attempting to create a JSON representation of sound sources and their mix values to be applied to each of a number of speakers, where the speakers are in different zones.
I have a few questions about the JSON construction, and would appreciate some guidelines:
- I create the mix values
Array<var> speakerMixVarLevels;
// Create a JUCE array of var values for each mix level - can be added as a property
for (int i = 0; i < zonePtr->noSpeakers; i++) {
speakerMixVarLevels.add(speakerMixLevels[i]);
}
//DynamicObject::Ptr mixLevelsObject = new DynamicObject();
// The final return object containing the speaker mix values
DynamicObject* mixLevelsObject = new DynamicObject();
mixLevelsObject->setProperty("Zone", zonePtr->Name);
mixLevelsObject->setProperty("Channel", channel);
mixLevelsObject->setProperty("MixValues", speakerMixVarLevels);
//Make the object a var type for inclusion in the mix matrix JSON
var mixLevelsVar(mixLevelsObject);
I found that I was not able to use DynamicObject::Ptr if I wanted to make the DynamicObject to be type var. Why is this?
- I would like to pass back var objects to functions that do further JSON aggregation:
return mixLevelsVar;
and also pass var objects and var arrays (Array<var>) to functions:
var SoundSource::renderSoundSource(var soundObject) {
Does this pose a problem for reference counting? Should one rather pass strings between functions, and parse the strings? I have been getting leakage errors, hence my question.
Thanks!