HISE Logo Forum
    • Categories
    • Register
    • Login

    Switching Images and {PROJECT_FOLDER}

    Scheduled Pinned Locked Moved General Questions
    5 Posts 2 Posters 292 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.
    • CyberGenC
      CyberGen
      last edited by CyberGen

      Hello friends.

      I've got a comboBox with about six items. The items are connected to the sample-maps and to a script image. OnControl, the comboBox is supposed to load the desired instrument/sample-map along with it's matching icon image. (Some code below)

      I'm using mostly stuff in Mr. Healey's tutorials. It works to an extent. The sample maps change fine and the instrument name is sent to the image's fileName, but the image box still says "missing". I think it has something to do with the {PROJECT_FOLDER} wild card, but I haven't been able to figure it out.

      I think it would work if I could set the comboBox to include the wildcard string along with the value sent to the the image fileName. I just don't know how.

      Any suggestions?
      Gracias.

      //	INSTRUMENTS COMBO BOX
      const var sampleMaps = Sampler.getSampleMapList();
      const var cmbInstruments = Content.getComponent("cmbInstruments");
      cmbInstruments.set("items", sampleMaps.join("\n"));
      
      // const var wildcardPlus = {w:"{PROJECT_FOLDER}", i:instrumentName};
      
      inline function oncmbInstrumentsControl(component, value)
      {
      	var instrumentName = (sampleMaps[value-1]);
      
      	Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]);
      	
      	Engine.loadImageIntoPool(instrumentName);
      	iconImage.set("fileName", instrumentName);
      
      	Console.print(instrumentName);
      	
      };
      Content.getComponent("cmbInstruments").setControlCallback(oncmbInstrumentsControl);
      
      
      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @CyberGen
        last edited by

        @RastaChess

        Use local instead of var in inline functions.

        Load all your images into the pool in on init instead of in your function. This is an operation that only needs to be done once when the project loads so there is no need to do it every time the combo box callback triggers.

        Engine.loadImageIntoPool("{PROJECT_FOLDER}imageName.jpg"); is probably the format you need. If the images are in subfolders you need to include that.

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        CyberGenC 1 Reply Last reply Reply Quote 0
        • CyberGenC
          CyberGen @d.healey
          last edited by

          @d-healey Thanks for your reply.

          I incorporated your suggestions. Thanks. They work fine, but I'm still having the issue with the images not being found.
          The local variable "instrumentName" contains/sends the file-name to the image but without the "{PROJECT_FOLDER}". So it shows up in the property editor as just the name, not "wildcard+imageName" which is what is needed, I think.

          Is there a way to add the wildcard to the "instrumentName" as part of the value being sent to the imageFile.?

          Note: images (PNG) are inside the images folder of the project, no subfolders and apear to be loading into the pool just fine.

          Help is much appreciated.
          Thank you.

          Updated code.

          //	INSTRUMENTS COMBO BOX
          const var sampleMaps = Sampler.getSampleMapList();
          const var cmbInstruments = Content.getComponent("cmbInstruments");
          cmbInstruments.set("items", sampleMaps.join("\n"));
          
          inline function oncmbInstrumentsControl(component, value)
          {
          	local instrumentName = (sampleMaps[value-1]);
          
          	Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]);
          		
          	iconImage.setImageFile(instrumentName, 0);
          	
          	Console.print(imageFile);
          	Console.print(instrumentName);	
          }
          
          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @CyberGen
            last edited by

            @RastaChess

            Try iconImage.setImageFile("{PROJECT_FOLDER}" + instrumentName + ".png");

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            1 Reply Last reply Reply Quote 0
            • CyberGenC
              CyberGen
              last edited by

              YES!!

              That works. 🤘

              Thank you sooooo much!
              :folded_hands_light_skin_tone:

              Best Regards.

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

              23

              Online

              1.8k

              Users

              12.0k

              Topics

              104.1k

              Posts