| 5345 | } |
| 5346 | |
| 5347 | void ScriptingApi::Synth::noteOffDelayedByEventId(int eventId, int timestamp) |
| 5348 | { |
| 5349 | if (parentMidiProcessor == nullptr) |
| 5350 | reportScriptError("Can't call this outside of MIDI script processors"); |
| 5351 | |
| 5352 | const HiseEvent e = getProcessor()->getMainController()->getEventHandler().popNoteOnFromEventId((uint16)eventId); |
| 5353 | |
| 5354 | |
| 5355 | |
| 5356 | if (!e.isEmpty()) |
| 5357 | { |
| 5358 | #if ENABLE_SCRIPTING_SAFE_CHECKS |
| 5359 | if (!e.isArtificial()) |
| 5360 | { |
| 5361 | reportScriptError("Hell breaks loose if you kill real events artificially!"); |
| 5362 | } |
| 5363 | #endif |
| 5364 | const HiseEvent* current = parentMidiProcessor->getCurrentHiseEvent(); |
| 5365 | |
| 5366 | #if HISE_USE_BACKWARDS_COMPATIBLE_TIMESTAMPS |
| 5367 | |
| 5368 | if (getProcessor()->getMainController()->getKillStateHandler().getCurrentThread() == MainController::KillStateHandler::TargetThread::AudioThread) |
| 5369 | { |
| 5370 | // Apparently there was something wrong with the timestamp calculation. |
| 5371 | // This restores the old behaviour by removing one block from the timestamps. |
| 5372 | // By default, it's turned off, but you can enable it if you need backwards |
| 5373 | // compatibility with older patches... |
| 5374 | int blocksize = parentMidiProcessor->getMainController()->getBufferSizeForCurrentBlock(); |
| 5375 | timestamp = jmax<int>(0, timestamp - blocksize); |
| 5376 | } |
| 5377 | |
| 5378 | #endif |
| 5379 | |
| 5380 | if (current != nullptr) |
| 5381 | { |
| 5382 | timestamp += current->getTimeStamp(); |
| 5383 | } |
| 5384 | |
| 5385 | HiseEvent noteOff(HiseEvent::Type::NoteOff, (uint8)e.getNoteNumber(), 1, (uint8)e.getChannel()); |
| 5386 | noteOff.setEventId((uint16)eventId); |
| 5387 | noteOff.setTimeStamp(timestamp); |
| 5388 | |
| 5389 | if (e.isArtificial()) noteOff.setArtificial(); |
| 5390 | |
| 5391 | parentMidiProcessor->addHiseEventToBuffer(noteOff); |
| 5392 | } |
| 5393 | else |
| 5394 | { |
| 5395 | // The note might already be killed, but you want to change the timestamp afterwards... |
| 5396 | parentMidiProcessor->setArtificialTimestamp(eventId, timestamp); |
| 5397 | } |
| 5398 | } |
| 5399 | |
| 5400 | void ScriptingApi::Synth::addToFront(bool addToFront) |
| 5401 | { |
no test coverage detected