Need help with importing samples via script
-
I have a backend script that has to import some 1600 (small) samples, set various sample attributes (root, velocity, RRgroup etc) then save the sampleMap but every time I run it it crashes HISE.
What are the best practices for batch importing like this? Tried:
- Background worker with
killAllVoicesAndCall
which made it worse - Switching from HDD to SSD (lol)
- inline vs regular function, inline seems to be a bit more stable but still crashy
- using less (200) samples, still crashes just as often
samples = FileSystem.findFiles(samplesFolder, "*.wav", false); for (i=0; i<samples.length; i++) { // Get sample name as string prefix = "{PROJECT_FOLDER}" + samplesFolder.toString(1) + "/"; name = samples[i].toString(3); path = prefix + name; // Set the RR Group Amount & Import Samples Sampler1.setAttribute(Sampler1.RRGroupAmount, NUM_ROUNDROBINS); var importedSamples = Sampler1.asSampler().importSamples([path], false); for (s in importedSamples) { sT = s.get(Sampler.FileName); idx = sT.indexOf("root") + 4; subString = sT.substring(idx, sT.length); idxEnd = subString.indexOf("_"); subString = subString.substring(0, idxEnd); rootNote = Math.round(subString); //s.set(Sampler.LoKey, 64); // doesn't work // Low Key Fix for (x = 3; x < 5; x++) { s.set(x, lowKey); } s.set(Sampler.Root, rootNote); s.set(Sampler.HiKey, highKey); // etc Sampler1.asSampler().saveCurrentSampleMap(sampleMapName); }
- Background worker with
-
@iamlamprey No idea if this is relevant but you seem to be missing a closing bracket at the end of the first for loop.
-
@dannytaurus Yeh I pasted that hastily, it's part of a larger function but includes the important parts.
I just debugged it and got a seemingly unrelated error so I'm thinking the problem is actually due to this line:
Sampler1.setAttribute(Sampler1.RRGroupAmount, NUM_ROUNDROBINS);
I'll keep digging
-
Okay I've moved
Sampler1.setAttribute(Sampler1.RRGroupAmount, NUM_ROUNDROBINS);
out of the internal function so it's only being called once, silly me -
-
-
-
okay nope, still crashing, now with a different jassert:
// if this hits, you're using multiple writer threads. consider the ScopedMultiWriteLock instead jassert(lock.writer == thisId || lock.writer == i);
@Christoph-Hart is this a drive-related error? its an old dying HDD so I'm assuming it's related
-
Another error related to this line:
var importedSamples = Sampler1.asSampler().importSamples([path], false);
Exception thrown: read access violation. std::_Atomic_address_as<long,std::_Atomic_padded<int> >(...) returned 0xFFFFFFFFFFFFFFFF.
This Atomic file is part of VS2022 so I'm in uncharted waters now I think