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" |
1078 |
return type == INT_EXPR; |
return type == INT_EXPR; |
1079 |
} |
} |
1080 |
|
|
1081 |
|
// Arbitrarily chosen constant value symbolizing "no limit". |
1082 |
|
#define NO_LIMIT 1315916909 |
1083 |
|
|
1084 |
template<float NoteBase::_Override::*T_noteParam, int T_synthParam, |
template<float NoteBase::_Override::*T_noteParam, int T_synthParam, |
1085 |
bool T_isNormalizedParam, int T_maxValue, int T_minValue> |
bool T_isNormalizedParam, int T_maxValue, int T_minValue> |
1086 |
VMFnResult* VMChangeSynthParamFunction::execTemplate(VMFnArgs* args, const char* functionName) { |
VMFnResult* VMChangeSynthParamFunction::execTemplate(VMFnArgs* args, const char* functionName) { |
1087 |
int value = args->arg(1)->asInt()->evalInt(); |
int value = args->arg(1)->asInt()->evalInt(); |
1088 |
if (value > T_maxValue) { |
if (T_maxValue != NO_LIMIT && value > T_maxValue) { |
1089 |
wrnMsg(String(functionName) + "(): argument 2 may not be larger than " + ToString(T_maxValue)); |
wrnMsg(String(functionName) + "(): argument 2 may not be larger than " + ToString(T_maxValue)); |
1090 |
value = T_maxValue; |
value = T_maxValue; |
1091 |
} else if (value < T_minValue) { |
} else if (T_minValue != NO_LIMIT && value < T_minValue) { |
1092 |
if (T_minValue == 0) |
if (T_minValue == 0) |
1093 |
wrnMsg(String(functionName) + "(): argument 2 may not be negative"); |
wrnMsg(String(functionName) + "(): argument 2 may not be negative"); |
1094 |
else |
else |
1119 |
// if this change_*() script function was called immediately after |
// if this change_*() script function was called immediately after |
1120 |
// note was triggered then immediately apply the synth parameter |
// note was triggered then immediately apply the synth parameter |
1121 |
// change to Note object |
// change to Note object |
1122 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1123 |
pNote->Override.*T_noteParam = fValue; |
pNote->Override.*T_noteParam = fValue; |
1124 |
} else { // otherwise schedule this synth parameter change ... |
} else { // otherwise schedule this synth parameter change ... |
1125 |
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" |
1144 |
// if this change_*() script function was called immediately after |
// if this change_*() script function was called immediately after |
1145 |
// note was triggered then immediately apply the synth parameter |
// note was triggered then immediately apply the synth parameter |
1146 |
// change to Note object |
// change to Note object |
1147 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1148 |
pNote->Override.*T_noteParam = fValue; |
pNote->Override.*T_noteParam = fValue; |
1149 |
} else { // otherwise schedule this synth parameter change ... |
} else { // otherwise schedule this synth parameter change ... |
1150 |
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" |
1168 |
VMFnResult* InstrumentScriptVMFunction_change_amp_lfo_depth::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_amp_lfo_depth::exec(VMFnArgs* args) { |
1169 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1170 |
&NoteBase::_Override::AmpLFODepth, |
&NoteBase::_Override::AmpLFODepth, |
1171 |
Event::synth_param_amp_lfo_depth, true>( args, "change_amp_lfo_depth" ); |
Event::synth_param_amp_lfo_depth, |
1172 |
|
true, 1000000, 0>( args, "change_amp_lfo_depth" ); |
1173 |
} |
} |
1174 |
|
|
1175 |
// change_amp_lfo_freq() function |
// change_amp_lfo_freq() function |
1177 |
VMFnResult* InstrumentScriptVMFunction_change_amp_lfo_freq::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_amp_lfo_freq::exec(VMFnArgs* args) { |
1178 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1179 |
&NoteBase::_Override::AmpLFOFreq, |
&NoteBase::_Override::AmpLFOFreq, |
1180 |
Event::synth_param_amp_lfo_freq, true>( args, "change_amp_lfo_freq" ); |
Event::synth_param_amp_lfo_freq, |
1181 |
|
true, 1000000, 0>( args, "change_amp_lfo_freq" ); |
1182 |
} |
} |
1183 |
|
|
1184 |
// change_pitch_lfo_depth() function |
// change_pitch_lfo_depth() function |
1186 |
VMFnResult* InstrumentScriptVMFunction_change_pitch_lfo_depth::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_pitch_lfo_depth::exec(VMFnArgs* args) { |
1187 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1188 |
&NoteBase::_Override::PitchLFODepth, |
&NoteBase::_Override::PitchLFODepth, |
1189 |
Event::synth_param_pitch_lfo_depth, true>( args, "change_pitch_lfo_depth" ); |
Event::synth_param_pitch_lfo_depth, |
1190 |
|
true, 1000000, 0>( args, "change_pitch_lfo_depth" ); |
1191 |
} |
} |
1192 |
|
|
1193 |
// change_pitch_lfo_freq() function |
// change_pitch_lfo_freq() function |
1195 |
VMFnResult* InstrumentScriptVMFunction_change_pitch_lfo_freq::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_pitch_lfo_freq::exec(VMFnArgs* args) { |
1196 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1197 |
&NoteBase::_Override::PitchLFOFreq, |
&NoteBase::_Override::PitchLFOFreq, |
1198 |
Event::synth_param_pitch_lfo_freq, true>( args, "change_pitch_lfo_freq" ); |
Event::synth_param_pitch_lfo_freq, |
1199 |
|
true, 1000000, 0>( args, "change_pitch_lfo_freq" ); |
1200 |
} |
} |
1201 |
|
|
1202 |
// change_vol_time() function |
// change_vol_time() function |
1204 |
VMFnResult* InstrumentScriptVMFunction_change_vol_time::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_vol_time::exec(VMFnArgs* args) { |
1205 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1206 |
&NoteBase::_Override::VolumeTime, |
&NoteBase::_Override::VolumeTime, |
1207 |
Event::synth_param_volume_time, false>( args, "change_vol_time" ); |
Event::synth_param_volume_time, |
1208 |
|
false, NO_LIMIT, 0>( args, "change_vol_time" ); |
1209 |
} |
} |
1210 |
|
|
1211 |
// change_tune_time() function |
// change_tune_time() function |
1213 |
VMFnResult* InstrumentScriptVMFunction_change_tune_time::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_tune_time::exec(VMFnArgs* args) { |
1214 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1215 |
&NoteBase::_Override::PitchTime, |
&NoteBase::_Override::PitchTime, |
1216 |
Event::synth_param_pitch_time, false>( args, "change_tune_time" ); |
Event::synth_param_pitch_time, |
1217 |
|
false, NO_LIMIT, 0>( args, "change_tune_time" ); |
1218 |
} |
} |
1219 |
|
|
1220 |
// fade_in() function |
// fade_in() function |
1259 |
// if fade_in() was called immediately after note was triggered |
// if fade_in() was called immediately after note was triggered |
1260 |
// then immediately apply a start volume of zero to Note object, |
// then immediately apply a start volume of zero to Note object, |
1261 |
// as well as the fade in duration |
// as well as the fade in duration |
1262 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1263 |
pNote->Override.Volume = 0.f; |
pNote->Override.Volume = 0.f; |
1264 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1265 |
} 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 ... |
1301 |
// if fade_in() was called immediately after note was triggered |
// if fade_in() was called immediately after note was triggered |
1302 |
// then immediately apply a start volume of zero to Note object, |
// then immediately apply a start volume of zero to Note object, |
1303 |
// as well as the fade in duration |
// as well as the fade in duration |
1304 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1305 |
pNote->Override.Volume = 0.f; |
pNote->Override.Volume = 0.f; |
1306 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1307 |
} 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 ... |
1380 |
|
|
1381 |
// if fade_out() was called immediately after note was triggered |
// if fade_out() was called immediately after note was triggered |
1382 |
// then immediately apply fade out duration to Note object |
// then immediately apply fade out duration to Note object |
1383 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1384 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1385 |
} 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 ... |
1386 |
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" |
1432 |
|
|
1433 |
// if fade_out() was called immediately after note was triggered |
// if fade_out() was called immediately after note was triggered |
1434 |
// then immediately apply fade out duration to Note object |
// then immediately apply fade out duration to Note object |
1435 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1436 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1437 |
} 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 ... |
1438 |
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" |
1479 |
return successResult(); |
return successResult(); |
1480 |
} |
} |
1481 |
|
|
1482 |
|
// get_event_par() function |
1483 |
|
|
1484 |
|
InstrumentScriptVMFunction_get_event_par::InstrumentScriptVMFunction_get_event_par(InstrumentScriptVM* parent) |
1485 |
|
: m_vm(parent) |
1486 |
|
{ |
1487 |
|
} |
1488 |
|
|
1489 |
|
VMFnResult* InstrumentScriptVMFunction_get_event_par::exec(VMFnArgs* args) { |
1490 |
|
AbstractEngineChannel* pEngineChannel = |
1491 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1492 |
|
|
1493 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1494 |
|
if (!id) { |
1495 |
|
wrnMsg("get_event_par(): note ID for argument 1 may not be zero"); |
1496 |
|
return successResult(0); |
1497 |
|
} |
1498 |
|
if (!id.isNoteID()) { |
1499 |
|
wrnMsg("get_event_par(): argument 1 is not a note ID"); |
1500 |
|
return successResult(0); |
1501 |
|
} |
1502 |
|
|
1503 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1504 |
|
if (!pNote) { |
1505 |
|
wrnMsg("get_event_par(): no note alive with that note ID of argument 1"); |
1506 |
|
return successResult(0); |
1507 |
|
} |
1508 |
|
|
1509 |
|
const int parameter = args->arg(1)->asInt()->evalInt(); |
1510 |
|
switch (parameter) { |
1511 |
|
case EVENT_PAR_NOTE: |
1512 |
|
return successResult(pNote->cause.Param.Note.Key); |
1513 |
|
case EVENT_PAR_VELOCITY: |
1514 |
|
return successResult(pNote->cause.Param.Note.Velocity); |
1515 |
|
case EVENT_PAR_VOLUME: |
1516 |
|
return successResult( |
1517 |
|
RTMath::LinRatioToDecibel(pNote->Override.Volume) * 1000.f |
1518 |
|
); |
1519 |
|
case EVENT_PAR_TUNE: |
1520 |
|
return successResult( |
1521 |
|
RTMath::FreqRatioToCents(pNote->Override.Pitch) * 1000.f |
1522 |
|
); |
1523 |
|
case EVENT_PAR_0: |
1524 |
|
return successResult(pNote->userPar[0]); |
1525 |
|
case EVENT_PAR_1: |
1526 |
|
return successResult(pNote->userPar[1]); |
1527 |
|
case EVENT_PAR_2: |
1528 |
|
return successResult(pNote->userPar[2]); |
1529 |
|
case EVENT_PAR_3: |
1530 |
|
return successResult(pNote->userPar[3]); |
1531 |
|
} |
1532 |
|
|
1533 |
|
wrnMsg("get_event_par(): argument 2 is an invalid event parameter"); |
1534 |
|
return successResult(0); |
1535 |
|
} |
1536 |
|
|
1537 |
|
// set_event_par() function |
1538 |
|
|
1539 |
|
InstrumentScriptVMFunction_set_event_par::InstrumentScriptVMFunction_set_event_par(InstrumentScriptVM* parent) |
1540 |
|
: m_vm(parent) |
1541 |
|
{ |
1542 |
|
} |
1543 |
|
|
1544 |
|
VMFnResult* InstrumentScriptVMFunction_set_event_par::exec(VMFnArgs* args) { |
1545 |
|
AbstractEngineChannel* pEngineChannel = |
1546 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1547 |
|
|
1548 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1549 |
|
if (!id) { |
1550 |
|
wrnMsg("set_event_par(): note ID for argument 1 may not be zero"); |
1551 |
|
return successResult(); |
1552 |
|
} |
1553 |
|
if (!id.isNoteID()) { |
1554 |
|
wrnMsg("set_event_par(): argument 1 is not a note ID"); |
1555 |
|
return successResult(); |
1556 |
|
} |
1557 |
|
|
1558 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1559 |
|
if (!pNote) return successResult(); |
1560 |
|
|
1561 |
|
const int parameter = args->arg(1)->asInt()->evalInt(); |
1562 |
|
const int value = args->arg(2)->asInt()->evalInt(); |
1563 |
|
|
1564 |
|
switch (parameter) { |
1565 |
|
case EVENT_PAR_NOTE: |
1566 |
|
if (value < 0 || value > 127) { |
1567 |
|
wrnMsg("set_event_par(): note number of argument 3 is out of range"); |
1568 |
|
return successResult(); |
1569 |
|
} |
1570 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1571 |
|
pNote->cause.Param.Note.Key = value; |
1572 |
|
m_vm->m_event->cause.Param.Note.Key = value; |
1573 |
|
} else { |
1574 |
|
wrnMsg("set_event_par(): note number can only be changed when note is new"); |
1575 |
|
} |
1576 |
|
return successResult(); |
1577 |
|
case EVENT_PAR_VELOCITY: |
1578 |
|
if (value < 0 || value > 127) { |
1579 |
|
wrnMsg("set_event_par(): velocity of argument 3 is out of range"); |
1580 |
|
return successResult(); |
1581 |
|
} |
1582 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1583 |
|
pNote->cause.Param.Note.Velocity = value; |
1584 |
|
m_vm->m_event->cause.Param.Note.Velocity = value; |
1585 |
|
} else { |
1586 |
|
wrnMsg("set_event_par(): velocity can only be changed when note is new"); |
1587 |
|
} |
1588 |
|
return successResult(); |
1589 |
|
case EVENT_PAR_VOLUME: |
1590 |
|
wrnMsg("set_event_par(): changing volume by this function is currently not supported, use change_vol() instead"); |
1591 |
|
return successResult(); |
1592 |
|
case EVENT_PAR_TUNE: |
1593 |
|
wrnMsg("set_event_par(): changing tune by this function is currently not supported, use change_tune() instead"); |
1594 |
|
return successResult(); |
1595 |
|
case EVENT_PAR_0: |
1596 |
|
pNote->userPar[0] = value; |
1597 |
|
return successResult(); |
1598 |
|
case EVENT_PAR_1: |
1599 |
|
pNote->userPar[1] = value; |
1600 |
|
return successResult(); |
1601 |
|
case EVENT_PAR_2: |
1602 |
|
pNote->userPar[2] = value; |
1603 |
|
return successResult(); |
1604 |
|
case EVENT_PAR_3: |
1605 |
|
pNote->userPar[3] = value; |
1606 |
|
return successResult(); |
1607 |
|
} |
1608 |
|
|
1609 |
|
wrnMsg("set_event_par(): argument 2 is an invalid event parameter"); |
1610 |
|
return successResult(); |
1611 |
|
} |
1612 |
|
|
1613 |
|
// change_note() function |
1614 |
|
|
1615 |
|
InstrumentScriptVMFunction_change_note::InstrumentScriptVMFunction_change_note(InstrumentScriptVM* parent) |
1616 |
|
: m_vm(parent) |
1617 |
|
{ |
1618 |
|
} |
1619 |
|
|
1620 |
|
VMFnResult* InstrumentScriptVMFunction_change_note::exec(VMFnArgs* args) { |
1621 |
|
AbstractEngineChannel* pEngineChannel = |
1622 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1623 |
|
|
1624 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1625 |
|
if (!id) { |
1626 |
|
wrnMsg("change_note(): note ID for argument 1 may not be zero"); |
1627 |
|
return successResult(); |
1628 |
|
} |
1629 |
|
if (!id.isNoteID()) { |
1630 |
|
wrnMsg("change_note(): argument 1 is not a note ID"); |
1631 |
|
return successResult(); |
1632 |
|
} |
1633 |
|
|
1634 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1635 |
|
if (!pNote) return successResult(); |
1636 |
|
|
1637 |
|
const int value = args->arg(1)->asInt()->evalInt(); |
1638 |
|
if (value < 0 || value > 127) { |
1639 |
|
wrnMsg("change_note(): note number of argument 2 is out of range"); |
1640 |
|
return successResult(); |
1641 |
|
} |
1642 |
|
|
1643 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1644 |
|
pNote->cause.Param.Note.Key = value; |
1645 |
|
m_vm->m_event->cause.Param.Note.Key = value; |
1646 |
|
} else { |
1647 |
|
wrnMsg("change_note(): note number can only be changed when note is new"); |
1648 |
|
} |
1649 |
|
|
1650 |
|
return successResult(); |
1651 |
|
} |
1652 |
|
|
1653 |
|
// change_velo() function |
1654 |
|
|
1655 |
|
InstrumentScriptVMFunction_change_velo::InstrumentScriptVMFunction_change_velo(InstrumentScriptVM* parent) |
1656 |
|
: m_vm(parent) |
1657 |
|
{ |
1658 |
|
} |
1659 |
|
|
1660 |
|
VMFnResult* InstrumentScriptVMFunction_change_velo::exec(VMFnArgs* args) { |
1661 |
|
AbstractEngineChannel* pEngineChannel = |
1662 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1663 |
|
|
1664 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1665 |
|
if (!id) { |
1666 |
|
wrnMsg("change_velo(): note ID for argument 1 may not be zero"); |
1667 |
|
return successResult(); |
1668 |
|
} |
1669 |
|
if (!id.isNoteID()) { |
1670 |
|
wrnMsg("change_velo(): argument 1 is not a note ID"); |
1671 |
|
return successResult(); |
1672 |
|
} |
1673 |
|
|
1674 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1675 |
|
if (!pNote) return successResult(); |
1676 |
|
|
1677 |
|
const int value = args->arg(1)->asInt()->evalInt(); |
1678 |
|
if (value < 0 || value > 127) { |
1679 |
|
wrnMsg("change_velo(): velocity of argument 2 is out of range"); |
1680 |
|
return successResult(); |
1681 |
|
} |
1682 |
|
|
1683 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1684 |
|
pNote->cause.Param.Note.Velocity = value; |
1685 |
|
m_vm->m_event->cause.Param.Note.Velocity = value; |
1686 |
|
} else { |
1687 |
|
wrnMsg("change_velo(): velocity can only be changed when note is new"); |
1688 |
|
} |
1689 |
|
|
1690 |
|
return successResult(); |
1691 |
|
} |
1692 |
|
|
1693 |
// event_status() function |
// event_status() function |
1694 |
|
|
1695 |
InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent) |
InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent) |
1755 |
(args->argsCount() >= 2) ? (args->arg(1)->asInt()->evalInt() == 1) : false; |
(args->argsCount() >= 2) ? (args->arg(1)->asInt()->evalInt() == 1) : false; |
1756 |
|
|
1757 |
pEngineChannel->ScheduleResumeOfScriptCallback( |
pEngineChannel->ScheduleResumeOfScriptCallback( |
1758 |
itCallback, m_vm->m_event->cause.SchedTime(), disableWaitForever |
itCallback, m_vm->m_event->scheduleTime, disableWaitForever |
1759 |
); |
); |
1760 |
|
|
1761 |
return successResult(); |
return successResult(); |