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

Method duplicateSample

hi_scripting/scripting/api/ScriptingApiObjects.cpp:2423–2451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2421}
2422
2423ScriptingObjects::ScriptingSamplerSound* ScriptingObjects::ScriptingSamplerSound::duplicateSample()
2424{
2425 auto jp = dynamic_cast<JavascriptProcessor*>(getScriptProcessor());
2426
2427 auto s = getSampler();
2428 auto mc = s->getMainController();
2429
2430 ScopedValueSetter<bool> svs(s->getSampleMap()->getSyncEditModeFlag(), true);
2431
2432 SuspendHelpers::ScopedTicket ticket(mc);
2433 mc->getJavascriptThreadPool().killVoicesAndExtendTimeOut(jp, 1000);
2434
2435 while (mc->getKillStateHandler().isAudioRunning())
2436 {
2437 Thread::sleep(100);
2438 }
2439
2440 LockHelpers::freeToGo(s->getMainController());
2441 LockHelpers::SafeLock sl(mc, LockHelpers::Type::SampleLock);
2442
2443 auto copy = sound->getData().createCopy();
2444
2445 s->getSampleMap()->addSound(copy);
2446 s->refreshPreloadSizes();
2447
2448 auto newSound = dynamic_cast<ModulatorSamplerSound*>(s->getSound(s->getNumSounds() - 1));
2449
2450 return new ScriptingSamplerSound(getScriptProcessor(), s, newSound);
2451}
2452
2453void ScriptingObjects::ScriptingSamplerSound::deleteSample()
2454{

Callers

nothing calls this directly

Calls 8

refreshPreloadSizesMethod · 0.80
getMainControllerMethod · 0.45
isAudioRunningMethod · 0.45
createCopyMethod · 0.45
getDataMethod · 0.45
addSoundMethod · 0.45
getSoundMethod · 0.45

Tested by

no test coverage detected