HISE Logo Forum
    • Categories
    • Register
    • Login

    Unknown Functions 'set' & 'getRange'

    Scheduled Pinned Locked Moved Scripting
    15 Posts 3 Posters 799 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.
    • trillbillyT
      trillbilly
      last edited by

      Hey Gang,

      Im using a version of the Custom Sample Import. Everything was working great until I opened my project tonight and all the Samplers 'sound.set' and 'sound.getRange' all throw an UKNOWN FUNCTION error. It seems these are both for the Loop Range & Loop Xfade.

      If I open any presets with the Loop Range or Loop Xfade saved within a preset, HISE crashes.

      What are best practices for figuring out the issue? Has anyone had something like this happen before?

      LindonL 1 Reply Last reply Reply Quote 0
      • LindonL
        Lindon @trillbilly
        last edited by

        @trillbilly show us the code....

        HISE Development for hire.
        www.channelrobot.com

        trillbillyT 1 Reply Last reply Reply Quote 0
        • trillbillyT
          trillbilly @Lindon
          last edited by trillbilly

          @Lindon Yes, of course. Here is Sampler 1. Its in the onLoopControl & onXfadeControl Functions.

          I have ran my projects XMLBackup through an XML Validator and it returned no issues. I have also removed all other coding/functions to see if something was interfering, but, it still didnt work. I also went back through and checked that I had the correct included scripts and that they were up to date.

          It kind of seemed out of nowhere (of course it was, I wasnt expecting it).

          //SAMPLER 1
          const var Sampler1 = Synth.getSampler("Sampler1");
          reg sound;
          reg totalSamples = 0;
          reg isCustomMap = false;
          
          
          //! "Page" Logic
          // Nothing special, it just shows / hides certain elements...
          
          const var editButtons = [Content.getComponent("EditLoop"),
                                   Content.getComponent("EditRange"),
                                   Content.getComponent("ShowDropper")];
          
          const var EDIT_LOOP = 0;
          const var EDIT_RANGE = 1;
          const var SHOW_DROPPER = 2;
          
          const var AudioWaveform1 = Content.getComponent("AudioWaveform1");
          const var SampleDropper = Content.getComponent("SampleDropper");
          const var LoopPanel = Content.getComponent("LoopPanel");
          const var Reverse = Content.getComponent("Reverse");
          
          
          
          inline function setEditMode(editMode)
          {
          	AudioWaveform1.set("enableRange", editMode == EDIT_RANGE);
          	LoopPanel.set("visible", editMode == EDIT_LOOP);
          	SampleDropper.set("visible", editMode == SHOW_DROPPER);
          }
          
          inline function setEditModeCallback(component, value)
          {
          	if(value)
          		setEditMode(editButtons.indexOf(component));
          }
          
          for(b in editButtons)
          	b.setControlCallback(setEditModeCallback);
          
          
          inline function onSampleMapLoaderControl(component, value)
          {
          	if(value > 0)
          	{
          		local id = Sampler1.getSampleMapList()[value - 1];
          		Sampler1.loadSampleMap(id);
          	}
          };
          
          Content.getComponent("SampleMapLoader").setControlCallback(onSampleMapLoaderControl);
          
          const var SampleMapLoader = Content.getComponent("SampleMapLoader");
          
          SampleMapLoader.set("items", Sampler1.getSampleMapList().join("\n"));
          
          
          setEditMode(EDIT_RANGE);
          
          //! Non persistent UI elements
          //  These UI controls do not store any data, but will read / write
          //  to the sample map directly.
          
          
          inline function onLoopControl(component, value)
          {
          	sound.set(Sampler1.LoopEnabled, value);
          	
          	// Make sure the loop end is set to the sample end when you
          	// enable the loop the first time
          	if(sound.get(Sampler1.LoopEnd) == 0)
          		sound.set(Sampler1.LoopEnd, sound.getRange(Sampler1.LoopEnd)[1]);
          	
          	// update the loop point panel
          	LoopPointDragger.updateLoopPoints();
          	
          	// write the loop points back into the base64 string
          	SampleLoadSave.storeSampleMapData();
          };
          
          Content.getComponent("Loop").setControlCallback(onLoopControl);
          
          inline function onXFadeControl(component, value)
          {
          	// the slider is 0...1 so we can use the available crossfade range length
          	// to figure out how big of a crossfade we want
          	local newValue = parseInt(sound.getRange(Sampler1.LoopXFade)[1] * value);
          	sound.set(Sampler1.LoopXFade, newValue);
          	
          	LoopPointDragger.updateLoopPoints();
          	SampleLoadSave.storeSampleMapData();
          };
          
          Content.getComponent("XFade").setControlCallback(onXFadeControl);
          
          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @trillbilly
            last edited by

            @trillbilly An unknown function error means the thing on the left side of the . does not have the function you are trying to call.

            This could be because you've used the wrong variable type or because it's undefined.

            Free HISE Bootcamp Full Course for beginners.
            YouTube Channel - Public HISE tutorials
            My Patreon - HISE tutorials

            trillbillyT 1 Reply Last reply Reply Quote 0
            • trillbillyT
              trillbilly @d.healey
              last edited by

              @d-healey Ahhh ok. So now I need to figure out what was changed, and how, because those functions were working just hours earlier.

              d.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey @trillbilly
                last edited by

                @trillbilly Is it because the sample map is not loaded?

                Free HISE Bootcamp Full Course for beginners.
                YouTube Channel - Public HISE tutorials
                My Patreon - HISE tutorials

                trillbillyT 1 Reply Last reply Reply Quote 0
                • trillbillyT
                  trillbilly @d.healey
                  last edited by

                  @d-healey You're right, when I load an internal sample map, it works. But it wont work anymore with Drag-And-Drop samples.

                  I would rather use the sample maps from internal samples, but, you cant edit the loop range. I've made a post about it HERE.

                  Also, obiviously Im using custom sample import so users can use their own samples. Im confused why it doesnt recognize them as sample maps anymore?

                  trillbillyT 1 Reply Last reply Reply Quote 0
                  • trillbillyT
                    trillbilly @trillbilly
                    last edited by

                    @d-healey Ok, scratch that. its working ONLY if there is a sample loaded. If the sampler is cleared, it throws the error.

                    If you save a preset without a sample/samplemap loaded, it will save but crash upon opening it again.

                    d.healeyD 1 Reply Last reply Reply Quote 0
                    • d.healeyD
                      d.healey @trillbilly
                      last edited by

                      @trillbilly So before you try to call a function on the sound object you need to check if the object is populated.

                      if (!isDefined(sound))
                          return;
                      

                      Free HISE Bootcamp Full Course for beginners.
                      YouTube Channel - Public HISE tutorials
                      My Patreon - HISE tutorials

                      trillbillyT 2 Replies Last reply Reply Quote 0
                      • trillbillyT
                        trillbilly @d.healey
                        last edited by

                        @d-healey That will work better than my idea of populating an empty samplemap when a sampler is not in use. Thank you.

                        1 Reply Last reply Reply Quote 0
                        • trillbillyT
                          trillbilly @d.healey
                          last edited by

                          @d-healey It solved the sound.set issue but not the sound.getRange issue.

                          d.healeyD 1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey @trillbilly
                            last edited by

                            @trillbilly This line?

                            local newValue = parseInt(sound.getRange(Sampler1.LoopXFade)[1] * value);

                            Free HISE Bootcamp Full Course for beginners.
                            YouTube Channel - Public HISE tutorials
                            My Patreon - HISE tutorials

                            trillbillyT 1 Reply Last reply Reply Quote 0
                            • trillbillyT
                              trillbilly @d.healey
                              last edited by

                              @d-healey Yes, that is correct

                              d.healeyD 1 Reply Last reply Reply Quote 0
                              • d.healeyD
                                d.healey @trillbilly
                                last edited by

                                @trillbilly And you tried placing the check before it?

                                Free HISE Bootcamp Full Course for beginners.
                                YouTube Channel - Public HISE tutorials
                                My Patreon - HISE tutorials

                                trillbillyT 1 Reply Last reply Reply Quote 0
                                • trillbillyT
                                  trillbilly @d.healey
                                  last edited by trillbilly

                                  @d-healey No, Im an idiot, I only put it in 1 callback.
                                  Worked like a charm. Much appreciated.

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

                                  22

                                  Online

                                  2.0k

                                  Users

                                  12.7k

                                  Topics

                                  110.1k

                                  Posts