/[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 3581 by schoenebeck, Fri Aug 30 11:40:25 2019 UTC revision 3587 by schoenebeck, Sat Aug 31 12:08:49 2019 UTC
# Line 21  namespace LinuxSampler { Line 21  namespace LinuxSampler {
21      {      {
22      }      }
23    
24        bool InstrumentScriptVMFunction_play_note::acceptsArgType(vmint iArg, ExprType_t type) const {
25            if (iArg == 2 || iArg == 3)
26                return type == INT_EXPR || type == REAL_EXPR;
27            else
28                return type == INT_EXPR;
29        }
30    
31        bool InstrumentScriptVMFunction_play_note::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {
32            if (iArg == 2 || iArg == 3)
33                return type == VM_NO_UNIT || type == VM_SECOND;
34            else
35                return type == VM_NO_UNIT;
36        }
37    
38        bool InstrumentScriptVMFunction_play_note::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
39            if (iArg == 2 || iArg == 3)
40                return type == VM_SECOND; // only allow metric prefix(es) if 'seconds' is used as unit type
41            else
42                return false;
43        }
44    
45      VMFnResult* InstrumentScriptVMFunction_play_note::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_play_note::exec(VMFnArgs* args) {
46          vmint note = args->arg(0)->asInt()->evalInt();          vmint note = args->arg(0)->asInt()->evalInt();
47          vmint velocity = (args->argsCount() >= 2) ? args->arg(1)->asInt()->evalInt() : 127;          vmint velocity = (args->argsCount() >= 2) ? args->arg(1)->asInt()->evalInt() : 127;
48          vmint duration = (args->argsCount() >= 4) ? args->arg(3)->asInt()->evalInt() : 0; //TODO: -1 might be a better default value instead of 0          VMNumberExpr* argDuration = (args->argsCount() >= 4) ? args->arg(3)->asNumber() : NULL;
49            vmint duration =
50                (argDuration) ?
51                    (argDuration->unitType()) ?
52                        argDuration->evalCastInt(VM_MICRO) :
53                        argDuration->evalCastInt() : 0; //TODO: -1 might be a better default value instead of 0
54    
55          if (note < 0 || note > 127) {          if (note < 0 || note > 127) {
56              errMsg("play_note(): argument 1 is an invalid note number");              errMsg("play_note(): argument 1 is an invalid note number");
# Line 69  namespace LinuxSampler { Line 95  namespace LinuxSampler {
95          // if a sample offset is supplied, assign the offset as override          // if a sample offset is supplied, assign the offset as override
96          // to the previously created Note object          // to the previously created Note object
97          if (args->argsCount() >= 3) {          if (args->argsCount() >= 3) {
98              vmint sampleoffset = args->arg(2)->asInt()->evalInt();              VMNumberExpr* argSampleOffset = args->arg(2)->asNumber();
99                vmint sampleoffset =
100                    (argSampleOffset->unitType()) ?
101                        argSampleOffset->evalCastInt(VM_MICRO) :
102                        argSampleOffset->evalCastInt();
103              if (sampleoffset >= 0) {              if (sampleoffset >= 0) {
104                  NoteBase* pNote = pEngineChannel->pEngine->NoteByID(id);                  NoteBase* pNote = pEngineChannel->pEngine->NoteByID(id);
105                  if (pNote) {                  if (pNote) {
# Line 372  namespace LinuxSampler { Line 402  namespace LinuxSampler {
402      bool InstrumentScriptVMFunction_change_vol::acceptsArgType(vmint iArg, ExprType_t type) const {      bool InstrumentScriptVMFunction_change_vol::acceptsArgType(vmint iArg, ExprType_t type) const {
403          if (iArg == 0)          if (iArg == 0)
404              return type == INT_EXPR || type == INT_ARR_EXPR;              return type == INT_EXPR || type == INT_ARR_EXPR;
405            else if (iArg == 1)
406                return type == INT_EXPR || type == REAL_EXPR;
407          else          else
408              return type == INT_EXPR;              return type == INT_EXPR;
409      }      }
# Line 384  namespace LinuxSampler { Line 416  namespace LinuxSampler {
416      }      }
417    
418      bool InstrumentScriptVMFunction_change_vol::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_change_vol::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
419          return iArg == 1 && type == VM_BEL;          return iArg == 1 && type == VM_BEL; // only allow metric prefix(es) if 'Bel' is used as unit type
420      }      }
421    
422      bool InstrumentScriptVMFunction_change_vol::acceptsArgFinal(vmint iArg) const {      bool InstrumentScriptVMFunction_change_vol::acceptsArgFinal(vmint iArg) const {
# Line 392  namespace LinuxSampler { Line 424  namespace LinuxSampler {
424      }      }
425    
426      VMFnResult* InstrumentScriptVMFunction_change_vol::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_vol::exec(VMFnArgs* args) {
427          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asNumber()->unitType();
428          vmint volume   = (unit) ? args->arg(1)->asInt()->evalInt(VM_MILLI,VM_DECI)          vmint volume =
429                                  : args->arg(1)->asInt()->evalInt(); // volume change in milli dB              (unit) ?
430          bool isFinal   = args->arg(1)->asInt()->isFinal();                  args->arg(1)->asNumber()->evalCastInt(VM_MILLI,VM_DECI) :
431                    args->arg(1)->asNumber()->evalCastInt(); // volume change in milli dB
432            bool isFinal = args->arg(1)->asNumber()->isFinal();
433          bool relative = (args->argsCount() >= 3) ? (args->arg(2)->asInt()->evalInt() & 1) : false;          bool relative = (args->argsCount() >= 3) ? (args->arg(2)->asInt()->evalInt() & 1) : false;
434          const float fVolumeLin = RTMath::DecibelToLinRatio(float(volume) / 1000.f);          const float fVolumeLin = RTMath::DecibelToLinRatio(float(volume) / 1000.f);
435    
# Line 487  namespace LinuxSampler { Line 521  namespace LinuxSampler {
521      bool InstrumentScriptVMFunction_change_tune::acceptsArgType(vmint iArg, ExprType_t type) const {      bool InstrumentScriptVMFunction_change_tune::acceptsArgType(vmint iArg, ExprType_t type) const {
522          if (iArg == 0)          if (iArg == 0)
523              return type == INT_EXPR || type == INT_ARR_EXPR;              return type == INT_EXPR || type == INT_ARR_EXPR;
524            else if (iArg == 1)
525                return type == INT_EXPR || type == REAL_EXPR;
526          else          else
527              return type == INT_EXPR;              return type == INT_EXPR;
528      }      }
# Line 500  namespace LinuxSampler { Line 536  namespace LinuxSampler {
536      }      }
537    
538      VMFnResult* InstrumentScriptVMFunction_change_tune::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_tune::exec(VMFnArgs* args) {
539          bool bUnitFactor = args->arg(1)->asInt()->hasUnitFactorNow();          vmint tune =
540          vmint tune       = (bUnitFactor) ? args->arg(1)->asInt()->evalInt(VM_MILLI,VM_CENTI)              (args->arg(1)->asNumber()->hasUnitFactorNow())
541                                           : args->arg(1)->asInt()->evalInt(); // tuning change in milli cents                  ? args->arg(1)->asNumber()->evalCastInt(VM_MILLI,VM_CENTI)
542          bool isFinal   = args->arg(1)->asInt()->isFinal();                  : args->arg(1)->asNumber()->evalCastInt(); // tuning change in milli cents
543          StdUnit_t unit = args->arg(1)->asInt()->unitType();          bool isFinal = args->arg(1)->asNumber()->isFinal();
544            StdUnit_t unit = args->arg(1)->asNumber()->unitType();
545          bool relative = (args->argsCount() >= 3) ? (args->arg(2)->asInt()->evalInt() & 1) : false;          bool relative = (args->argsCount() >= 3) ? (args->arg(2)->asInt()->evalInt() & 1) : false;
546          const float fFreqRatio = RTMath::CentsToFreqRatioUnlimited(float(tune) / 1000.f);          const float fFreqRatio = RTMath::CentsToFreqRatioUnlimited(float(tune) / 1000.f);
547    
# Line 708  namespace LinuxSampler { Line 745  namespace LinuxSampler {
745      bool InstrumentScriptVMFunction_change_cutoff::acceptsArgType(vmint iArg, ExprType_t type) const {      bool InstrumentScriptVMFunction_change_cutoff::acceptsArgType(vmint iArg, ExprType_t type) const {
746          if (iArg == 0)          if (iArg == 0)
747              return type == INT_EXPR || type == INT_ARR_EXPR;              return type == INT_EXPR || type == INT_ARR_EXPR;
748            else if (iArg == 1)
749                return type == INT_EXPR || type == REAL_EXPR;
750          else          else
751              return type == INT_EXPR;              return type == INT_EXPR;
752      }      }
# Line 720  namespace LinuxSampler { Line 759  namespace LinuxSampler {
759      }      }
760    
761      bool InstrumentScriptVMFunction_change_cutoff::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_change_cutoff::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
762          return iArg == 1 && type == VM_HERTZ;          return iArg == 1 && type == VM_HERTZ; // only allow metric prefix(es) if 'Hz' is used as unit type
763      }      }
764    
765      bool InstrumentScriptVMFunction_change_cutoff::acceptsArgFinal(vmint iArg) const {      bool InstrumentScriptVMFunction_change_cutoff::acceptsArgFinal(vmint iArg) const {
# Line 728  namespace LinuxSampler { Line 767  namespace LinuxSampler {
767      }      }
768    
769      VMFnResult* InstrumentScriptVMFunction_change_cutoff::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_cutoff::exec(VMFnArgs* args) {
770          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asNumber()->unitType();
771          vmint cutoff   = (unit) ? args->arg(1)->asInt()->evalInt(VM_NO_PREFIX)          vmint cutoff =
772                                  : args->arg(1)->asInt()->evalInt();              (unit) ?
773          bool isFinal   = args->arg(1)->asInt()->isFinal();                  args->arg(1)->asNumber()->evalCastInt(VM_NO_PREFIX) :
774                    args->arg(1)->asNumber()->evalCastInt();
775            bool isFinal = args->arg(1)->asNumber()->isFinal();
776          if (!unit && cutoff > VM_FILTER_PAR_MAX_VALUE) {          if (!unit && cutoff > VM_FILTER_PAR_MAX_VALUE) {
777              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));
778              cutoff = VM_FILTER_PAR_MAX_VALUE;              cutoff = VM_FILTER_PAR_MAX_VALUE;
# Line 923  namespace LinuxSampler { Line 964  namespace LinuxSampler {
964          if (iArg == 0)          if (iArg == 0)
965              return type == INT_EXPR || type == INT_ARR_EXPR;              return type == INT_EXPR || type == INT_ARR_EXPR;
966          else          else
967              return type == INT_EXPR;              return type == INT_EXPR || type == REAL_EXPR;
968      }      }
969    
970      bool InstrumentScriptVMFunction_change_attack::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_change_attack::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {
# Line 934  namespace LinuxSampler { Line 975  namespace LinuxSampler {
975      }      }
976    
977      bool InstrumentScriptVMFunction_change_attack::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_change_attack::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
978          return iArg == 1 && type == VM_SECOND;          return iArg == 1 && type == VM_SECOND; // only allow metric prefix(es) if 'seconds' is used as unit type
979      }      }
980    
981      bool InstrumentScriptVMFunction_change_attack::acceptsArgFinal(vmint iArg) const {      bool InstrumentScriptVMFunction_change_attack::acceptsArgFinal(vmint iArg) const {
# Line 942  namespace LinuxSampler { Line 983  namespace LinuxSampler {
983      }      }
984    
985      VMFnResult* InstrumentScriptVMFunction_change_attack::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_attack::exec(VMFnArgs* args) {
986          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asNumber()->unitType();
987          vmint attack   = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)          vmint attack =
988                                  : args->arg(1)->asInt()->evalInt();              (unit) ?
989          bool isFinal   = args->arg(1)->asInt()->isFinal();                  args->arg(1)->asNumber()->evalCastInt(VM_MICRO) :
990                    args->arg(1)->asNumber()->evalCastInt();
991            bool isFinal = args->arg(1)->asNumber()->isFinal();
992          // note: intentionally not checking against a max. value here!          // note: intentionally not checking against a max. value here!
993          // (to allow i.e. passing 2000000 for doubling the attack time)          // (to allow i.e. passing 2000000 for doubling the attack time)
994          if (attack < 0) {          if (attack < 0) {
# Line 1036  namespace LinuxSampler { Line 1079  namespace LinuxSampler {
1079          if (iArg == 0)          if (iArg == 0)
1080              return type == INT_EXPR || type == INT_ARR_EXPR;              return type == INT_EXPR || type == INT_ARR_EXPR;
1081          else          else
1082              return type == INT_EXPR;              return type == INT_EXPR || type == REAL_EXPR;
1083      }      }
1084    
1085      bool InstrumentScriptVMFunction_change_decay::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_change_decay::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {
# Line 1047  namespace LinuxSampler { Line 1090  namespace LinuxSampler {
1090      }      }
1091    
1092      bool InstrumentScriptVMFunction_change_decay::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_change_decay::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
1093          return iArg == 1 && type == VM_SECOND;          return iArg == 1 && type == VM_SECOND; // only allow metric prefix(es) if 'seconds' is used as unit type
1094      }      }
1095    
1096      bool InstrumentScriptVMFunction_change_decay::acceptsArgFinal(vmint iArg) const {      bool InstrumentScriptVMFunction_change_decay::acceptsArgFinal(vmint iArg) const {
# Line 1055  namespace LinuxSampler { Line 1098  namespace LinuxSampler {
1098      }      }
1099    
1100      VMFnResult* InstrumentScriptVMFunction_change_decay::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_decay::exec(VMFnArgs* args) {
1101          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asNumber()->unitType();
1102          vmint decay    = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)          vmint decay =
1103                                  : args->arg(1)->asInt()->evalInt();              (unit) ?
1104          bool isFinal   = args->arg(1)->asInt()->isFinal();                  args->arg(1)->asNumber()->evalCastInt(VM_MICRO) :
1105                    args->arg(1)->asNumber()->evalCastInt();
1106            bool isFinal = args->arg(1)->asNumber()->isFinal();
1107          // note: intentionally not checking against a max. value here!          // note: intentionally not checking against a max. value here!
1108          // (to allow i.e. passing 2000000 for doubling the decay time)          // (to allow i.e. passing 2000000 for doubling the decay time)
1109          if (decay < 0) {          if (decay < 0) {
# Line 1149  namespace LinuxSampler { Line 1194  namespace LinuxSampler {
1194          if (iArg == 0)          if (iArg == 0)
1195              return type == INT_EXPR || type == INT_ARR_EXPR;              return type == INT_EXPR || type == INT_ARR_EXPR;
1196          else          else
1197              return type == INT_EXPR;              return type == INT_EXPR || type == REAL_EXPR;
1198      }      }
1199    
1200      bool InstrumentScriptVMFunction_change_release::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_change_release::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {
# Line 1160  namespace LinuxSampler { Line 1205  namespace LinuxSampler {
1205      }      }
1206    
1207      bool InstrumentScriptVMFunction_change_release::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_change_release::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
1208          return iArg == 1 && type == VM_SECOND;          return iArg == 1 && type == VM_SECOND; // only allow metric prefix(es) if 'seconds' is used as unit type
1209      }      }
1210    
1211      bool InstrumentScriptVMFunction_change_release::acceptsArgFinal(vmint iArg) const {      bool InstrumentScriptVMFunction_change_release::acceptsArgFinal(vmint iArg) const {
# Line 1168  namespace LinuxSampler { Line 1213  namespace LinuxSampler {
1213      }      }
1214    
1215      VMFnResult* InstrumentScriptVMFunction_change_release::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_release::exec(VMFnArgs* args) {
1216          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asNumber()->unitType();
1217          vmint release  = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)          vmint release =
1218                                  : args->arg(1)->asInt()->evalInt();              (unit) ?
1219          bool isFinal   = args->arg(1)->asInt()->isFinal();                  args->arg(1)->asNumber()->evalCastInt(VM_MICRO) :
1220                    args->arg(1)->asNumber()->evalCastInt();
1221            bool isFinal = args->arg(1)->asNumber()->isFinal();
1222          // note: intentionally not checking against a max. value here!          // note: intentionally not checking against a max. value here!
1223          // (to allow i.e. passing 2000000 for doubling the release time)          // (to allow i.e. passing 2000000 for doubling the release time)
1224          if (release < 0) {          if (release < 0) {
# Line 1257  namespace LinuxSampler { Line 1304  namespace LinuxSampler {
1304          if (iArg == 0)          if (iArg == 0)
1305              return type == INT_EXPR || type == INT_ARR_EXPR;              return type == INT_EXPR || type == INT_ARR_EXPR;
1306          else          else
1307              return type == INT_EXPR;              return type == INT_EXPR || (m_acceptReal && type == REAL_EXPR);
1308      }      }
1309    
1310      bool VMChangeSynthParamFunction::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {      bool VMChangeSynthParamFunction::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {
# Line 1268  namespace LinuxSampler { Line 1315  namespace LinuxSampler {
1315      }      }
1316    
1317      bool VMChangeSynthParamFunction::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {      bool VMChangeSynthParamFunction::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
1318          return m_acceptUnitPrefix && iArg == 1 && type == m_unit;          return m_acceptUnitPrefix && iArg == 1 && type == m_unit; // only allow metric prefix(es) if approprirate unit type is used (e.g. Hz)
1319      }      }
1320    
1321      bool VMChangeSynthParamFunction::acceptsArgFinal(vmint iArg) const {      bool VMChangeSynthParamFunction::acceptsArgFinal(vmint iArg) const {
# Line 1306  namespace LinuxSampler { Line 1353  namespace LinuxSampler {
1353               MetricPrefix_t T_unitPrefix0, MetricPrefix_t ... T_unitPrefixN>               MetricPrefix_t T_unitPrefix0, MetricPrefix_t ... T_unitPrefixN>
1354      VMFnResult* VMChangeSynthParamFunction::execTemplate(VMFnArgs* args, const char* functionName)      VMFnResult* VMChangeSynthParamFunction::execTemplate(VMFnArgs* args, const char* functionName)
1355      {      {
1356          const StdUnit_t unit = args->arg(1)->asInt()->unitType();          const StdUnit_t unit = args->arg(1)->asNumber()->unitType();
1357          const bool isFinal   = args->arg(1)->asInt()->isFinal();          const bool isFinal   = args->arg(1)->asNumber()->isFinal();
1358          vmint value =          vmint value =
1359              (m_acceptUnitPrefix && ((m_unit && unit) || (!m_unit && args->arg(1)->asInt()->hasUnitFactorNow())))              (m_acceptUnitPrefix && ((m_unit && unit) || (!m_unit && args->arg(1)->asNumber()->hasUnitFactorNow())))
1360                  ? args->arg(1)->asInt()->evalInt(T_unitPrefix0, T_unitPrefixN ...)                  ? args->arg(1)->asNumber()->evalCastInt(T_unitPrefix0, T_unitPrefixN ...)
1361                  : args->arg(1)->asInt()->evalInt();                  : args->arg(1)->asNumber()->evalCastInt();
1362    
1363          if (unit && !isFinal && m_unit != VM_BEL && m_unit) {          if (unit && !isFinal && m_unit != VM_BEL && m_unit) {
1364              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 1729  namespace LinuxSampler { Line 1776  namespace LinuxSampler {
1776          if (iArg == 0)          if (iArg == 0)
1777              return type == INT_EXPR || type == INT_ARR_EXPR;              return type == INT_EXPR || type == INT_ARR_EXPR;
1778          else          else
1779              return type == INT_EXPR;              return type == INT_EXPR || type == REAL_EXPR;
1780      }      }
1781    
1782      bool InstrumentScriptVMFunction_fade_in::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_fade_in::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {
# Line 1740  namespace LinuxSampler { Line 1787  namespace LinuxSampler {
1787      }      }
1788    
1789      bool InstrumentScriptVMFunction_fade_in::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_fade_in::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
1790          return iArg == 1 && type == VM_SECOND;          return iArg == 1 && type == VM_SECOND; // only allow metric prefix(es) if 'seconds' is used as unit type
1791      }      }
1792    
1793      VMFnResult* InstrumentScriptVMFunction_fade_in::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_fade_in::exec(VMFnArgs* args) {
1794          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asNumber()->unitType();
1795          vmint duration = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)          vmint duration =
1796                                  : args->arg(1)->asInt()->evalInt();              (unit) ?
1797                    args->arg(1)->asNumber()->evalCastInt(VM_MICRO) :
1798                    args->arg(1)->asNumber()->evalCastInt();
1799          if (duration < 0) {          if (duration < 0) {
1800              wrnMsg("fade_in(): argument 2 may not be negative");              wrnMsg("fade_in(): argument 2 may not be negative");
1801              duration = 0;              duration = 0;
# Line 1862  namespace LinuxSampler { Line 1911  namespace LinuxSampler {
1911          if (iArg == 0)          if (iArg == 0)
1912              return type == INT_EXPR || type == INT_ARR_EXPR;              return type == INT_EXPR || type == INT_ARR_EXPR;
1913          else          else
1914              return type == INT_EXPR;              return type == INT_EXPR || type == REAL_EXPR;
1915      }      }
1916    
1917      bool InstrumentScriptVMFunction_fade_out::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_fade_out::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {
# Line 1873  namespace LinuxSampler { Line 1922  namespace LinuxSampler {
1922      }      }
1923    
1924      bool InstrumentScriptVMFunction_fade_out::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_fade_out::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
1925          return iArg == 1 && type == VM_SECOND;          return iArg == 1 && type == VM_SECOND; // only allow metric prefix(es) if 'seconds' is used as unit type
1926      }      }
1927    
1928      VMFnResult* InstrumentScriptVMFunction_fade_out::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_fade_out::exec(VMFnArgs* args) {
1929          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asNumber()->unitType();
1930          vmint duration = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)          vmint duration =
1931                                  : args->arg(1)->asInt()->evalInt();              (unit) ?
1932                    args->arg(1)->asNumber()->evalCastInt(VM_MICRO) :
1933                    args->arg(1)->asNumber()->evalCastInt();
1934          if (duration < 0) {          if (duration < 0) {
1935              wrnMsg("fade_out(): argument 2 may not be negative");              wrnMsg("fade_out(): argument 2 may not be negative");
1936              duration = 0;              duration = 0;
# Line 2220  namespace LinuxSampler { Line 2271  namespace LinuxSampler {
2271      // change_play_pos() function      // change_play_pos() function
2272    
2273      InstrumentScriptVMFunction_change_play_pos::InstrumentScriptVMFunction_change_play_pos(InstrumentScriptVM* parent)      InstrumentScriptVMFunction_change_play_pos::InstrumentScriptVMFunction_change_play_pos(InstrumentScriptVM* parent)
2274      : m_vm(parent)          : m_vm(parent)
2275      {      {
2276      }      }
2277    
2278        bool InstrumentScriptVMFunction_change_play_pos::acceptsArgType(vmint iArg, ExprType_t type) const {
2279            if (iArg == 0)
2280                return type == INT_EXPR;
2281            else
2282                return type == INT_EXPR || type == REAL_EXPR;
2283        }
2284    
2285      bool InstrumentScriptVMFunction_change_play_pos::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_change_play_pos::acceptsArgUnitType(vmint iArg, StdUnit_t type) const {
2286          if (iArg == 1)          if (iArg == 1)
2287              return type == VM_NO_UNIT || type == VM_SECOND;              return type == VM_NO_UNIT || type == VM_SECOND;
# Line 2232  namespace LinuxSampler { Line 2290  namespace LinuxSampler {
2290      }      }
2291    
2292      bool InstrumentScriptVMFunction_change_play_pos::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {      bool InstrumentScriptVMFunction_change_play_pos::acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const {
2293          return iArg == 1 && VM_SECOND;          return iArg == 1 && type == VM_SECOND; // only allow metric prefix(es) if 'seconds' is used as unit type
2294      }      }
2295    
2296      VMFnResult* InstrumentScriptVMFunction_change_play_pos::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_change_play_pos::exec(VMFnArgs* args) {
# Line 2246  namespace LinuxSampler { Line 2304  namespace LinuxSampler {
2304              return successResult();              return successResult();
2305          }          }
2306    
2307          StdUnit_t unit = args->arg(1)->asInt()->unitType();          StdUnit_t unit = args->arg(1)->asNumber()->unitType();
2308          const vmint pos = (unit) ? args->arg(1)->asInt()->evalInt(VM_MICRO)          const vmint pos =
2309                                   : args->arg(1)->asInt()->evalInt();              (unit) ?
2310                    args->arg(1)->asNumber()->evalCastInt(VM_MICRO) :
2311                    args->arg(1)->asNumber()->evalCastInt();
2312          if (pos < 0) {          if (pos < 0) {
2313              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");
2314              return successResult();              return successResult();

Legend:
Removed from v.3581  
changed lines
  Added in v.3587

  ViewVC Help
Powered by ViewVC