HISE Logo Forum
    • Categories
    • Register
    • Login

    Replacing Sample in Sampler

    Scheduled Pinned Locked Moved Scripting
    2 Posts 2 Posters 83 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.
    • V
      VeryHuman
      last edited by

      I am trying to replace a sample with another sample but I can't for the life of me get it working. I suspect it has something to do with asynchronous functions such as the clearSampleMap. Any ideas?

      const var Sample1 = Content.getComponent("Sample1");
      const var Sampler1 = Synth.getChildSynth("Sampler1");
      
      Sample1.setMouseCallback(function(event)
      {
          if(event.clicked){
      		FileSystem.browse("undefined", false, "*.wav", function(result)
      		{
      		    if(result){
      			
      				Sampler1.asSampler().clearSampleMap();
      				var importedSamples = Sampler1.asSampler().importSamples([result.toString("FULLPATH")], false);
      
      			    importedSamples[0].set(2, 60);
      			    importedSamples[0].set(3,60);
      			    importedSamples[0].set(4,60);
      			    Sampler1.asSampler().saveCurrentSampleMap("Module1");
      			    Sampler1.asSampler().loadSampleMap("Module1");
      			    
      
      		    }
      		    
      		});
      	}
      });
      
      
      Oli UllmannO 1 Reply Last reply Reply Quote 0
      • Oli UllmannO
        Oli Ullmann @VeryHuman
        last edited by

        @VeryHuman
        Maybe you should have a look at the custom sample import demo project from Christoph:

        Link Preview Image
        GitHub - christophhart/hise_tutorial: The Tutorial project for HISE

        The Tutorial project for HISE. Contribute to christophhart/hise_tutorial development by creating an account on GitHub.

        favicon

        GitHub (github.com)

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

        10

        Online

        1.7k

        Users

        11.8k

        Topics

        102.3k

        Posts