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

Method importSamples

hi_scripting/scripting/api/ScriptingApi.cpp:4828–4924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4826}
4827
4828var ScriptingApi::Sampler::importSamples(var fileNameList, bool skipExistingSamples)
4829{
4830#if HI_ENABLE_EXPANSION_EDITING
4831 if (fileNameList.isArray() && fileNameList.getArray()->size() == 0)
4832 return fileNameList;
4833
4834 WARN_IF_AUDIO_THREAD(true, ScriptGuard::IllegalApiCall);
4835
4836 ModulatorSampler *s = static_cast<ModulatorSampler*>(sampler.get());
4837
4838 if (s != nullptr)
4839 {
4840 auto start = Time::getMillisecondCounter();
4841
4842 SuspendHelpers::ScopedTicket ticket(s->getMainController());
4843
4844 s->getMainController()->getKillStateHandler().killVoicesAndWait();
4845
4846 LockHelpers::SafeLock sl(s->getMainController(), LockHelpers::Type::SampleLock);
4847
4848 auto sampleExists = [s](PoolReference r)
4849 {
4850 auto fileName = r.getFile().getFullPathName();
4851
4852 for (int i = 0; i < s->getNumSounds(); i++)
4853 {
4854 if (auto sound = dynamic_cast<ModulatorSamplerSound*>(s->getSound(i)))
4855 {
4856 auto f = sound->getPropertyAsString(SampleIds::FileName);
4857
4858 if (f == fileName)
4859 return true;
4860 }
4861 }
4862
4863 return false;
4864 };
4865
4866 if (auto ar = fileNameList.getArray())
4867 {
4868 StringArray list;
4869
4870 for (auto& newSample : *ar)
4871 {
4872 PoolReference ref(s->getMainController(), newSample, FileHandlerBase::Samples);
4873
4874 if (skipExistingSamples && sampleExists(ref))
4875 continue;
4876
4877 list.add(ref.getFile().getFullPathName());
4878 }
4879
4880 BigInteger rootNotes;
4881 // start at note number 0
4882 rootNotes.setRange(0, jmin(127, list.size()), true);
4883
4884 int startIndex = s->getNumSounds();
4885

Callers

nothing calls this directly

Calls 15

jminFunction · 0.85
varFunction · 0.85
killVoicesAndWaitMethod · 0.80
getPropertyAsStringMethod · 0.80
getScriptEngineMethod · 0.80
StringClass · 0.50
isArrayMethod · 0.45
sizeMethod · 0.45
getArrayMethod · 0.45
getMethod · 0.45
getMainControllerMethod · 0.45
getFileMethod · 0.45

Tested by

no test coverage detected