136 |
AbstractEngineChannel* pEngineChannel = |
AbstractEngineChannel* pEngineChannel = |
137 |
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
138 |
|
|
139 |
if (args->arg(0)->exprType() == INT_EXPR) { |
if (args->argsCount() == 0 || args->arg(0)->exprType() == INT_EXPR) { |
140 |
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
const ScriptID id = (args->argsCount() >= 1) ? args->arg(0)->asInt()->evalInt() : m_vm->m_event->id; |
141 |
if (!id) { |
if (!id && args->argsCount() >= 1) { |
142 |
wrnMsg("ignore_event(): event ID argument may not be zero"); |
wrnMsg("ignore_event(): event ID argument may not be zero"); |
143 |
// not errorResult(), because that would abort the script, not intentional in this case |
// not errorResult(), because that would abort the script, not intentional in this case |
144 |
return successResult(); |
return successResult(); |
385 |
if (!pNote) return successResult(); |
if (!pNote) return successResult(); |
386 |
|
|
387 |
// if change_vol() was called immediately after note was triggered |
// if change_vol() was called immediately after note was triggered |
388 |
// then immediately apply the volume to note object |
// then immediately apply the volume to note object, but only if |
389 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
// change_vol_time() has not been called before |
390 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime && |
391 |
|
pNote->Override.VolumeTime <= DEFAULT_NOTE_VOLUME_TIME_S) |
392 |
|
{ |
393 |
if (relative) |
if (relative) |
394 |
pNote->Override.Volume *= fVolumeLin; |
pNote->Override.Volume *= fVolumeLin; |
395 |
else |
else |
415 |
if (!pNote) continue; |
if (!pNote) continue; |
416 |
|
|
417 |
// if change_vol() was called immediately after note was triggered |
// if change_vol() was called immediately after note was triggered |
418 |
// then immediately apply the volume to Note object |
// then immediately apply the volume to Note object, but only if |
419 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
// change_vol_time() has not been called before |
420 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime && |
421 |
|
pNote->Override.VolumeTime <= DEFAULT_NOTE_VOLUME_TIME_S) |
422 |
|
{ |
423 |
if (relative) |
if (relative) |
424 |
pNote->Override.Volume *= fVolumeLin; |
pNote->Override.Volume *= fVolumeLin; |
425 |
else |
else |
478 |
if (!pNote) return successResult(); |
if (!pNote) return successResult(); |
479 |
|
|
480 |
// if change_tune() was called immediately after note was triggered |
// if change_tune() was called immediately after note was triggered |
481 |
// then immediately apply the tuning to Note object |
// then immediately apply the tuning to Note object, but only if |
482 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
// change_tune_time() has not been called before |
483 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime && |
484 |
|
pNote->Override.PitchTime <= DEFAULT_NOTE_PITCH_TIME_S) |
485 |
|
{ |
486 |
if (relative) |
if (relative) |
487 |
pNote->Override.Pitch *= fFreqRatio; |
pNote->Override.Pitch *= fFreqRatio; |
488 |
else |
else |
508 |
if (!pNote) continue; |
if (!pNote) continue; |
509 |
|
|
510 |
// if change_tune() was called immediately after note was triggered |
// if change_tune() was called immediately after note was triggered |
511 |
// then immediately apply the tuning to Note object |
// then immediately apply the tuning to Note object, but only if |
512 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
// change_tune_time() has not been called before |
513 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime && |
514 |
|
pNote->Override.PitchTime <= DEFAULT_NOTE_PITCH_TIME_S) |
515 |
|
{ |
516 |
if (relative) |
if (relative) |
517 |
pNote->Override.Pitch *= fFreqRatio; |
pNote->Override.Pitch *= fFreqRatio; |
518 |
else |
else |
580 |
|
|
581 |
// if change_pan() was called immediately after note was triggered |
// if change_pan() was called immediately after note was triggered |
582 |
// then immediately apply the panning to Note object |
// then immediately apply the panning to Note object |
583 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
584 |
if (relative) { |
if (relative) { |
585 |
pNote->Override.Pan = RTMath::RelativeSummedAvg(pNote->Override.Pan, fPan, ++pNote->Override.PanSources); |
pNote->Override.Pan = RTMath::RelativeSummedAvg(pNote->Override.Pan, fPan, ++pNote->Override.PanSources); |
586 |
} else { |
} else { |
609 |
|
|
610 |
// if change_pan() was called immediately after note was triggered |
// if change_pan() was called immediately after note was triggered |
611 |
// then immediately apply the panning to Note object |
// then immediately apply the panning to Note object |
612 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
613 |
if (relative) { |
if (relative) { |
614 |
pNote->Override.Pan = RTMath::RelativeSummedAvg(pNote->Override.Pan, fPan, ++pNote->Override.PanSources); |
pNote->Override.Pan = RTMath::RelativeSummedAvg(pNote->Override.Pan, fPan, ++pNote->Override.PanSources); |
615 |
} else { |
} else { |
680 |
|
|
681 |
// if change_cutoff() was called immediately after note was triggered |
// if change_cutoff() was called immediately after note was triggered |
682 |
// then immediately apply cutoff to Note object |
// then immediately apply cutoff to Note object |
683 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
684 |
pNote->Override.Cutoff = fCutoff; |
pNote->Override.Cutoff = fCutoff; |
685 |
} else { // otherwise schedule cutoff change ... |
} else { // otherwise schedule cutoff change ... |
686 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
704 |
|
|
705 |
// if change_cutoff() was called immediately after note was triggered |
// if change_cutoff() was called immediately after note was triggered |
706 |
// then immediately apply cutoff to Note object |
// then immediately apply cutoff to Note object |
707 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
708 |
pNote->Override.Cutoff = fCutoff; |
pNote->Override.Cutoff = fCutoff; |
709 |
} else { // otherwise schedule cutoff change ... |
} else { // otherwise schedule cutoff change ... |
710 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
767 |
|
|
768 |
// if change_reso() was called immediately after note was triggered |
// if change_reso() was called immediately after note was triggered |
769 |
// then immediately apply resonance to Note object |
// then immediately apply resonance to Note object |
770 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
771 |
pNote->Override.Resonance = fResonance; |
pNote->Override.Resonance = fResonance; |
772 |
} else { // otherwise schedule resonance change ... |
} else { // otherwise schedule resonance change ... |
773 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
791 |
|
|
792 |
// if change_reso() was called immediately after note was triggered |
// if change_reso() was called immediately after note was triggered |
793 |
// then immediately apply resonance to Note object |
// then immediately apply resonance to Note object |
794 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
795 |
pNote->Override.Resonance = fResonance; |
pNote->Override.Resonance = fResonance; |
796 |
} else { // otherwise schedule resonance change ... |
} else { // otherwise schedule resonance change ... |
797 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
854 |
|
|
855 |
// if change_attack() was called immediately after note was triggered |
// if change_attack() was called immediately after note was triggered |
856 |
// then immediately apply attack to Note object |
// then immediately apply attack to Note object |
857 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
858 |
pNote->Override.Attack = fAttack; |
pNote->Override.Attack = fAttack; |
859 |
} else { // otherwise schedule attack change ... |
} else { // otherwise schedule attack change ... |
860 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
878 |
|
|
879 |
// if change_attack() was called immediately after note was triggered |
// if change_attack() was called immediately after note was triggered |
880 |
// then immediately apply attack to Note object |
// then immediately apply attack to Note object |
881 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
882 |
pNote->Override.Attack = fAttack; |
pNote->Override.Attack = fAttack; |
883 |
} else { // otherwise schedule attack change ... |
} else { // otherwise schedule attack change ... |
884 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
941 |
|
|
942 |
// if change_decay() was called immediately after note was triggered |
// if change_decay() was called immediately after note was triggered |
943 |
// then immediately apply decay to Note object |
// then immediately apply decay to Note object |
944 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
945 |
pNote->Override.Decay = fDecay; |
pNote->Override.Decay = fDecay; |
946 |
} else { // otherwise schedule decay change ... |
} else { // otherwise schedule decay change ... |
947 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
965 |
|
|
966 |
// if change_decay() was called immediately after note was triggered |
// if change_decay() was called immediately after note was triggered |
967 |
// then immediately apply decay to Note object |
// then immediately apply decay to Note object |
968 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
969 |
pNote->Override.Decay = fDecay; |
pNote->Override.Decay = fDecay; |
970 |
} else { // otherwise schedule decay change ... |
} else { // otherwise schedule decay change ... |
971 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
1028 |
|
|
1029 |
// if change_release() was called immediately after note was triggered |
// if change_release() was called immediately after note was triggered |
1030 |
// then immediately apply relase to Note object |
// then immediately apply relase to Note object |
1031 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1032 |
pNote->Override.Release = fRelease; |
pNote->Override.Release = fRelease; |
1033 |
} else { // otherwise schedule release change ... |
} else { // otherwise schedule release change ... |
1034 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
1052 |
|
|
1053 |
// if change_release() was called immediately after note was triggered |
// if change_release() was called immediately after note was triggered |
1054 |
// then immediately apply relase to Note object |
// then immediately apply relase to Note object |
1055 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1056 |
pNote->Override.Release = fRelease; |
pNote->Override.Release = fRelease; |
1057 |
} else { // otherwise schedule release change ... |
} else { // otherwise schedule release change ... |
1058 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
1071 |
return successResult(); |
return successResult(); |
1072 |
} |
} |
1073 |
|
|
1074 |
|
// template for change_*() functions |
1075 |
|
|
1076 |
bool VMChangeSynthParamFunction::acceptsArgType(int iArg, ExprType_t type) const { |
bool VMChangeSynthParamFunction::acceptsArgType(int iArg, ExprType_t type) const { |
1077 |
if (iArg == 0) |
if (iArg == 0) |
1078 |
return type == INT_EXPR || type == INT_ARR_EXPR; |
return type == INT_EXPR || type == INT_ARR_EXPR; |
1121 |
// if this change_*() script function was called immediately after |
// if this change_*() script function was called immediately after |
1122 |
// note was triggered then immediately apply the synth parameter |
// note was triggered then immediately apply the synth parameter |
1123 |
// change to Note object |
// change to Note object |
1124 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1125 |
pNote->Override.*T_noteParam = fValue; |
pNote->Override.*T_noteParam = fValue; |
1126 |
} else { // otherwise schedule this synth parameter change ... |
} else { // otherwise schedule this synth parameter change ... |
1127 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
1146 |
// if this change_*() script function was called immediately after |
// if this change_*() script function was called immediately after |
1147 |
// note was triggered then immediately apply the synth parameter |
// note was triggered then immediately apply the synth parameter |
1148 |
// change to Note object |
// change to Note object |
1149 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1150 |
pNote->Override.*T_noteParam = fValue; |
pNote->Override.*T_noteParam = fValue; |
1151 |
} else { // otherwise schedule this synth parameter change ... |
} else { // otherwise schedule this synth parameter change ... |
1152 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
1219 |
false, NO_LIMIT, 0>( args, "change_tune_time" ); |
false, NO_LIMIT, 0>( args, "change_tune_time" ); |
1220 |
} |
} |
1221 |
|
|
1222 |
|
// template for change_*_curve() functions |
1223 |
|
|
1224 |
|
bool VMChangeFadeCurveFunction::acceptsArgType(int iArg, ExprType_t type) const { |
1225 |
|
if (iArg == 0) |
1226 |
|
return type == INT_EXPR || type == INT_ARR_EXPR; |
1227 |
|
else |
1228 |
|
return type == INT_EXPR; |
1229 |
|
} |
1230 |
|
|
1231 |
|
template<fade_curve_t NoteBase::_Override::*T_noteParam, int T_synthParam> |
1232 |
|
VMFnResult* VMChangeFadeCurveFunction::execTemplate(VMFnArgs* args, const char* functionName) { |
1233 |
|
int value = args->arg(1)->asInt()->evalInt(); |
1234 |
|
switch (value) { |
1235 |
|
case FADE_CURVE_LINEAR: |
1236 |
|
case FADE_CURVE_EASE_IN_EASE_OUT: |
1237 |
|
break; |
1238 |
|
default: |
1239 |
|
wrnMsg(String(functionName) + "(): invalid curve type passed as argument 2"); |
1240 |
|
return successResult(); |
1241 |
|
} |
1242 |
|
|
1243 |
|
AbstractEngineChannel* pEngineChannel = |
1244 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1245 |
|
|
1246 |
|
if (args->arg(0)->exprType() == INT_EXPR) { |
1247 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1248 |
|
if (!id) { |
1249 |
|
wrnMsg(String(functionName) + "(): note ID for argument 1 may not be zero"); |
1250 |
|
return successResult(); |
1251 |
|
} |
1252 |
|
if (!id.isNoteID()) { |
1253 |
|
wrnMsg(String(functionName) + "(): argument 1 is not a note ID"); |
1254 |
|
return successResult(); |
1255 |
|
} |
1256 |
|
|
1257 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1258 |
|
if (!pNote) return successResult(); |
1259 |
|
|
1260 |
|
// if this change_*_curve() script function was called immediately after |
1261 |
|
// note was triggered then immediately apply the synth parameter |
1262 |
|
// change to Note object |
1263 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1264 |
|
pNote->Override.*T_noteParam = (fade_curve_t) value; |
1265 |
|
} else { // otherwise schedule this synth parameter change ... |
1266 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
1267 |
|
e.Init(); // clear IDs |
1268 |
|
e.Type = Event::type_note_synth_param; |
1269 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
1270 |
|
e.Param.NoteSynthParam.Type = (Event::synth_param_t) T_synthParam; |
1271 |
|
e.Param.NoteSynthParam.Delta = value; |
1272 |
|
e.Param.NoteSynthParam.Relative = false; |
1273 |
|
|
1274 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
1275 |
|
} |
1276 |
|
} else if (args->arg(0)->exprType() == INT_ARR_EXPR) { |
1277 |
|
VMIntArrayExpr* ids = args->arg(0)->asIntArray(); |
1278 |
|
for (int i = 0; i < ids->arraySize(); ++i) { |
1279 |
|
const ScriptID id = ids->evalIntElement(i); |
1280 |
|
if (!id || !id.isNoteID()) continue; |
1281 |
|
|
1282 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1283 |
|
if (!pNote) continue; |
1284 |
|
|
1285 |
|
// if this change_*_curve() script function was called immediately after |
1286 |
|
// note was triggered then immediately apply the synth parameter |
1287 |
|
// change to Note object |
1288 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1289 |
|
pNote->Override.*T_noteParam = (fade_curve_t) value; |
1290 |
|
} else { // otherwise schedule this synth parameter change ... |
1291 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
1292 |
|
e.Init(); // clear IDs |
1293 |
|
e.Type = Event::type_note_synth_param; |
1294 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
1295 |
|
e.Param.NoteSynthParam.Type = (Event::synth_param_t) T_synthParam; |
1296 |
|
e.Param.NoteSynthParam.Delta = value; |
1297 |
|
e.Param.NoteSynthParam.Relative = false; |
1298 |
|
|
1299 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
1300 |
|
} |
1301 |
|
} |
1302 |
|
} |
1303 |
|
|
1304 |
|
return successResult(); |
1305 |
|
} |
1306 |
|
|
1307 |
|
// change_vol_curve() function |
1308 |
|
|
1309 |
|
VMFnResult* InstrumentScriptVMFunction_change_vol_curve::exec(VMFnArgs* args) { |
1310 |
|
return VMChangeFadeCurveFunction::execTemplate< |
1311 |
|
&NoteBase::_Override::VolumeCurve, |
1312 |
|
Event::synth_param_volume_curve>( args, "change_vol_curve" ); |
1313 |
|
} |
1314 |
|
|
1315 |
|
// change_tune_curve() function |
1316 |
|
|
1317 |
|
VMFnResult* InstrumentScriptVMFunction_change_tune_curve::exec(VMFnArgs* args) { |
1318 |
|
return VMChangeFadeCurveFunction::execTemplate< |
1319 |
|
&NoteBase::_Override::PitchCurve, |
1320 |
|
Event::synth_param_pitch_curve>( args, "change_tune_curve" ); |
1321 |
|
} |
1322 |
|
|
1323 |
// fade_in() function |
// fade_in() function |
1324 |
|
|
1325 |
InstrumentScriptVMFunction_fade_in::InstrumentScriptVMFunction_fade_in(InstrumentScriptVM* parent) |
InstrumentScriptVMFunction_fade_in::InstrumentScriptVMFunction_fade_in(InstrumentScriptVM* parent) |
1362 |
// if fade_in() was called immediately after note was triggered |
// if fade_in() was called immediately after note was triggered |
1363 |
// then immediately apply a start volume of zero to Note object, |
// then immediately apply a start volume of zero to Note object, |
1364 |
// as well as the fade in duration |
// as well as the fade in duration |
1365 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1366 |
pNote->Override.Volume = 0.f; |
pNote->Override.Volume = 0.f; |
1367 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1368 |
} else { // otherwise schedule a "volume time" change with the requested fade in duration ... |
} else { // otherwise schedule a "volume time" change with the requested fade in duration ... |
1404 |
// if fade_in() was called immediately after note was triggered |
// if fade_in() was called immediately after note was triggered |
1405 |
// then immediately apply a start volume of zero to Note object, |
// then immediately apply a start volume of zero to Note object, |
1406 |
// as well as the fade in duration |
// as well as the fade in duration |
1407 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1408 |
pNote->Override.Volume = 0.f; |
pNote->Override.Volume = 0.f; |
1409 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1410 |
} else { // otherwise schedule a "volume time" change with the requested fade in duration ... |
} else { // otherwise schedule a "volume time" change with the requested fade in duration ... |
1483 |
|
|
1484 |
// if fade_out() was called immediately after note was triggered |
// if fade_out() was called immediately after note was triggered |
1485 |
// then immediately apply fade out duration to Note object |
// then immediately apply fade out duration to Note object |
1486 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1487 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1488 |
} else { // otherwise schedule a "volume time" change with the requested fade out duration ... |
} else { // otherwise schedule a "volume time" change with the requested fade out duration ... |
1489 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
1535 |
|
|
1536 |
// if fade_out() was called immediately after note was triggered |
// if fade_out() was called immediately after note was triggered |
1537 |
// then immediately apply fade out duration to Note object |
// then immediately apply fade out duration to Note object |
1538 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1539 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1540 |
} else { // otherwise schedule a "volume time" change with the requested fade out duration ... |
} else { // otherwise schedule a "volume time" change with the requested fade out duration ... |
1541 |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
1670 |
wrnMsg("set_event_par(): note number of argument 3 is out of range"); |
wrnMsg("set_event_par(): note number of argument 3 is out of range"); |
1671 |
return successResult(); |
return successResult(); |
1672 |
} |
} |
1673 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1674 |
pNote->cause.Param.Note.Key = value; |
pNote->cause.Param.Note.Key = value; |
1675 |
else |
m_vm->m_event->cause.Param.Note.Key = value; |
1676 |
|
} else { |
1677 |
wrnMsg("set_event_par(): note number can only be changed when note is new"); |
wrnMsg("set_event_par(): note number can only be changed when note is new"); |
1678 |
|
} |
1679 |
return successResult(); |
return successResult(); |
1680 |
case EVENT_PAR_VELOCITY: |
case EVENT_PAR_VELOCITY: |
1681 |
if (value < 0 || value > 127) { |
if (value < 0 || value > 127) { |
1682 |
wrnMsg("set_event_par(): velocity of argument 3 is out of range"); |
wrnMsg("set_event_par(): velocity of argument 3 is out of range"); |
1683 |
return successResult(); |
return successResult(); |
1684 |
} |
} |
1685 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1686 |
pNote->cause.Param.Note.Velocity = value; |
pNote->cause.Param.Note.Velocity = value; |
1687 |
else |
m_vm->m_event->cause.Param.Note.Velocity = value; |
1688 |
|
} else { |
1689 |
wrnMsg("set_event_par(): velocity can only be changed when note is new"); |
wrnMsg("set_event_par(): velocity can only be changed when note is new"); |
1690 |
|
} |
1691 |
return successResult(); |
return successResult(); |
1692 |
case EVENT_PAR_VOLUME: |
case EVENT_PAR_VOLUME: |
1693 |
wrnMsg("set_event_par(): changing volume by this function is currently not supported, use change_vol() instead"); |
wrnMsg("set_event_par(): changing volume by this function is currently not supported, use change_vol() instead"); |
1713 |
return successResult(); |
return successResult(); |
1714 |
} |
} |
1715 |
|
|
1716 |
|
// change_note() function |
1717 |
|
|
1718 |
|
InstrumentScriptVMFunction_change_note::InstrumentScriptVMFunction_change_note(InstrumentScriptVM* parent) |
1719 |
|
: m_vm(parent) |
1720 |
|
{ |
1721 |
|
} |
1722 |
|
|
1723 |
|
VMFnResult* InstrumentScriptVMFunction_change_note::exec(VMFnArgs* args) { |
1724 |
|
AbstractEngineChannel* pEngineChannel = |
1725 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1726 |
|
|
1727 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1728 |
|
if (!id) { |
1729 |
|
wrnMsg("change_note(): note ID for argument 1 may not be zero"); |
1730 |
|
return successResult(); |
1731 |
|
} |
1732 |
|
if (!id.isNoteID()) { |
1733 |
|
wrnMsg("change_note(): argument 1 is not a note ID"); |
1734 |
|
return successResult(); |
1735 |
|
} |
1736 |
|
|
1737 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1738 |
|
if (!pNote) return successResult(); |
1739 |
|
|
1740 |
|
const int value = args->arg(1)->asInt()->evalInt(); |
1741 |
|
if (value < 0 || value > 127) { |
1742 |
|
wrnMsg("change_note(): note number of argument 2 is out of range"); |
1743 |
|
return successResult(); |
1744 |
|
} |
1745 |
|
|
1746 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1747 |
|
pNote->cause.Param.Note.Key = value; |
1748 |
|
m_vm->m_event->cause.Param.Note.Key = value; |
1749 |
|
} else { |
1750 |
|
wrnMsg("change_note(): note number can only be changed when note is new"); |
1751 |
|
} |
1752 |
|
|
1753 |
|
return successResult(); |
1754 |
|
} |
1755 |
|
|
1756 |
|
// change_velo() function |
1757 |
|
|
1758 |
|
InstrumentScriptVMFunction_change_velo::InstrumentScriptVMFunction_change_velo(InstrumentScriptVM* parent) |
1759 |
|
: m_vm(parent) |
1760 |
|
{ |
1761 |
|
} |
1762 |
|
|
1763 |
|
VMFnResult* InstrumentScriptVMFunction_change_velo::exec(VMFnArgs* args) { |
1764 |
|
AbstractEngineChannel* pEngineChannel = |
1765 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1766 |
|
|
1767 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1768 |
|
if (!id) { |
1769 |
|
wrnMsg("change_velo(): note ID for argument 1 may not be zero"); |
1770 |
|
return successResult(); |
1771 |
|
} |
1772 |
|
if (!id.isNoteID()) { |
1773 |
|
wrnMsg("change_velo(): argument 1 is not a note ID"); |
1774 |
|
return successResult(); |
1775 |
|
} |
1776 |
|
|
1777 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1778 |
|
if (!pNote) return successResult(); |
1779 |
|
|
1780 |
|
const int value = args->arg(1)->asInt()->evalInt(); |
1781 |
|
if (value < 0 || value > 127) { |
1782 |
|
wrnMsg("change_velo(): velocity of argument 2 is out of range"); |
1783 |
|
return successResult(); |
1784 |
|
} |
1785 |
|
|
1786 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1787 |
|
pNote->cause.Param.Note.Velocity = value; |
1788 |
|
m_vm->m_event->cause.Param.Note.Velocity = value; |
1789 |
|
} else { |
1790 |
|
wrnMsg("change_velo(): velocity can only be changed when note is new"); |
1791 |
|
} |
1792 |
|
|
1793 |
|
return successResult(); |
1794 |
|
} |
1795 |
|
|
1796 |
// event_status() function |
// event_status() function |
1797 |
|
|
1798 |
InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent) |
InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent) |
1858 |
(args->argsCount() >= 2) ? (args->arg(1)->asInt()->evalInt() == 1) : false; |
(args->argsCount() >= 2) ? (args->arg(1)->asInt()->evalInt() == 1) : false; |
1859 |
|
|
1860 |
pEngineChannel->ScheduleResumeOfScriptCallback( |
pEngineChannel->ScheduleResumeOfScriptCallback( |
1861 |
itCallback, m_vm->m_event->cause.SchedTime(), disableWaitForever |
itCallback, m_vm->m_event->scheduleTime, disableWaitForever |
1862 |
); |
); |
1863 |
|
|
1864 |
return successResult(); |
return successResult(); |