HISE Logo Forum
    • Categories
    • Register
    • Login

    Need help with importing samples via script

    Scheduled Pinned Locked Moved Unsolved Scripting
    6 Posts 2 Posters 154 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User
      last edited by

      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);	
      
      }
      
      dannytaurusD 1 Reply Last reply Reply Quote 0
      • dannytaurusD
        dannytaurus @A Former User
        last edited by

        @iamlamprey No idea if this is relevant but you seem to be missing a closing bracket at the end of the first for loop.

        Meat Beats: https://meatbeats.com
        Klippr Video: https://klippr.video

        ? 1 Reply Last reply Reply Quote 0
        • ?
          A Former User @dannytaurus
          last edited by A Former User

          @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

          ? 1 Reply Last reply Reply Quote 1
          • ?
            A Former User @A Former User
            last edited by

            @iamlamprey

            Okay I've moved Sampler1.setAttribute(Sampler1.RRGroupAmount, NUM_ROUNDROBINS); out of the internal function so it's only being called once, silly me 🙂

            1 Reply Last reply Reply Quote 1
            • System marked this topic as a question on
            • System has marked this topic as solved on
            • System has marked this topic as unsolved on
            • ?
              A Former User
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • ?
                A Former User
                last edited by

                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 😲

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post

                44

                Online

                1.7k

                Users

                11.7k

                Topics

                102.1k

                Posts