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(); |
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 |
389 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
390 |
if (relative) |
if (relative) |
391 |
pNote->Override.Volume *= fVolumeLin; |
pNote->Override.Volume *= fVolumeLin; |
392 |
else |
else |
413 |
|
|
414 |
// if change_vol() was called immediately after note was triggered |
// if change_vol() was called immediately after note was triggered |
415 |
// then immediately apply the volume to Note object |
// then immediately apply the volume to Note object |
416 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
417 |
if (relative) |
if (relative) |
418 |
pNote->Override.Volume *= fVolumeLin; |
pNote->Override.Volume *= fVolumeLin; |
419 |
else |
else |
473 |
|
|
474 |
// if change_tune() was called immediately after note was triggered |
// if change_tune() was called immediately after note was triggered |
475 |
// then immediately apply the tuning to Note object |
// then immediately apply the tuning to Note object |
476 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
477 |
if (relative) |
if (relative) |
478 |
pNote->Override.Pitch *= fFreqRatio; |
pNote->Override.Pitch *= fFreqRatio; |
479 |
else |
else |
500 |
|
|
501 |
// if change_tune() was called immediately after note was triggered |
// if change_tune() was called immediately after note was triggered |
502 |
// then immediately apply the tuning to Note object |
// then immediately apply the tuning to Note object |
503 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
504 |
if (relative) |
if (relative) |
505 |
pNote->Override.Pitch *= fFreqRatio; |
pNote->Override.Pitch *= fFreqRatio; |
506 |
else |
else |
568 |
|
|
569 |
// if change_pan() was called immediately after note was triggered |
// if change_pan() was called immediately after note was triggered |
570 |
// then immediately apply the panning to Note object |
// then immediately apply the panning to Note object |
571 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
572 |
if (relative) { |
if (relative) { |
573 |
pNote->Override.Pan = RTMath::RelativeSummedAvg(pNote->Override.Pan, fPan, ++pNote->Override.PanSources); |
pNote->Override.Pan = RTMath::RelativeSummedAvg(pNote->Override.Pan, fPan, ++pNote->Override.PanSources); |
574 |
} else { |
} else { |
597 |
|
|
598 |
// if change_pan() was called immediately after note was triggered |
// if change_pan() was called immediately after note was triggered |
599 |
// then immediately apply the panning to Note object |
// then immediately apply the panning to Note object |
600 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
601 |
if (relative) { |
if (relative) { |
602 |
pNote->Override.Pan = RTMath::RelativeSummedAvg(pNote->Override.Pan, fPan, ++pNote->Override.PanSources); |
pNote->Override.Pan = RTMath::RelativeSummedAvg(pNote->Override.Pan, fPan, ++pNote->Override.PanSources); |
603 |
} else { |
} else { |
668 |
|
|
669 |
// if change_cutoff() was called immediately after note was triggered |
// if change_cutoff() was called immediately after note was triggered |
670 |
// then immediately apply cutoff to Note object |
// then immediately apply cutoff to Note object |
671 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
672 |
pNote->Override.Cutoff = fCutoff; |
pNote->Override.Cutoff = fCutoff; |
673 |
} else { // otherwise schedule cutoff change ... |
} else { // otherwise schedule cutoff change ... |
674 |
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" |
692 |
|
|
693 |
// if change_cutoff() was called immediately after note was triggered |
// if change_cutoff() was called immediately after note was triggered |
694 |
// then immediately apply cutoff to Note object |
// then immediately apply cutoff to Note object |
695 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
696 |
pNote->Override.Cutoff = fCutoff; |
pNote->Override.Cutoff = fCutoff; |
697 |
} else { // otherwise schedule cutoff change ... |
} else { // otherwise schedule cutoff change ... |
698 |
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" |
755 |
|
|
756 |
// if change_reso() was called immediately after note was triggered |
// if change_reso() was called immediately after note was triggered |
757 |
// then immediately apply resonance to Note object |
// then immediately apply resonance to Note object |
758 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
759 |
pNote->Override.Resonance = fResonance; |
pNote->Override.Resonance = fResonance; |
760 |
} else { // otherwise schedule resonance change ... |
} else { // otherwise schedule resonance change ... |
761 |
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" |
779 |
|
|
780 |
// if change_reso() was called immediately after note was triggered |
// if change_reso() was called immediately after note was triggered |
781 |
// then immediately apply resonance to Note object |
// then immediately apply resonance to Note object |
782 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
783 |
pNote->Override.Resonance = fResonance; |
pNote->Override.Resonance = fResonance; |
784 |
} else { // otherwise schedule resonance change ... |
} else { // otherwise schedule resonance change ... |
785 |
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" |
842 |
|
|
843 |
// if change_attack() was called immediately after note was triggered |
// if change_attack() was called immediately after note was triggered |
844 |
// then immediately apply attack to Note object |
// then immediately apply attack to Note object |
845 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
846 |
pNote->Override.Attack = fAttack; |
pNote->Override.Attack = fAttack; |
847 |
} else { // otherwise schedule attack change ... |
} else { // otherwise schedule attack change ... |
848 |
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" |
866 |
|
|
867 |
// if change_attack() was called immediately after note was triggered |
// if change_attack() was called immediately after note was triggered |
868 |
// then immediately apply attack to Note object |
// then immediately apply attack to Note object |
869 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
870 |
pNote->Override.Attack = fAttack; |
pNote->Override.Attack = fAttack; |
871 |
} else { // otherwise schedule attack change ... |
} else { // otherwise schedule attack change ... |
872 |
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" |
929 |
|
|
930 |
// if change_decay() was called immediately after note was triggered |
// if change_decay() was called immediately after note was triggered |
931 |
// then immediately apply decay to Note object |
// then immediately apply decay to Note object |
932 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
933 |
pNote->Override.Decay = fDecay; |
pNote->Override.Decay = fDecay; |
934 |
} else { // otherwise schedule decay change ... |
} else { // otherwise schedule decay change ... |
935 |
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" |
953 |
|
|
954 |
// if change_decay() was called immediately after note was triggered |
// if change_decay() was called immediately after note was triggered |
955 |
// then immediately apply decay to Note object |
// then immediately apply decay to Note object |
956 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
957 |
pNote->Override.Decay = fDecay; |
pNote->Override.Decay = fDecay; |
958 |
} else { // otherwise schedule decay change ... |
} else { // otherwise schedule decay change ... |
959 |
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" |
1016 |
|
|
1017 |
// if change_release() was called immediately after note was triggered |
// if change_release() was called immediately after note was triggered |
1018 |
// then immediately apply relase to Note object |
// then immediately apply relase to Note object |
1019 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1020 |
pNote->Override.Release = fRelease; |
pNote->Override.Release = fRelease; |
1021 |
} else { // otherwise schedule release change ... |
} else { // otherwise schedule release change ... |
1022 |
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" |
1040 |
|
|
1041 |
// if change_release() was called immediately after note was triggered |
// if change_release() was called immediately after note was triggered |
1042 |
// then immediately apply relase to Note object |
// then immediately apply relase to Note object |
1043 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1044 |
pNote->Override.Release = fRelease; |
pNote->Override.Release = fRelease; |
1045 |
} else { // otherwise schedule release change ... |
} else { // otherwise schedule release change ... |
1046 |
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" |
1066 |
return type == INT_EXPR; |
return type == INT_EXPR; |
1067 |
} |
} |
1068 |
|
|
1069 |
|
// Arbitrarily chosen constant value symbolizing "no limit". |
1070 |
|
#define NO_LIMIT 1315916909 |
1071 |
|
|
1072 |
template<float NoteBase::_Override::*T_noteParam, int T_synthParam, |
template<float NoteBase::_Override::*T_noteParam, int T_synthParam, |
1073 |
bool T_isNormalizedParam, int T_maxValue, int T_minValue> |
bool T_isNormalizedParam, int T_maxValue, int T_minValue> |
1074 |
VMFnResult* VMChangeSynthParamFunction::execTemplate(VMFnArgs* args, const char* functionName) { |
VMFnResult* VMChangeSynthParamFunction::execTemplate(VMFnArgs* args, const char* functionName) { |
1075 |
int value = args->arg(1)->asInt()->evalInt(); |
int value = args->arg(1)->asInt()->evalInt(); |
1076 |
if (value > T_maxValue) { |
if (T_maxValue != NO_LIMIT && value > T_maxValue) { |
1077 |
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)); |
1078 |
value = T_maxValue; |
value = T_maxValue; |
1079 |
} else if (value < T_minValue) { |
} else if (T_minValue != NO_LIMIT && value < T_minValue) { |
1080 |
if (T_minValue == 0) |
if (T_minValue == 0) |
1081 |
wrnMsg(String(functionName) + "(): argument 2 may not be negative"); |
wrnMsg(String(functionName) + "(): argument 2 may not be negative"); |
1082 |
else |
else |
1107 |
// if this change_*() script function was called immediately after |
// if this change_*() script function was called immediately after |
1108 |
// note was triggered then immediately apply the synth parameter |
// note was triggered then immediately apply the synth parameter |
1109 |
// change to Note object |
// change to Note object |
1110 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1111 |
pNote->Override.*T_noteParam = fValue; |
pNote->Override.*T_noteParam = fValue; |
1112 |
} else { // otherwise schedule this synth parameter change ... |
} else { // otherwise schedule this synth parameter change ... |
1113 |
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" |
1132 |
// if this change_*() script function was called immediately after |
// if this change_*() script function was called immediately after |
1133 |
// note was triggered then immediately apply the synth parameter |
// note was triggered then immediately apply the synth parameter |
1134 |
// change to Note object |
// change to Note object |
1135 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1136 |
pNote->Override.*T_noteParam = fValue; |
pNote->Override.*T_noteParam = fValue; |
1137 |
} else { // otherwise schedule this synth parameter change ... |
} else { // otherwise schedule this synth parameter change ... |
1138 |
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" |
1156 |
VMFnResult* InstrumentScriptVMFunction_change_amp_lfo_depth::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_amp_lfo_depth::exec(VMFnArgs* args) { |
1157 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1158 |
&NoteBase::_Override::AmpLFODepth, |
&NoteBase::_Override::AmpLFODepth, |
1159 |
Event::synth_param_amp_lfo_depth, true>( args, "change_amp_lfo_depth" ); |
Event::synth_param_amp_lfo_depth, |
1160 |
|
true, 1000000, 0>( args, "change_amp_lfo_depth" ); |
1161 |
} |
} |
1162 |
|
|
1163 |
// change_amp_lfo_freq() function |
// change_amp_lfo_freq() function |
1165 |
VMFnResult* InstrumentScriptVMFunction_change_amp_lfo_freq::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_amp_lfo_freq::exec(VMFnArgs* args) { |
1166 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1167 |
&NoteBase::_Override::AmpLFOFreq, |
&NoteBase::_Override::AmpLFOFreq, |
1168 |
Event::synth_param_amp_lfo_freq, true>( args, "change_amp_lfo_freq" ); |
Event::synth_param_amp_lfo_freq, |
1169 |
|
true, 1000000, 0>( args, "change_amp_lfo_freq" ); |
1170 |
} |
} |
1171 |
|
|
1172 |
// change_pitch_lfo_depth() function |
// change_pitch_lfo_depth() function |
1174 |
VMFnResult* InstrumentScriptVMFunction_change_pitch_lfo_depth::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_pitch_lfo_depth::exec(VMFnArgs* args) { |
1175 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1176 |
&NoteBase::_Override::PitchLFODepth, |
&NoteBase::_Override::PitchLFODepth, |
1177 |
Event::synth_param_pitch_lfo_depth, true>( args, "change_pitch_lfo_depth" ); |
Event::synth_param_pitch_lfo_depth, |
1178 |
|
true, 1000000, 0>( args, "change_pitch_lfo_depth" ); |
1179 |
} |
} |
1180 |
|
|
1181 |
// change_pitch_lfo_freq() function |
// change_pitch_lfo_freq() function |
1183 |
VMFnResult* InstrumentScriptVMFunction_change_pitch_lfo_freq::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_pitch_lfo_freq::exec(VMFnArgs* args) { |
1184 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1185 |
&NoteBase::_Override::PitchLFOFreq, |
&NoteBase::_Override::PitchLFOFreq, |
1186 |
Event::synth_param_pitch_lfo_freq, true>( args, "change_pitch_lfo_freq" ); |
Event::synth_param_pitch_lfo_freq, |
1187 |
|
true, 1000000, 0>( args, "change_pitch_lfo_freq" ); |
1188 |
} |
} |
1189 |
|
|
1190 |
// change_vol_time() function |
// change_vol_time() function |
1192 |
VMFnResult* InstrumentScriptVMFunction_change_vol_time::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_vol_time::exec(VMFnArgs* args) { |
1193 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1194 |
&NoteBase::_Override::VolumeTime, |
&NoteBase::_Override::VolumeTime, |
1195 |
Event::synth_param_volume_time, false>( args, "change_vol_time" ); |
Event::synth_param_volume_time, |
1196 |
|
false, NO_LIMIT, 0>( args, "change_vol_time" ); |
1197 |
} |
} |
1198 |
|
|
1199 |
// change_tune_time() function |
// change_tune_time() function |
1201 |
VMFnResult* InstrumentScriptVMFunction_change_tune_time::exec(VMFnArgs* args) { |
VMFnResult* InstrumentScriptVMFunction_change_tune_time::exec(VMFnArgs* args) { |
1202 |
return VMChangeSynthParamFunction::execTemplate< |
return VMChangeSynthParamFunction::execTemplate< |
1203 |
&NoteBase::_Override::PitchTime, |
&NoteBase::_Override::PitchTime, |
1204 |
Event::synth_param_pitch_time, false>( args, "change_tune_time" ); |
Event::synth_param_pitch_time, |
1205 |
|
false, NO_LIMIT, 0>( args, "change_tune_time" ); |
1206 |
} |
} |
1207 |
|
|
1208 |
// fade_in() function |
// fade_in() function |
1247 |
// if fade_in() was called immediately after note was triggered |
// if fade_in() was called immediately after note was triggered |
1248 |
// then immediately apply a start volume of zero to Note object, |
// then immediately apply a start volume of zero to Note object, |
1249 |
// as well as the fade in duration |
// as well as the fade in duration |
1250 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1251 |
pNote->Override.Volume = 0.f; |
pNote->Override.Volume = 0.f; |
1252 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1253 |
} 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 ... |
1289 |
// if fade_in() was called immediately after note was triggered |
// if fade_in() was called immediately after note was triggered |
1290 |
// then immediately apply a start volume of zero to Note object, |
// then immediately apply a start volume of zero to Note object, |
1291 |
// as well as the fade in duration |
// as well as the fade in duration |
1292 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1293 |
pNote->Override.Volume = 0.f; |
pNote->Override.Volume = 0.f; |
1294 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1295 |
} 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 ... |
1368 |
|
|
1369 |
// if fade_out() was called immediately after note was triggered |
// if fade_out() was called immediately after note was triggered |
1370 |
// then immediately apply fade out duration to Note object |
// then immediately apply fade out duration to Note object |
1371 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1372 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1373 |
} 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 ... |
1374 |
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" |
1420 |
|
|
1421 |
// if fade_out() was called immediately after note was triggered |
// if fade_out() was called immediately after note was triggered |
1422 |
// then immediately apply fade out duration to Note object |
// then immediately apply fade out duration to Note object |
1423 |
if (m_vm->m_event->cause.SchedTime() == pNote->triggerSchedTime) { |
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1424 |
pNote->Override.VolumeTime = fDuration; |
pNote->Override.VolumeTime = fDuration; |
1425 |
} 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 ... |
1426 |
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" |
1467 |
return successResult(); |
return successResult(); |
1468 |
} |
} |
1469 |
|
|
1470 |
|
// get_event_par() function |
1471 |
|
|
1472 |
|
InstrumentScriptVMFunction_get_event_par::InstrumentScriptVMFunction_get_event_par(InstrumentScriptVM* parent) |
1473 |
|
: m_vm(parent) |
1474 |
|
{ |
1475 |
|
} |
1476 |
|
|
1477 |
|
VMFnResult* InstrumentScriptVMFunction_get_event_par::exec(VMFnArgs* args) { |
1478 |
|
AbstractEngineChannel* pEngineChannel = |
1479 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1480 |
|
|
1481 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1482 |
|
if (!id) { |
1483 |
|
wrnMsg("get_event_par(): note ID for argument 1 may not be zero"); |
1484 |
|
return successResult(0); |
1485 |
|
} |
1486 |
|
if (!id.isNoteID()) { |
1487 |
|
wrnMsg("get_event_par(): argument 1 is not a note ID"); |
1488 |
|
return successResult(0); |
1489 |
|
} |
1490 |
|
|
1491 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1492 |
|
if (!pNote) { |
1493 |
|
wrnMsg("get_event_par(): no note alive with that note ID of argument 1"); |
1494 |
|
return successResult(0); |
1495 |
|
} |
1496 |
|
|
1497 |
|
const int parameter = args->arg(1)->asInt()->evalInt(); |
1498 |
|
switch (parameter) { |
1499 |
|
case EVENT_PAR_NOTE: |
1500 |
|
return successResult(pNote->cause.Param.Note.Key); |
1501 |
|
case EVENT_PAR_VELOCITY: |
1502 |
|
return successResult(pNote->cause.Param.Note.Velocity); |
1503 |
|
case EVENT_PAR_VOLUME: |
1504 |
|
return successResult( |
1505 |
|
RTMath::LinRatioToDecibel(pNote->Override.Volume) * 1000.f |
1506 |
|
); |
1507 |
|
case EVENT_PAR_TUNE: |
1508 |
|
return successResult( |
1509 |
|
RTMath::FreqRatioToCents(pNote->Override.Pitch) * 1000.f |
1510 |
|
); |
1511 |
|
case EVENT_PAR_0: |
1512 |
|
return successResult(pNote->userPar[0]); |
1513 |
|
case EVENT_PAR_1: |
1514 |
|
return successResult(pNote->userPar[1]); |
1515 |
|
case EVENT_PAR_2: |
1516 |
|
return successResult(pNote->userPar[2]); |
1517 |
|
case EVENT_PAR_3: |
1518 |
|
return successResult(pNote->userPar[3]); |
1519 |
|
} |
1520 |
|
|
1521 |
|
wrnMsg("get_event_par(): argument 2 is an invalid event parameter"); |
1522 |
|
return successResult(0); |
1523 |
|
} |
1524 |
|
|
1525 |
|
// set_event_par() function |
1526 |
|
|
1527 |
|
InstrumentScriptVMFunction_set_event_par::InstrumentScriptVMFunction_set_event_par(InstrumentScriptVM* parent) |
1528 |
|
: m_vm(parent) |
1529 |
|
{ |
1530 |
|
} |
1531 |
|
|
1532 |
|
VMFnResult* InstrumentScriptVMFunction_set_event_par::exec(VMFnArgs* args) { |
1533 |
|
AbstractEngineChannel* pEngineChannel = |
1534 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1535 |
|
|
1536 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1537 |
|
if (!id) { |
1538 |
|
wrnMsg("set_event_par(): note ID for argument 1 may not be zero"); |
1539 |
|
return successResult(); |
1540 |
|
} |
1541 |
|
if (!id.isNoteID()) { |
1542 |
|
wrnMsg("set_event_par(): argument 1 is not a note ID"); |
1543 |
|
return successResult(); |
1544 |
|
} |
1545 |
|
|
1546 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1547 |
|
if (!pNote) return successResult(); |
1548 |
|
|
1549 |
|
const int parameter = args->arg(1)->asInt()->evalInt(); |
1550 |
|
const int value = args->arg(2)->asInt()->evalInt(); |
1551 |
|
|
1552 |
|
switch (parameter) { |
1553 |
|
case EVENT_PAR_NOTE: |
1554 |
|
if (value < 0 || value > 127) { |
1555 |
|
wrnMsg("set_event_par(): note number of argument 3 is out of range"); |
1556 |
|
return successResult(); |
1557 |
|
} |
1558 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1559 |
|
pNote->cause.Param.Note.Key = value; |
1560 |
|
m_vm->m_event->cause.Param.Note.Key = value; |
1561 |
|
} else { |
1562 |
|
wrnMsg("set_event_par(): note number can only be changed when note is new"); |
1563 |
|
} |
1564 |
|
return successResult(); |
1565 |
|
case EVENT_PAR_VELOCITY: |
1566 |
|
if (value < 0 || value > 127) { |
1567 |
|
wrnMsg("set_event_par(): velocity 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.Velocity = value; |
1572 |
|
m_vm->m_event->cause.Param.Note.Velocity = value; |
1573 |
|
} else { |
1574 |
|
wrnMsg("set_event_par(): velocity can only be changed when note is new"); |
1575 |
|
} |
1576 |
|
return successResult(); |
1577 |
|
case EVENT_PAR_VOLUME: |
1578 |
|
wrnMsg("set_event_par(): changing volume by this function is currently not supported, use change_vol() instead"); |
1579 |
|
return successResult(); |
1580 |
|
case EVENT_PAR_TUNE: |
1581 |
|
wrnMsg("set_event_par(): changing tune by this function is currently not supported, use change_tune() instead"); |
1582 |
|
return successResult(); |
1583 |
|
case EVENT_PAR_0: |
1584 |
|
pNote->userPar[0] = value; |
1585 |
|
return successResult(); |
1586 |
|
case EVENT_PAR_1: |
1587 |
|
pNote->userPar[1] = value; |
1588 |
|
return successResult(); |
1589 |
|
case EVENT_PAR_2: |
1590 |
|
pNote->userPar[2] = value; |
1591 |
|
return successResult(); |
1592 |
|
case EVENT_PAR_3: |
1593 |
|
pNote->userPar[3] = value; |
1594 |
|
return successResult(); |
1595 |
|
} |
1596 |
|
|
1597 |
|
wrnMsg("set_event_par(): argument 2 is an invalid event parameter"); |
1598 |
|
return successResult(); |
1599 |
|
} |
1600 |
|
|
1601 |
|
// change_note() function |
1602 |
|
|
1603 |
|
InstrumentScriptVMFunction_change_note::InstrumentScriptVMFunction_change_note(InstrumentScriptVM* parent) |
1604 |
|
: m_vm(parent) |
1605 |
|
{ |
1606 |
|
} |
1607 |
|
|
1608 |
|
VMFnResult* InstrumentScriptVMFunction_change_note::exec(VMFnArgs* args) { |
1609 |
|
AbstractEngineChannel* pEngineChannel = |
1610 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1611 |
|
|
1612 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1613 |
|
if (!id) { |
1614 |
|
wrnMsg("change_note(): note ID for argument 1 may not be zero"); |
1615 |
|
return successResult(); |
1616 |
|
} |
1617 |
|
if (!id.isNoteID()) { |
1618 |
|
wrnMsg("change_note(): argument 1 is not a note ID"); |
1619 |
|
return successResult(); |
1620 |
|
} |
1621 |
|
|
1622 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1623 |
|
if (!pNote) return successResult(); |
1624 |
|
|
1625 |
|
const int value = args->arg(1)->asInt()->evalInt(); |
1626 |
|
if (value < 0 || value > 127) { |
1627 |
|
wrnMsg("change_note(): note number of argument 2 is out of range"); |
1628 |
|
return successResult(); |
1629 |
|
} |
1630 |
|
|
1631 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1632 |
|
pNote->cause.Param.Note.Key = value; |
1633 |
|
m_vm->m_event->cause.Param.Note.Key = value; |
1634 |
|
} else { |
1635 |
|
wrnMsg("change_note(): note number can only be changed when note is new"); |
1636 |
|
} |
1637 |
|
|
1638 |
|
return successResult(); |
1639 |
|
} |
1640 |
|
|
1641 |
|
// change_velo() function |
1642 |
|
|
1643 |
|
InstrumentScriptVMFunction_change_velo::InstrumentScriptVMFunction_change_velo(InstrumentScriptVM* parent) |
1644 |
|
: m_vm(parent) |
1645 |
|
{ |
1646 |
|
} |
1647 |
|
|
1648 |
|
VMFnResult* InstrumentScriptVMFunction_change_velo::exec(VMFnArgs* args) { |
1649 |
|
AbstractEngineChannel* pEngineChannel = |
1650 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1651 |
|
|
1652 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1653 |
|
if (!id) { |
1654 |
|
wrnMsg("change_velo(): note ID for argument 1 may not be zero"); |
1655 |
|
return successResult(); |
1656 |
|
} |
1657 |
|
if (!id.isNoteID()) { |
1658 |
|
wrnMsg("change_velo(): argument 1 is not a note ID"); |
1659 |
|
return successResult(); |
1660 |
|
} |
1661 |
|
|
1662 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1663 |
|
if (!pNote) return successResult(); |
1664 |
|
|
1665 |
|
const int value = args->arg(1)->asInt()->evalInt(); |
1666 |
|
if (value < 0 || value > 127) { |
1667 |
|
wrnMsg("change_velo(): velocity of argument 2 is out of range"); |
1668 |
|
return successResult(); |
1669 |
|
} |
1670 |
|
|
1671 |
|
if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) { |
1672 |
|
pNote->cause.Param.Note.Velocity = value; |
1673 |
|
m_vm->m_event->cause.Param.Note.Velocity = value; |
1674 |
|
} else { |
1675 |
|
wrnMsg("change_velo(): velocity can only be changed when note is new"); |
1676 |
|
} |
1677 |
|
|
1678 |
|
return successResult(); |
1679 |
|
} |
1680 |
|
|
1681 |
// event_status() function |
// event_status() function |
1682 |
|
|
1683 |
InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent) |
InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent) |
1743 |
(args->argsCount() >= 2) ? (args->arg(1)->asInt()->evalInt() == 1) : false; |
(args->argsCount() >= 2) ? (args->arg(1)->asInt()->evalInt() == 1) : false; |
1744 |
|
|
1745 |
pEngineChannel->ScheduleResumeOfScriptCallback( |
pEngineChannel->ScheduleResumeOfScriptCallback( |
1746 |
itCallback, m_vm->m_event->cause.SchedTime(), disableWaitForever |
itCallback, m_vm->m_event->scheduleTime, disableWaitForever |
1747 |
); |
); |
1748 |
|
|
1749 |
return successResult(); |
return successResult(); |