AnalogTapeModel

Physical modelling signal processing for analog tape recording
Log | Files | Refs | Submodules | README | LICENSE

MixGroupsSharedData.cpp (1974B)


      1 #include "MixGroupsSharedData.h"
      2 #include "MixGroupsController.h"
      3 
      4 MixGroupsSharedData::MixGroupsSharedData()
      5 {
      6     for (int i = 0; i < MixGroupsConstants::numMixGroups; ++i)
      7         pluginsInGroup.add (std::make_unique<StringArray>());
      8 }
      9 
     10 void MixGroupsSharedData::loadParameterList (Array<String>& paramList)
     11 {
     12     if (! paramMaps.empty()) // already loaded
     13         return;
     14 
     15     for (int i = 0; i < MixGroupsConstants::numMixGroups; ++i)
     16     {
     17         auto paramMap = std::make_unique<ParamMap>();
     18 
     19         for (const auto& paramID : paramList)
     20             paramMap->set (paramID, 0.0f);
     21 
     22         paramMaps.push_back (std::move (paramMap));
     23     }
     24 }
     25 
     26 void MixGroupsSharedData::pluginGroupChanged (const String& pluginID, int mixGroup)
     27 {
     28     // remove plugin from any group it's currently in
     29     for (auto& group : pluginsInGroup)
     30         group->removeString (pluginID);
     31 
     32     if (mixGroup == 0)
     33         return;
     34 
     35     // add plugin to new group
     36     pluginsInGroup[mixGroup - 1]->addIfNotAlreadyThere (pluginID);
     37 }
     38 
     39 int MixGroupsSharedData::getNumPluginsInGroup (int mixGroup) const
     40 {
     41     return pluginsInGroup[mixGroup - 1]->size();
     42 }
     43 
     44 void MixGroupsSharedData::copyPluginState (int mixGroup, AudioProcessorValueTreeState& vts)
     45 {
     46     auto paramMap = paramMaps[(size_t) mixGroup - 1].get();
     47     auto mapIter = paramMap->begin();
     48     while (mapIter.next())
     49     {
     50         const auto param = vts.getRawParameterValue (mapIter.getKey());
     51         paramMap->set (mapIter.getKey(), param->load());
     52     }
     53 }
     54 
     55 void MixGroupsSharedData::setParameter (const String& paramID, int mixGroup, float value, String uuid)
     56 {
     57     paramMaps[(size_t) mixGroup - 1]->set (paramID, value);
     58     MessageManager::callAsync ([=]
     59                                { listeners.call (&Listener::mixGroupParamChanged, paramID, mixGroup, value, uuid); });
     60 }
     61 
     62 float MixGroupsSharedData::getParameter (const String& paramID, int mixGroup) const
     63 {
     64     return paramMaps[(size_t) mixGroup - 1]->operator[] (paramID);
     65 }