Skip to content

Commit

Permalink
Split of profile list into custom and generic profiles in audio mixer
Browse files Browse the repository at this point in the history
  • Loading branch information
hkbinaurics committed Sep 11, 2024
1 parent 7728241 commit 3d13508
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class CjvxAuN2AudioMixer : public CjvxNVTasks, public IjvxDirectMixerControl, pu
// from base class <CjvxNVTasks> when extending the mixbuffer list!
std::map<jvxSize, oneBufferDefinition> mixBuffers;

jvxSize numberProfilePresets = 0;
jvxSize numberGenericPresetProfiles = 0;

private:

Expand Down Expand Up @@ -293,9 +293,12 @@ class CjvxAuN2AudioMixer : public CjvxNVTasks, public IjvxDirectMixerControl, pu

void recursive_vtask_processing();

virtual std::string profile_preset_name(jvxSize cnt);
virtual std::string generic_preset_profile_name(jvxSize cnt);
virtual void realize_preset_profile(jvxSize cnt);

//virtual std::string profile_preset_name(jvxSize cnt);
//virtual void realize_preset_profile(jvxSize cnt);

// =============================================================================
// =============================================================================
// Property callbacks
Expand All @@ -305,7 +308,8 @@ class CjvxAuN2AudioMixer : public CjvxNVTasks, public IjvxDirectMixerControl, pu
JVX_PROPERTIES_FORWARD_C_CALLBACK_DECLARE(update_level_get);
JVX_PROPERTIES_FORWARD_C_CALLBACK_DECLARE(update_level_set);
JVX_PROPERTIES_FORWARD_C_CALLBACK_DECLARE(clear_storage);
JVX_PROPERTIES_FORWARD_C_CALLBACK_DECLARE(address_profiles);
JVX_PROPERTIES_FORWARD_C_CALLBACK_DECLARE(address_custom_profiles);
JVX_PROPERTIES_FORWARD_C_CALLBACK_DECLARE(address_generic_profiles);

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,44 @@ SECTION PROPERTIES
};
};

SECTION profiles
SECTION custom_profiles
{
ALLOWED_STATE_MASK = {"JVX_STATE_ACTIVE", "JVX_STATE_PREPARED", "JVX_STATE_PROCESSING"};
CALLBACKS = {"address_profiles"};
SECTION profile_list
CALLBACKS = {"address_custom_profiles"};
SECTION custom_profile_list
{
GENERATE_ENTRY_CONFIG_FILE = "yes";
DESCRIPTION = "Select one among the stored profiles.";
// SELECTION_LIST_NAMES = {"PCM @ 16 bit", "PCM @ 8 bit"}; empty on start
// SELECTION_LIST_SELECTED = {"yes", "no"}; empty on start
// SELECTION_LIST_EXCLUSIVE = {"yes", "yes"}; empty on start
TYPE = "JVX_DATAFORMAT_SELECTION_LIST";
CONTENT_DECODER_TYPE = "JVX_PROPERTY_DECODER_SINGLE_SELECTION";
CALLBACK_SET_POSTHOOK = "address_profiles";
CALLBACK_SET_POSTHOOK = "address_custom_profiles";
};
SECTION profile_add
SECTION custom_profile_add
{
DESCRIPTION = "Add a new profile with the given name.";
TYPE = "JVX_DATAFORMAT_STRING";
INIT = "";
CALLBACK_SET_POSTHOOK = "address_profiles";
CALLBACK_SET_POSTHOOK = "address_custom_profiles";
};
SECTION clear_profile
SECTION custom_clear_profile
{
DESCRIPTION = "Clear the selected profile.";
TYPE = "JVX_DATAFORMAT_BOOL";
CALLBACK_SET_POSTHOOK = "address_profiles";
CALLBACK_SET_POSTHOOK = "address_custom_profiles";
};
};

