MCPcopy Create free account
hub / github.com/christophhart/HISE / noteOffDelayedByEventId

Method noteOffDelayedByEventId

hi_scripting/scripting/api/ScriptingApi.cpp:5347–5398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5345}
5346
5347void 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
5400void ScriptingApi::Synth::addToFront(bool addToFront)
5401{

Callers 4

onNoteOnMethod · 0.80
playNoteMethod · 0.80
stopCurrentNoteMethod · 0.80
sendNoteOffMethod · 0.80

Calls 15

getProcessorFunction · 0.85
popNoteOnFromEventIdMethod · 0.80
getCurrentHiseEventMethod · 0.80
getTimeStampMethod · 0.80
setTimeStampMethod · 0.80
setArtificialMethod · 0.80
addHiseEventToBufferMethod · 0.80
getMainControllerMethod · 0.45
isEmptyMethod · 0.45
isArtificialMethod · 0.45

Tested by

no test coverage detected