379 |
} |
} |
380 |
pVoicePool->clear(); |
pVoicePool->clear(); |
381 |
|
|
382 |
// (re)create event generator |
// update event generator |
383 |
if (pEventGenerator) delete pEventGenerator; |
pEventGenerator->SetSampleRate(pAudioOut->SampleRate()); |
|
pEventGenerator = new EventGenerator(pAudioOut->SampleRate()); |
|
384 |
|
|
385 |
dmsg(1,("Starting disk thread...")); |
dmsg(1,("Starting disk thread...")); |
386 |
pDiskThread->StartThread(); |
pDiskThread->StartThread(); |
983 |
// script event object |
// script event object |
984 |
RTList<ScriptEvent>::Iterator itScriptEvent = |
RTList<ScriptEvent>::Iterator itScriptEvent = |
985 |
pChannel->pScript->pEvents->allocAppend(); |
pChannel->pScript->pEvents->allocAppend(); |
986 |
|
// if event handler uses polyphonic variables, reset them |
987 |
|
// to zero values before starting to execute the handler |
988 |
|
if (pEventHandler->isPolyphonic()) |
989 |
|
itScriptEvent->execCtx->resetPolyphonicData(); |
990 |
ProcessScriptEvent( |
ProcessScriptEvent( |
991 |
pChannel, itEvent, pEventHandler, itScriptEvent |
pChannel, itEvent, pEventHandler, itScriptEvent |
992 |
); |
); |
1024 |
itScriptEvent->executionSlices = 0; |
itScriptEvent->executionSlices = 0; |
1025 |
itScriptEvent->ignoreAllWaitCalls = false; |
itScriptEvent->ignoreAllWaitCalls = false; |
1026 |
itScriptEvent->handlerType = pEventHandler->eventHandlerType(); |
itScriptEvent->handlerType = pEventHandler->eventHandlerType(); |
1027 |
|
itScriptEvent->parentHandlerID = 0; |
1028 |
|
itScriptEvent->childHandlerID[0] = 0; |
1029 |
|
itScriptEvent->autoAbortByParent = false; |
1030 |
|
itScriptEvent->forkIndex = 0; |
1031 |
// this is the native representation of the $EVENT_ID script variable |
// this is the native representation of the $EVENT_ID script variable |
1032 |
itScriptEvent->id = |
itScriptEvent->id = |
1033 |
(itEvent->Type == Event::type_note_on) |
(itEvent->Type == Event::type_note_on) |
1299 |
RTList<ScriptEvent>::Iterator itScriptEvent = |
RTList<ScriptEvent>::Iterator itScriptEvent = |
1300 |
pEngineChannel->pScript->pEvents->allocAppend(); |
pEngineChannel->pScript->pEvents->allocAppend(); |
1301 |
|
|
1302 |
|
itScriptEvent->cause = pEventGenerator->CreateEvent(0); |
1303 |
|
itScriptEvent->cause.Type = (Event::type_t) -1; // some invalid type to avoid random event processing |
1304 |
itScriptEvent->cause.pEngineChannel = pEngineChannel; |
itScriptEvent->cause.pEngineChannel = pEngineChannel; |
1305 |
|
itScriptEvent->cause.pMidiInputPort = pEngineChannel->GetMidiInputPort(); |
1306 |
|
itScriptEvent->id = 0; |
1307 |
itScriptEvent->handlers[0] = pEngineChannel->pScript->handlerInit; |
itScriptEvent->handlers[0] = pEngineChannel->pScript->handlerInit; |
1308 |
itScriptEvent->handlers[1] = NULL; |
itScriptEvent->handlers[1] = NULL; |
1309 |
itScriptEvent->currentHandler = 0; |
itScriptEvent->currentHandler = 0; |
1310 |
itScriptEvent->executionSlices = 0; |
itScriptEvent->executionSlices = 0; |
1311 |
itScriptEvent->ignoreAllWaitCalls = false; |
itScriptEvent->ignoreAllWaitCalls = false; |
1312 |
itScriptEvent->handlerType = VM_EVENT_HANDLER_INIT; |
itScriptEvent->handlerType = VM_EVENT_HANDLER_INIT; |
1313 |
|
itScriptEvent->parentHandlerID = 0; |
1314 |
/*VMExecStatus_t res = */ pScriptVM->exec( |
itScriptEvent->childHandlerID[0] = 0; |
1315 |
pEngineChannel->pScript->parserContext, &*itScriptEvent |
itScriptEvent->autoAbortByParent = false; |
1316 |
); |
itScriptEvent->forkIndex = 0; |
1317 |
|
|
1318 |
|
VMExecStatus_t res; |
1319 |
|
size_t instructionsCount = 0; |
1320 |
|
const size_t maxInstructions = 200000; // aiming approx. 1 second max. (based on very roughly 5us / instruction) |
1321 |
|
bool bWarningShown = false; |
1322 |
|
do { |
1323 |
|
res = pScriptVM->exec( |
1324 |
|
pEngineChannel->pScript->parserContext, &*itScriptEvent |
1325 |
|
); |
1326 |
|
instructionsCount += itScriptEvent->execCtx->instructionsPerformed(); |
1327 |
|
if (instructionsCount > maxInstructions && !bWarningShown) { |
1328 |
|
bWarningShown = true; |
1329 |
|
dmsg(0,("[ScriptVM] WARNING: \"init\" event handler of instrument script executing for long time!\n")); |
1330 |
|
} |
1331 |
|
} while (res & VM_EXEC_SUSPENDED && !(res & VM_EXEC_ERROR)); |
1332 |
|
|
1333 |
pEngineChannel->pScript->pEvents->free(itScriptEvent); |
pEngineChannel->pScript->pEvents->free(itScriptEvent); |
1334 |
} |
} |
2016 |
case Event::synth_param_volume_time: |
case Event::synth_param_volume_time: |
2017 |
pNote->Override.VolumeTime = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta; |
pNote->Override.VolumeTime = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta; |
2018 |
break; |
break; |
2019 |
|
case Event::synth_param_volume_curve: |
2020 |
|
itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta; |
2021 |
|
pNote->Override.VolumeCurve = (fade_curve_t) itEvent->Param.NoteSynthParam.AbsValue; |
2022 |
|
break; |
2023 |
case Event::synth_param_pitch: |
case Event::synth_param_pitch: |
2024 |
if (relative) |
if (relative) |
2025 |
pNote->Override.Pitch *= itEvent->Param.NoteSynthParam.Delta; |
pNote->Override.Pitch *= itEvent->Param.NoteSynthParam.Delta; |
2030 |
case Event::synth_param_pitch_time: |
case Event::synth_param_pitch_time: |
2031 |
pNote->Override.PitchTime = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta; |
pNote->Override.PitchTime = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta; |
2032 |
break; |
break; |
2033 |
|
case Event::synth_param_pitch_curve: |
2034 |
|
itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta; |
2035 |
|
pNote->Override.PitchCurve = (fade_curve_t) itEvent->Param.NoteSynthParam.AbsValue; |
2036 |
|
break; |
2037 |
case Event::synth_param_pan: |
case Event::synth_param_pan: |
2038 |
if (relative) { |
if (relative) { |
2039 |
pNote->Override.Pan = RTMath::RelativeSummedAvg(pNote->Override.Pan, itEvent->Param.NoteSynthParam.Delta, ++pNote->Override.PanSources); |
pNote->Override.Pan = RTMath::RelativeSummedAvg(pNote->Override.Pan, itEvent->Param.NoteSynthParam.Delta, ++pNote->Override.PanSources); |