HISE Logo Forum
    • Categories
    • Register
    • Login
    1. HISE
    2. Fergler
    3. Best
    F
    • Profile
    • Following 0
    • Followers 0
    • Topics 9
    • Posts 40
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: Hihat Full Choke Senario? Is That Possible in Hise??? Finaly Yes!

      Adding my code as well for anyone looking to do hihats from GM layout, but support e-kit that uses CC4 to open/close note 46 for tip and note 26 for edge:

      onInit function and declarations:

      // Create a midilist with 128 elements
      const var midiData = Engine.createMidiList();
      // This count will manage our position in the midilist
      var count = 0;
      
      const TipTranslations = [70, 69, 68, 67, 66];
      const ShoulderTranslations = [64, 63, 62, 61, 60];
      
      function getTranslatedNote(input, cc4Value) {
          var translatedNote = input;  
      
          var translation = (input == 46) ? TipTranslations : (input == 26) ? ShoulderTranslations : null;
      
          if (translation != null) {
              for (i = 0; i < cc4Ranges.length; i++) {
                  if (cc4Value >= cc4Ranges[i][0] && cc4Value <= cc4Ranges[i][1]) {
                      translatedNote = translation[i];
                      break;
                  }
              }
          }
      
          return translatedNote;
      }
      
      function onNoteOn()
      {
          var input = Message.getNoteNumber();
          var id = Message.getEventId();
          var weight;
          
          // Get the translated note number
          var newMsg = getTranslatedNote(input, cc4Value);
          
          // Send the modified note
          Message.setNoteNumber(newMsg);
          
          // Check if the note number is within the specified range or matches specific values
          if ((newMsg >= 60 && newMsg <= 70) || newMsg == 44 || newMsg == 73 || newMsg == 42)
          {
              // Assign weights based on note number
              switch(newMsg) {
                  case 70:
                  case 64:
                      weight = 5;
                      break;
                  case 69:
                  case 63:
                      weight = 4;
                      break;
                  case 68:
                  case 62:
                      weight = 3;
                      break;
                  case 67:
                  case 61:
                      weight = 2;
                      break;
                  case 60:
                  case 66:
                      weight = 1;
                      break;
                  case 44:
                  case 73:
                      weight = 1;
                      break;
                  default:
                      weight = 1;
              }
      
              // Calculate the indices for the midilist
              var index1 = count * 2;
              var index2 = index1 + 1;
      
              // Store event ID and weight in the midilist
              midiData.setValue(index1, id);
              midiData.setValue(index2, weight);
      
              // Increment and reset count as necessary
              count = (count + 1) % 64;
      
              // Loop through midilist weights
              for (var i = 1; i < 128; i += 2)
              {
                  var storedWeight = midiData.getValue(i);
                  if (storedWeight > weight)  // Checking weights at odd indices
                  {
                      var storedId = midiData.getValue(i - 1);  // Retrieve the event ID from the previous index
                      Synth.addVolumeFade(storedId, 150, -60);  // 150 ms fade to -60 dB
                      //Console.print("Killed notes: " + storedId);
      
                      // Set weight to 0 to mark as "killed" and skip in future checks
                      midiData.setValue(i, 0);
                  }
              }
          }
      }
      
      
      
      function onController()
      {
          var number = Message.getControllerNumber();
          var value = Message.getControllerValue();
          
          if (number == 4) 
          {
              cc4Value = value;
          }
      }
      

      This could be improved to change the fade time/amount depending on the weight difference (which I probably will to control open > less open vs open to full closed, and to generate new transition sounds (hihat rattling) when closing the pedal after a recent open hit.

      posted in Scripting
      F
      Fergler
    • RE: What filetypes and channel sizes are supported?

      @d-healey

      It’s achieved; I’m loading samples based on their tokens and creating a module structure. Right now I’m only loading one mic (OH_M) and there are 6 other mic positions to load later with multimic. I should probably investigate doing it manually and exporting the sample map to see how it is represented there, if it is.

      const
      var dataObj = Engine.loadFromJSON("../ArticulationData.json");
      
      include("UI.js");
      
      
      
      function createModule(type, name, parent) {
          if (type.toLowerCase() == "sampler") {
              var type = builder.SoundGenerators.StreamingSampler;
          } else {
              var type = builder.SoundGenerators.SynthChain;
          }
      
          var module = builder.create(type, name, parent, builder.ChainIndexes.Direct);
          return module;
      }
      
      
      function createSampleObj(fName, note1, note2, loVel, hiVel, RRGroup /*(j+1)*/ , Duplicate /*0*/ ) {
          var obj = {
              FileName: fName,
              Root: note1,
              LoKey: note1,
              HiKey: note1,
              LoVel: loVel,
              HiVel: hiVel,
              RRGroup: RRGroup,
              Duplicate: Duplicate
          };
      
          return obj
      }
      
      var builder = Synth.createBuilder();
      builder.clear();
      
      var sampleMap = [];
      var stopper = 0;
      for (group in dataObj) {
          
          stopper++;
          
          
          var groupSampler = createModule("Sampler", group, 0);
                  include("SetSamplerAttributes.js");
      
      
          sampleMap = [];
          for (hit in dataObj[group]) {
      	    
              var rrGroups = dataObj[group][hit].RRGroups;
              var rrSize = dataObj[group][hit].RRSize;
              var Layers = dataObj[group][hit].Layers;
              var note1 = dataObj[group][hit].Note1;
              var note2 = dataObj[group][hit].Note2;
      			
      		
      		var count = 0;	
              for (i = 0; i < rrGroups; i++) { // for each rrGroup
      			
      			
                  for (j = 0; j < rrSize && count < Layers; j++) {
      	            count++;
                  
                  	include("SampleSortConsolePrint.js");
      
                      var fName = "{PROJECT_FOLDER}" + group + "-" + hit + "-OH_M-" + count + ".wav";
                      
                      include("VelocityMath.js");
      
                      var obj = createSampleObj(fName, note1, note2, loVel, hiVel, (j+1), 0);
                      
                      sampleMap.push(obj);
      
                      if (count == Layers) { // only saves complete sample sets until overflow logic is complete
                      //Console.print("test");
                          Engine.dumpAsJSON(sampleMap, group + ".json");
                      }
                  }
                  Synth.getSampler(group).loadSampleMapFromJSON(sampleMap);
              }
          }
      
          if (stopper > 4) break // Let's take it slow
      }
      
      builder.flush();
      

      Working good!

      posted in General Questions
      F
      Fergler
    • RE: applyMask behaves differently at different UI scales

      Another interesting thing. Content.createScreenshot will take a screenshot but the results have different mask scaling than the UI, even when my zoom is at 100% and everything looks correct.

      posted in Bug Reports
      F
      Fergler