gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

parametervaluelist.cpp (816B)


      1 #include "parametervaluelist.h"
      2 
      3 namespace pluginLib
      4 {
      5 	namespace
      6 	{
      7 		std::string g_empty;
      8 	}
      9 
     10 	uint32_t ValueList::textToValue(const std::string& _string) const
     11 	{
     12 		const auto it = textToValueMap.find(_string);
     13 		if (it != textToValueMap.end())
     14 			return it->second;
     15 		return 0;
     16 	}
     17 
     18 	const std::string& ValueList::valueToText(const uint32_t _value) const
     19 	{
     20 		if (_value >= texts.size())
     21 			return texts.back();
     22 		return texts[_value];
     23 	}
     24 
     25 	ParamValue ValueList::orderToValue(const uint32_t _orderIndex) const
     26 	{
     27 		if(_orderIndex >= order.size())
     28 			return InvalidValue;
     29 		return order[_orderIndex];
     30 	}
     31 
     32 	const std::string& ValueList::orderToText(const uint32_t _orderIndex) const
     33 	{
     34 		const auto value = orderToValue(_orderIndex);
     35 		if(value == InvalidValue)
     36 			return g_empty;
     37 		return valueToText(value);
     38 	}
     39 }