/[svn]/linuxsampler/trunk/src/engines/common/InstrumentScriptVMFunctions.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/InstrumentScriptVMFunctions.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3561 by schoenebeck, Fri Aug 23 11:44:00 2019 UTC revision 3564 by schoenebeck, Sat Aug 24 09:18:57 2019 UTC
# Line 383  namespace LinuxSampler { Line 383  namespace LinuxSampler {
383              return type == VM_NO_UNIT;              return type == VM_NO_UNIT;
384      }      }
385    
386      bool InstrumentScriptVMFunction_change_vol::acceptsArgUnitPrefix(vmint iArg) const {      bool InstrumentScriptVMFunction_change_vol::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
387          return iArg == 1;          return iArg == 1 && type == VM_BEL;
388      }      }
389    
390      bool InstrumentScriptVMFunction_change_vol::acceptsArgFinal(vmint iArg) const {      bool InstrumentScriptVMFunction_change_vol::acceptsArgFinal(vmint iArg) const {
# Line 392  namespace LinuxSampler { Line 392  namespace LinuxSampler {
392      }      }
393    
394      VMFnResult* InstrumentScriptVMFunction_change_vol::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_vol::exec(VMFnArgs* args) {
         vmint volume   = args->arg(1)->asInt()->evalInt(VM_MILLI,VM_DECI); // volume change in milli dB  
         bool isFinal   = args->arg(1)->asInt()->isFinal();  
395          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asInt()->unitType();
396            vmint volume   = (unit) ? args->arg(1)->asInt()->evalInt(VM_MILLI,VM_DECI)
397                                    : args->arg(1)->asInt()->evalInt(); // volume change in milli dB
398            bool isFinal   = args->arg(1)->asInt()->isFinal();
399          bool relative = (args->argsCount() >= 3) ? (args->arg(2)->asInt()->evalInt() & 1) : false;          bool relative = (args->argsCount() >= 3) ? (args->arg(2)->asInt()->evalInt() & 1) : false;
400          const float fVolumeLin = RTMath::DecibelToLinRatio(float(volume) / 1000.f);          const float fVolumeLin = RTMath::DecibelToLinRatio(float(volume) / 1000.f);
401    
# Line 490  namespace LinuxSampler { Line 491  namespace LinuxSampler {
491              return type == INT_EXPR;              return type == INT_EXPR;
492      }      }
493    
494      bool InstrumentScriptVMFunction_change_tune::acceptsArgUnitPrefix(vmint iArg) const {      bool InstrumentScriptVMFunction_change_tune::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
495          return iArg == 1;          return iArg == 1;
496      }      }
497    
# Line 499  namespace LinuxSampler { Line 500  namespace LinuxSampler {
500      }      }
501    
502      VMFnResult* InstrumentScriptVMFunction_change_tune::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_tune::exec(VMFnArgs* args) {
503          vmint tune     = args->arg(1)->asInt()->evalInt(VM_MILLI,VM_CENTI); // tuning change in milli cents          MetricPrefix_t prefix = args->arg(1)->asInt()->unitPrefix(0);
504            vmint tune     = (prefix) ? args->arg(1)->asInt()->evalInt(VM_MILLI,VM_CENTI)
505                                      : args->arg(1)->asInt()->evalInt(); // tuning change in milli cents
506          bool isFinal   = args->arg(1)->asInt()->isFinal();          bool isFinal   = args->arg(1)->asInt()->isFinal();
507          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asInt()->unitType();
508          bool relative = (args->argsCount() >= 3) ? (args->arg(2)->asInt()->evalInt() & 1) : false;          bool relative = (args->argsCount() >= 3) ? (args->arg(2)->asInt()->evalInt() & 1) : false;
# Line 716  namespace LinuxSampler { Line 719  namespace LinuxSampler {
719              return type == VM_NO_UNIT;              return type == VM_NO_UNIT;
720      }      }
721    
722      bool InstrumentScriptVMFunction_change_cutoff::acceptsArgUnitPrefix(vmint iArg) const {      bool InstrumentScriptVMFunction_change_cutoff::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
723          return iArg == 1;          return iArg == 1 && type == VM_HERTZ;
724      }      }
725    
726      bool InstrumentScriptVMFunction_change_cutoff::acceptsArgFinal(vmint iArg) const {      bool InstrumentScriptVMFunction_change_cutoff::acceptsArgFinal(vmint iArg) const {
# Line 725  namespace LinuxSampler { Line 728  namespace LinuxSampler {
728      }      }
729    
730      VMFnResult* InstrumentScriptVMFunction_change_cutoff::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_cutoff::exec(VMFnArgs* args) {
         vmint cutoff   = args->arg(1)->asInt()->evalInt(VM_NO_PREFIX);  
         bool isFinal   = args->arg(1)->asInt()->isFinal();  
731          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asInt()->unitType();
732            vmint cutoff   = (unit) ? args->arg(1)->asInt()->evalInt(VM_NO_PREFIX)
733                                    : args->arg(1)->asInt()->evalInt();
734            bool isFinal   = args->arg(1)->asInt()->isFinal();
735          if (!unit && cutoff > VM_FILTER_PAR_MAX_VALUE) {          if (!unit && cutoff > VM_FILTER_PAR_MAX_VALUE) {
736              wrnMsg("change_cutoff(): argument 2 may not be larger than " strfy(VM_FILTER_PAR_MAX_VALUE));              wrnMsg("change_cutoff(): argument 2 may not be larger than " strfy(VM_FILTER_PAR_MAX_VALUE));
737              cutoff = VM_FILTER_PAR_MAX_VALUE;              cutoff = VM_FILTER_PAR_MAX_VALUE;
# Line 929  namespace LinuxSampler { Line 933  namespace LinuxSampler {
933              return type == VM_NO_UNIT;              return type == VM_NO_UNIT;
934      }      }
935    
936      bool InstrumentScriptVMFunction_change_attack::acceptsArgUnitPrefix(vmint iArg) const {      bool InstrumentScriptVMFunction_change_attack::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
937          return iArg == 1;          return iArg == 1 && type == VM_SECOND;
938      }      }
939    
940      bool InstrumentScriptVMFunction_change_attack::acceptsArgFinal(vmint iArg) const {      bool InstrumentScriptVMFunction_change_attack::acceptsArgFinal(vmint iArg) const {
# Line 938  namespace LinuxSampler { Line 942  namespace LinuxSampler {
942      }      }
943    
944      VMFnResult* InstrumentScriptVMFunction_change_attack::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_attack::exec(VMFnArgs* args) {
         vmint attack   = args->arg(1)->asInt()->evalInt(VM_MICRO);  
         bool isFinal   = args->arg(1)->asInt()->isFinal();  
945          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asInt()->unitType();
946            vmint attack   = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)
947                                    : args->arg(1)->asInt()->evalInt();
948            bool isFinal   = args->arg(1)->asInt()->isFinal();
949          // note: intentionally not checking against a max. value here!          // note: intentionally not checking against a max. value here!
950          // (to allow i.e. passing 2000000 for doubling the attack time)          // (to allow i.e. passing 2000000 for doubling the attack time)
951          if (attack < 0) {          if (attack < 0) {
# Line 1041  namespace LinuxSampler { Line 1046  namespace LinuxSampler {
1046              return type == VM_NO_UNIT;              return type == VM_NO_UNIT;
1047      }      }
1048    
1049      bool InstrumentScriptVMFunction_change_decay::acceptsArgUnitPrefix(vmint iArg) const {      bool InstrumentScriptVMFunction_change_decay::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
1050          return iArg == 1;          return iArg == 1 && type == VM_SECOND;
1051      }      }
1052    
1053      bool InstrumentScriptVMFunction_change_decay::acceptsArgFinal(vmint iArg) const {      bool InstrumentScriptVMFunction_change_decay::acceptsArgFinal(vmint iArg) const {
# Line 1050  namespace LinuxSampler { Line 1055  namespace LinuxSampler {
1055      }      }
1056    
1057      VMFnResult* InstrumentScriptVMFunction_change_decay::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_decay::exec(VMFnArgs* args) {
         vmint decay    = args->arg(1)->asInt()->evalInt(VM_MICRO);  
         bool isFinal   = args->arg(1)->asInt()->isFinal();  
1058          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asInt()->unitType();
1059            vmint decay    = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)
1060                                    : args->arg(1)->asInt()->evalInt();
1061            bool isFinal   = args->arg(1)->asInt()->isFinal();
1062          // note: intentionally not checking against a max. value here!          // note: intentionally not checking against a max. value here!
1063          // (to allow i.e. passing 2000000 for doubling the decay time)          // (to allow i.e. passing 2000000 for doubling the decay time)
1064          if (decay < 0) {          if (decay < 0) {
# Line 1153  namespace LinuxSampler { Line 1159  namespace LinuxSampler {
1159              return type == VM_NO_UNIT;              return type == VM_NO_UNIT;
1160      }      }
1161    
1162      bool InstrumentScriptVMFunction_change_release::acceptsArgUnitPrefix(vmint iArg) const {      bool InstrumentScriptVMFunction_change_release::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
1163          return iArg == 1;          return iArg == 1 && type == VM_SECOND;
1164      }      }
1165    
1166      bool InstrumentScriptVMFunction_change_release::acceptsArgFinal(vmint iArg) const {      bool InstrumentScriptVMFunction_change_release::acceptsArgFinal(vmint iArg) const {
# Line 1162  namespace LinuxSampler { Line 1168  namespace LinuxSampler {
1168      }      }
1169    
1170      VMFnResult* InstrumentScriptVMFunction_change_release::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_release::exec(VMFnArgs* args) {
         vmint release  = args->arg(1)->asInt()->evalInt(VM_MICRO);  
         bool isFinal   = args->arg(1)->asInt()->isFinal();  
1171          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asInt()->unitType();
1172            vmint release  = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)
1173                                    : args->arg(1)->asInt()->evalInt();
1174            bool isFinal   = args->arg(1)->asInt()->isFinal();
1175          // note: intentionally not checking against a max. value here!          // note: intentionally not checking against a max. value here!
1176          // (to allow i.e. passing 2000000 for doubling the release time)          // (to allow i.e. passing 2000000 for doubling the release time)
1177          if (release < 0) {          if (release < 0) {
# Line 1260  namespace LinuxSampler { Line 1267  namespace LinuxSampler {
1267              return type == VM_NO_UNIT;              return type == VM_NO_UNIT;
1268      }      }
1269    
1270      bool VMChangeSynthParamFunction::acceptsArgUnitPrefix(vmint iArg) const {      bool VMChangeSynthParamFunction::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
1271          return m_unit && iArg == 1;          return m_acceptUnitPrefix && iArg == 1 && type == m_unit;
1272      }      }
1273    
1274      bool VMChangeSynthParamFunction::acceptsArgFinal(vmint iArg) const {      bool VMChangeSynthParamFunction::acceptsArgFinal(vmint iArg) const {
# Line 1302  namespace LinuxSampler { Line 1309  namespace LinuxSampler {
1309          const StdUnit_t unit = args->arg(1)->asInt()->unitType();          const StdUnit_t unit = args->arg(1)->asInt()->unitType();
1310          const bool isFinal   = args->arg(1)->asInt()->isFinal();          const bool isFinal   = args->arg(1)->asInt()->isFinal();
1311          vmint value =          vmint value =
1312              (unit & m_unit) ?              (m_acceptUnitPrefix && ((m_unit && unit) || (!m_unit && args->arg(1)->asInt()->unitPrefix(0))))
1313                  args->arg(1)->asInt()->evalInt(T_unitPrefix0, T_unitPrefixN ...) :                  ? args->arg(1)->asInt()->evalInt(T_unitPrefix0, T_unitPrefixN ...)
1314                  args->arg(1)->asInt()->evalInt(VM_NO_PREFIX);                  : args->arg(1)->asInt()->evalInt();
1315    
1316          if (unit && !isFinal && m_unit != VM_BEL && m_unit) {          if (unit && !isFinal && m_unit != VM_BEL && m_unit) {
1317              wrnMsg(String(functionName) + "(): you must pass argument 2 as 'final' value when using a unit");              wrnMsg(String(functionName) + "(): you must pass argument 2 as 'final' value when using a unit");
# Line 1732  namespace LinuxSampler { Line 1739  namespace LinuxSampler {
1739              return type == VM_NO_UNIT;              return type == VM_NO_UNIT;
1740      }      }
1741    
1742      bool InstrumentScriptVMFunction_fade_in::acceptsArgUnitPrefix(vmint iArg) const {      bool InstrumentScriptVMFunction_fade_in::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
1743          return iArg == 1;          return iArg == 1 && type == VM_SECOND;
1744      }      }
1745    
1746      VMFnResult* InstrumentScriptVMFunction_fade_in::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_fade_in::exec(VMFnArgs* args) {
1747          vmint duration = args->arg(1)->asInt()->evalInt(VM_MICRO);          StdUnit_t unit = args->arg(1)->asInt()->unitType();
1748            vmint duration = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)
1749                                    : args->arg(1)->asInt()->evalInt();
1750          if (duration < 0) {          if (duration < 0) {
1751              wrnMsg("fade_in(): argument 2 may not be negative");              wrnMsg("fade_in(): argument 2 may not be negative");
1752              duration = 0;              duration = 0;
# Line 1863  namespace LinuxSampler { Line 1872  namespace LinuxSampler {
1872              return type == VM_NO_UNIT;              return type == VM_NO_UNIT;
1873      }      }
1874    
1875      bool InstrumentScriptVMFunction_fade_out::acceptsArgUnitPrefix(vmint iArg) const {      bool InstrumentScriptVMFunction_fade_out::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
1876          return iArg == 1;          return iArg == 1 && type == VM_SECOND;
1877      }      }
1878    
1879      VMFnResult* InstrumentScriptVMFunction_fade_out::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_fade_out::exec(VMFnArgs* args) {
1880          vmint duration = args->arg(1)->asInt()->evalInt(VM_MICRO);          StdUnit_t unit = args->arg(1)->asInt()->unitType();
1881            vmint duration = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)
1882                                    : args->arg(1)->asInt()->evalInt();
1883          if (duration < 0) {          if (duration < 0) {
1884              wrnMsg("fade_out(): argument 2 may not be negative");              wrnMsg("fade_out(): argument 2 may not be negative");
1885              duration = 0;              duration = 0;
# Line 2220  namespace LinuxSampler { Line 2231  namespace LinuxSampler {
2231              return type == VM_NO_UNIT;              return type == VM_NO_UNIT;
2232      }      }
2233    
2234      bool InstrumentScriptVMFunction_change_play_pos::acceptsArgUnitPrefix(vmint iArg) const {      bool InstrumentScriptVMFunction_change_play_pos::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
2235          return iArg == 1;          return iArg == 1 && VM_SECOND;
2236      }      }
2237    
2238      VMFnResult* InstrumentScriptVMFunction_change_play_pos::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_play_pos::exec(VMFnArgs* args) {
2239          const ScriptID id = args->arg(0)->asInt()->evalInt(VM_MICRO);          const ScriptID id = args->arg(0)->asInt()->evalInt();
2240          if (!id) {          if (!id) {
2241              wrnMsg("change_play_pos(): note ID for argument 1 may not be zero");              wrnMsg("change_play_pos(): note ID for argument 1 may not be zero");
2242              return successResult();              return successResult();
# Line 2235  namespace LinuxSampler { Line 2246  namespace LinuxSampler {
2246              return successResult();              return successResult();
2247          }          }
2248    
2249          const vmint pos = args->arg(1)->asInt()->evalInt();          StdUnit_t unit = args->arg(1)->asInt()->unitType();
2250            const vmint pos = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)
2251                                     : args->arg(1)->asInt()->evalInt();
2252          if (pos < 0) {          if (pos < 0) {
2253              wrnMsg("change_play_pos(): playback position of argument 2 may not be negative");              wrnMsg("change_play_pos(): playback position of argument 2 may not be negative");
2254              return successResult();              return successResult();

Legend:
Removed from v.3561  
changed lines
  Added in v.3564

  ViewVC Help
Powered by ViewVC