SECTION generic_profiles
{
ALLOWED_STATE_MASK = {"JVX_STATE_ACTIVE", "JVX_STATE_PREPARED", "JVX_STATE_PROCESSING"};
CALLBACKS = {"address_generic_profiles"};
SECTION generic_profile_list
{
GENERATE_ENTRY_CONFIG_FILE = "no";
DESCRIPTION = "Select one among the generic profiles.";
TYPE = "JVX_DATAFORMAT_SELECTION_LIST";
CONTENT_DECODER_TYPE = "JVX_PROPERTY_DECODER_SINGLE_SELECTION";
CALLBACK_SET_POSTHOOK = "address_generic_profiles";
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,22 @@ CjvxAuN2AudioMixer::activate()
set_extend_ifx_reference,
update_level_get, update_level_set,
update_level_get, update_level_set,
clear_storage, address_profiles,
clear_storage, address_custom_profiles,
address_generic_profiles,
reinterpret_cast<jvxHandle*>(this),
nullptr);

update_profile_list_properties();

for (jvxSize cnt = 0; cnt < numberGenericPresetProfiles; cnt++)
{
std::string token = generic_preset_profile_name(cnt);
gen2AudioMixer_node::generic_profiles.generic_profile_list.value.entries.push_back(token);
}
if (numberGenericPresetProfiles)
{
jvx_bitZSet(gen2AudioMixer_node::generic_profiles.generic_profile_list.value.selection(), 0);
}
}
return(res);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ CjvxAuN2AudioMixer::get_configuration(jvxCallManagerConfiguration* callConf, Ijv
}
if (_common_set_min.theState >= JVX_STATE_ACTIVE)
{
gen2AudioMixer_node::get_configuration__profiles(callConf,
gen2AudioMixer_node::get_configuration__custom_profiles(callConf,
processor, sectionWhereToAddAllSubsections);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,14 @@ JVX_PROPERTIES_FORWARD_C_CALLBACK_EXECUTE_FULL(CjvxAuN2AudioMixer, clear_storage
return JVX_NO_ERROR;
}

JVX_PROPERTIES_FORWARD_C_CALLBACK_EXECUTE_FULL(CjvxAuN2AudioMixer, address_profiles)
JVX_PROPERTIES_FORWARD_C_CALLBACK_EXECUTE_FULL(CjvxAuN2AudioMixer, address_custom_profiles)
{
jvxBool lstRefresh = false;
std::string propsReport;
std::string activateName;
if (JVX_PROPERTY_CHECK_ID_CAT(ident.id, ident.cat, gen2AudioMixer_node::profiles.profile_add))
if (JVX_PROPERTY_CHECK_ID_CAT(ident.id, ident.cat, gen2AudioMixer_node::custom_profiles.custom_profile_add))
{
std::string addme = gen2AudioMixer_node::profiles.profile_add.value;
std::string addme = gen2AudioMixer_node::custom_profiles.custom_profile_add.value;

// Add current setup to profile list
auto elmP = profileList.find(addme);
Expand All @@ -527,93 +527,87 @@ JVX_PROPERTIES_FORWARD_C_CALLBACK_EXECUTE_FULL(CjvxAuN2AudioMixer, address_profi
lstRefresh = true;
activateName = addme;

gen2AudioMixer_node::profiles.profile_add.value.clear();
gen2AudioMixer_node::custom_profiles.custom_profile_add.value.clear();

}
else if (JVX_PROPERTY_CHECK_ID_CAT(ident.id, ident.cat, gen2AudioMixer_node::profiles.clear_profile))
else if (JVX_PROPERTY_CHECK_ID_CAT(ident.id, ident.cat, gen2AudioMixer_node::custom_profiles.custom_clear_profile))
{
if (gen2AudioMixer_node::profiles.clear_profile.value == c_true)
if (gen2AudioMixer_node::custom_profiles.custom_clear_profile.value == c_true)
{
// remove the currently selected profile
jvxSize selId = jvx_bitfieldSelection2Id(
gen2AudioMixer_node::profiles.profile_list.value.selection(),
gen2AudioMixer_node::profiles.profile_list.value.entries.size());
gen2AudioMixer_node::custom_profiles.custom_profile_list.value.selection(),
gen2AudioMixer_node::custom_profiles.custom_profile_list.value.entries.size());
if (JVX_CHECK_SIZE_SELECTED(selId))
{
std::string txt = gen2AudioMixer_node::profiles.profile_list.value.entries[selId];
std::string txt = gen2AudioMixer_node::custom_profiles.custom_profile_list.value.entries[selId];
auto elmP = profileList.find(txt);
if (elmP != profileList.end())
{
profileList.erase(txt);
}
lstRefresh = true;
}
gen2AudioMixer_node::profiles.clear_profile.value = c_false;
gen2AudioMixer_node::custom_profiles.custom_clear_profile.value = c_false;
}
}
else if (JVX_PROPERTY_CHECK_ID_CAT(ident.id, ident.cat, gen2AudioMixer_node::profiles.profile_list))
else if (JVX_PROPERTY_CHECK_ID_CAT(ident.id, ident.cat, gen2AudioMixer_node::custom_profiles.custom_profile_list))
{
jvxSize selId = jvx_bitfieldSelection2Id(
gen2AudioMixer_node::profiles.profile_list.value.selection(),
gen2AudioMixer_node::profiles.profile_list.value.entries.size());
gen2AudioMixer_node::custom_profiles.custom_profile_list.value.selection(),
gen2AudioMixer_node::custom_profiles.custom_profile_list.value.entries.size());
if (JVX_CHECK_SIZE_SELECTED(selId))
{
if (selId >= this->numberProfilePresets)
{
std::string entry = gen2AudioMixer_node::profiles.profile_list.value.entries[selId];
std::string entry = gen2AudioMixer_node::custom_profiles.custom_profile_list.value.entries[selId];

const auto& elmP = profileList.find(entry);
const auto& elmP = profileList.find(entry);

// Load profile entries
jvxSize cntChan = 0;
for (auto& set : registeredChannelListInput)
// Load profile entries
jvxSize cntChan = 0;
for (auto& set : registeredChannelListInput)
{
std::string masName = set.second.masName;
for (auto& elmC : set.second.channels)
{
std::string masName = set.second.masName;
for (auto& elmC : set.second.channels)
updateChannelFromStorage((*elmP).second.inputChannelsInStorage, elmC, masName, true);
mixer_input.fldGain[cntChan] = elmC.gain;
jvx_bitZSet(mixer_input.fldMute[cntChan], 0);
if (elmC.mute)
{
updateChannelFromStorage((*elmP).second.inputChannelsInStorage, elmC, masName, true);
mixer_input.fldGain[cntChan] = elmC.gain;
jvx_bitZSet(mixer_input.fldMute[cntChan], 0);
if (elmC.mute)
{
jvx_bitZSet(mixer_input.fldMute[cntChan], 1);
}

if (extender)
{
extender->fillLinearFields(true, cntChan, elmC.attSpecificPtr);
}
jvx_bitZSet(mixer_input.fldMute[cntChan], 1);
}

cntChan++;
if (extender)
{
extender->fillLinearFields(true, cntChan, elmC.attSpecificPtr);
}

cntChan++;
}
}

cntChan = 0;
for (auto& set : registeredChannelListOutput)
cntChan = 0;
for (auto& set : registeredChannelListOutput)
{
std::string masName = set.second.masName;
for (auto& elmC : set.second.channels)
{
std::string masName = set.second.masName;
for (auto& elmC : set.second.channels)
{
updateChannelFromStorage((*elmP).second.outputChannelsInStorage, elmC, masName, false);
updateChannelFromStorage((*elmP).second.outputChannelsInStorage, elmC, masName, false);

mixer_output.fldGain[cntChan] = elmC.gain;
jvx_bitZSet(mixer_output.fldMute[cntChan], 0);
if (elmC.mute)
{
jvx_bitZSet(mixer_output.fldMute[cntChan], 1);
}
if (extender)
{
extender->fillLinearFields(false, cntChan, elmC.attSpecificPtr);
}
cntChan++;
mixer_output.fldGain[cntChan] = elmC.gain;
jvx_bitZSet(mixer_output.fldMute[cntChan], 0);
if (elmC.mute)
{
jvx_bitZSet(mixer_output.fldMute[cntChan], 1);
}
if (extender)
{
extender->fillLinearFields(false, cntChan, elmC.attSpecificPtr);
}
cntChan++;
}
}
else
{
realize_preset_profile(selId);
}


CjvxProperties::add_property_report_collect(gen2AudioMixer_node::mixer_input.mixer_control.level_gain.descriptor.std_str());
CjvxProperties::add_property_report_collect(gen2AudioMixer_node::mixer_input.mixer_control.level_mute.descriptor.std_str());
Expand All @@ -631,13 +625,37 @@ JVX_PROPERTIES_FORWARD_C_CALLBACK_EXECUTE_FULL(CjvxAuN2AudioMixer, address_profi
{
update_profile_list_properties(activateName);
CjvxProperties::add_property_report_collect(
gen2AudioMixer_node::profiles.profile_list.descriptor.std_str(),
gen2AudioMixer_node::custom_profiles.custom_profile_list.descriptor.std_str(),
true);
}

return JVX_NO_ERROR;
}

JVX_PROPERTIES_FORWARD_C_CALLBACK_EXECUTE_FULL(CjvxAuN2AudioMixer, address_generic_profiles)
{
jvxSize idSel = jvx_bitfieldSelection2Id(
gen2AudioMixer_node::generic_profiles.generic_profile_list.value.selection(),
gen2AudioMixer_node::generic_profiles.generic_profile_list.value.entries.size());

if (idSel < numberGenericPresetProfiles)
{
realize_preset_profile(idSel);

CjvxProperties::add_property_report_collect(gen2AudioMixer_node::mixer_input.mixer_control.level_gain.descriptor.std_str());
CjvxProperties::add_property_report_collect(gen2AudioMixer_node::mixer_input.mixer_control.level_mute.descriptor.std_str());
CjvxProperties::add_property_report_collect(gen2AudioMixer_node::mixer_output.mixer_control.level_gain.descriptor.std_str());
CjvxProperties::add_property_report_collect(gen2AudioMixer_node::mixer_output.mixer_control.level_mute.descriptor.std_str());
if (extender)
{
extender->reportPropertyUpdateChannels(true);
extender->reportPropertyUpdateChannels(false);
}
}

return JVX_NO_ERROR;
}

void
CjvxAuN2AudioMixer::update_profile_list_properties(const std::string& activateThis)
{
Expand All @@ -653,26 +671,16 @@ CjvxAuN2AudioMixer::update_profile_list_properties(const std::string& activateTh
else
{
jvxSize idBefore = jvx_bitfieldSelection2Id(
gen2AudioMixer_node::profiles.profile_list.value.selection(),
gen2AudioMixer_node::profiles.profile_list.value.entries.size());
if (idBefore < gen2AudioMixer_node::profiles.profile_list.value.entries.size())
gen2AudioMixer_node::custom_profiles.custom_profile_list.value.selection(),
gen2AudioMixer_node::custom_profiles.custom_profile_list.value.entries.size());
if (idBefore < gen2AudioMixer_node::custom_profiles.custom_profile_list.value.entries.size())
{
actProf = gen2AudioMixer_node::profiles.profile_list.value.entries[idBefore];
actProf = gen2AudioMixer_node::custom_profiles.custom_profile_list.value.entries[idBefore];
}
}

gen2AudioMixer_node::profiles.profile_list.value.entries.clear();
jvx_bitFClear(gen2AudioMixer_node::profiles.profile_list.value.selection());

for (cnt = 0; cnt < numberProfilePresets; cnt++)
{
std::string token = profile_preset_name(cnt);
if (token == actProf)
{
idNew = cnt;
}
gen2AudioMixer_node::profiles.profile_list.value.entries.push_back(token);
}
gen2AudioMixer_node::custom_profiles.custom_profile_list.value.entries.clear();
jvx_bitFClear(gen2AudioMixer_node::custom_profiles.custom_profile_list.value.selection());

for (auto elm : profileList)
{
Expand All @@ -681,7 +689,7 @@ CjvxAuN2AudioMixer::update_profile_list_properties(const std::string& activateTh
idNew = cnt;
}
cnt++;
gen2AudioMixer_node::profiles.profile_list.value.entries.push_back(elm.first);
gen2AudioMixer_node::custom_profiles.custom_profile_list.value.entries.push_back(elm.first);
}

if (JVX_CHECK_SIZE_UNSELECTED(idNew))
Expand All @@ -693,12 +701,12 @@ CjvxAuN2AudioMixer::update_profile_list_properties(const std::string& activateTh
}
if (JVX_CHECK_SIZE_SELECTED(idNew))
{
jvx_bitZSet(gen2AudioMixer_node::profiles.profile_list.value.selection(), idNew);
jvx_bitZSet(gen2AudioMixer_node::custom_profiles.custom_profile_list.value.selection(), idNew);
}
}

std::string
CjvxAuN2AudioMixer::profile_preset_name(jvxSize cnt)
std::string
CjvxAuN2AudioMixer::generic_preset_profile_name(jvxSize cnt)
{
std::string token = "Profile #" + jvx_size2String(cnt);
return token;
Expand All @@ -707,5 +715,5 @@ CjvxAuN2AudioMixer::profile_preset_name(jvxSize cnt)
void
CjvxAuN2AudioMixer::realize_preset_profile(jvxSize cnt)
{

}
// Do nothing here, to be used in base class
}

0 comments on commit 3d13508

Please sign in to comment.