| 2421 | } |
| 2422 | |
| 2423 | ScriptingObjects::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 | |
| 2453 | void ScriptingObjects::ScriptingSamplerSound::deleteSample() |
| 2454 | { |
nothing calls this directly
no test coverage detected