HISE Logo Forum
    • Categories
    • Register
    • Login

    Expansions - loading sample maps behaving oddly...

    Scheduled Pinned Locked Moved General Questions
    7 Posts 2 Posters 136 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.
    • LindonL
      Lindon
      last edited by

      So I'm trying to load maps into a sampler.

      The basic approach is pretty simple - an inline function that takes the name of the sample map and it loads the map into a defined sampler....
      .
      Here's the function:

      inline function loadVoiceByName(voiceNumber, voiceName)
      {
      	if (voiceName != "")
      	{
      		local testName;
      		//look for the voice display name...
      		for (mv in masterVoiceData)
      		{
      			if(voiceName == mv.VoiceDisplayName)
      			{
      				// found our voice
      				if(mv.VoiceLocation != "Factory")
      				{
      					// its an expansion
      					testName = "{EXP::" + "DeepHorizens" + "}"+ "DH_AirKeys";
      	   				Console.print("Constructed:" + testName );
      				}else{
      					testName = mv.VoiceMapName;
      				}
      			};
      		};
             //testName = "{EXP::" + "DeepHorizens" + "}"+ "DH_Airkeys"; //<-- uncomment this line an it works!
      	   Console.print("Trying to load " + testName );
             TheSamplers[voiceNumber].loadSampleMap(testName);
         }
      };
      

      As you can see it first checks there is a value present , then looks through an array (of JSON objects) called masterVoiceData. It looks in here to find out if the name we've been sent is in fact the name of a map from an expansion...if it is it constructs the string we need (in testName) to get an expansion map to load, if its not then it just uses the passed in string value...

      This loads all the "factory" content perfectly, but fails to load the expansion map every time.....

      BUT.... uncomment the line at the bottom assigning exactly the same string to testName - and it works every time....

      What am I doing wrong????

      HISE Development for hire.
      www.channelrobot.com

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

        @Lindon oh n o...t-shit time again I think.....

        check the spelling on the two assignments of Airkeys (or as I have it on one spot AirKeys) doh!

        HISE Development for hire.
        www.channelrobot.com

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

          @Lindon Your nesting is killing me :)

          inline function loadVoiceByName(voiceNumber, voiceName)
          {
              if (voiceName == "")
                  return;
          		
              local sampleMap;
          		
              for (x in masterVoiceData)
              {
                  if (voiceName != x.VoiceDisplayName)
          	    continue;
          			
          	if (x.VoiceLocation != "Factory")
                      sampleMap = "{EXP::" + "DeepHorizens" + "}"+ "DH_Airkeys";
                  else
                      sampleMap = x.VoiceMapName;			
              }
          		
              TheSamplers[voiceNumber].loadSampleMap(sampleMap);
          };
          

          Also you might want to use the getWildcardReference function instead of hardcoding the expansion name.

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

          LindonL 1 Reply Last reply Reply Quote 0
          • LindonL
            Lindon @d.healey
            last edited by Lindon

            @d-healey oh I DONT hard code the expansion name ,I actually get it from anoth piece of the json puzzle, this was just to demonstrate the problem - which actually just demonstrated by stupidity....

            Whats wrong with the nesting?

            -- oh hang on I like the "continue".... dont normally use that... still...

            HISE Development for hire.
            www.channelrobot.com

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

              @Lindon This changed how I write code and made my scripts much cleaner, easier to read and maintain

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

              LindonL 2 Replies Last reply Reply Quote 0
              • LindonL
                Lindon @d.healey
                last edited by

                @d-healey cool I will take a look, here's wjhat a correctly working version of this look like:

                inline function loadVoiceByName(voiceNumber, voiceName)
                {
                	if (voiceName != "")
                        {
                            TheSamplers[voiceNumber].loadSampleMap(voiceName);
                        }
                };
                
                

                HISE Development for hire.
                www.channelrobot.com

                1 Reply Last reply Reply Quote 0
                • LindonL
                  Lindon @d.healey
                  last edited by Lindon

                  @d-healey oh hang on I've watched that video before _ I must admit I'm a big user of

                  if(!value)
                     return;
                  

                  these days...as a result.

                  HISE Development for hire.
                  www.channelrobot.com

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

                  28

                  Online

                  1.7k

                  Users

                  11.8k

                  Topics

                  103.1k

                  Posts