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

Method startTimer

hi_scripting/scripting/api/ScriptingApi.cpp:5594–5641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5592}
5593
5594void ScriptingApi::Synth::startTimer(double intervalInSeconds)
5595{
5596#if ENABLE_SCRIPTING_SAFE_CHECKS
5597 if(intervalInSeconds < 0.004)
5598 {
5599 reportScriptError("Go easy on the timer!");
5600 return;
5601 }
5602#endif
5603
5604
5605
5606
5607
5608
5609 if (parentMidiProcessor == nullptr)
5610 reportScriptError("Timers only work in MIDI processors!");
5611
5612 if(jp != nullptr && jp->isDeferred())
5613 {
5614 owner->stopSynthTimer(parentMidiProcessor->getIndexInChain());
5615 jp->startTimer((int)(intervalInSeconds * 1000));
5616 parentMidiProcessor->setIndexInChain(-1);
5617 }
5618 else
5619 {
5620 int freeTimerSlot = parentMidiProcessor->getIndexInChain() != -1 ? parentMidiProcessor->getIndexInChain() : owner->getFreeTimerSlot();
5621
5622 if (freeTimerSlot == -1)
5623 {
5624 reportScriptError("All 4 timers are used");
5625 return;
5626 }
5627
5628 parentMidiProcessor->setIndexInChain(freeTimerSlot);
5629
5630 auto* e = parentMidiProcessor->getCurrentHiseEvent();
5631
5632 int timestamp = 0;
5633
5634 if (e != nullptr)
5635 {
5636 timestamp = e->getTimeStamp();
5637 }
5638
5639 owner->startSynthTimer(parentMidiProcessor->getIndexInChain(), intervalInSeconds, timestamp);
5640 }
5641}
5642
5643void ScriptingApi::Synth::stopTimer()
5644{

Callers 3

onInitMethod · 0.45
startMethod · 0.45

Calls 8

isDeferredMethod · 0.80
stopSynthTimerMethod · 0.80
getIndexInChainMethod · 0.80
setIndexInChainMethod · 0.80
getFreeTimerSlotMethod · 0.80
getCurrentHiseEventMethod · 0.80
getTimeStampMethod · 0.80
startSynthTimerMethod · 0.80

Tested by

no test coverage detected