| 292 | } |
| 293 | |
| 294 | void JavascriptMidiProcessor::runScriptCallbacks() |
| 295 | { |
| 296 | if (currentEvent->isAllNotesOff()) |
| 297 | { |
| 298 | synthObject->handleNoteCounter(*currentEvent); |
| 299 | // All notes off are controller message, so they should not be processed, or it can lead to loop. |
| 300 | currentMidiMessage->onAllNotesOff(); |
| 301 | return; |
| 302 | } |
| 303 | |
| 304 | #if ENABLE_SCRIPTING_BREAKPOINTS |
| 305 | breakpointWasHit(-1); |
| 306 | #endif |
| 307 | |
| 308 | scriptEngine->maximumExecutionTime = HiseJavascriptEngine::getDefaultTimeOut(); |
| 309 | |
| 310 | synthObject->handleNoteCounter(*currentEvent); |
| 311 | |
| 312 | switch (currentEvent->getType()) |
| 313 | { |
| 314 | case HiseEvent::Type::NoteOn: |
| 315 | { |
| 316 | if (onNoteOnCallback->isSnippetEmpty()) return; |
| 317 | |
| 318 | scriptEngine->executeCallback(onNoteOn, &lastResult); |
| 319 | |
| 320 | BACKEND_ONLY(if (!lastResult.wasOk()) debugError(this, lastResult.getErrorMessage())); |
| 321 | |
| 322 | break; |
| 323 | } |
| 324 | case HiseEvent::Type::NoteOff: |
| 325 | { |
| 326 | if (onNoteOffCallback->isSnippetEmpty()) return; |
| 327 | |
| 328 | scriptEngine->executeCallback(onNoteOff, &lastResult); |
| 329 | |
| 330 | BACKEND_ONLY(if (!lastResult.wasOk()) debugError(this, lastResult.getErrorMessage())); |
| 331 | |
| 332 | break; |
| 333 | } |
| 334 | case HiseEvent::Type::Controller: |
| 335 | case HiseEvent::Type::PitchBend: |
| 336 | case HiseEvent::Type::Aftertouch: |
| 337 | case HiseEvent::Type::ProgramChange: |
| 338 | { |
| 339 | if (currentEvent->isControllerOfType(64)) |
| 340 | { |
| 341 | synthObject->setSustainPedal(currentEvent->getControllerValue() > 64); |
| 342 | } |
| 343 | |
| 344 | if (onControllerCallback->isSnippetEmpty()) return; |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | Result r = Result::ok(); |
| 350 | scriptEngine->executeCallback(onController, &lastResult); |
| 351 |
no test coverage detected