HISE Logo Forum
    • Categories
    • Register
    • Login

    Further fade out an event that is in the process of being faded out

    Scheduled Pinned Locked Moved General Questions
    4 Posts 2 Posters 276 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.
    • gorangroovesG
      gorangrooves
      last edited by gorangrooves

      I have a hi-hat script for variable hats that utilizes 3 different decay rates for how quickly to fade out open hat notes.

      The open hat notes played by this sampler are muted when either:

      • hi-hat foot pedal is played (note# 44),
      • another variable open hi-hat note is played (when CC4 value is within the range of 41-84),
      • closed variable hi-hat is played (when CC4 value is above 84),
      • the sampler receives controller 127 with value 1 (secret message sent by another script in parent container).

      Depending on the circumstances, the notes are faded out at a rate set by one of the 'decay' knobs.
      The script works ok if an open hat note is choked by a single event, as specified above.

      The issue I am trying to get around is this:

      Step 1 - A 75% open hats note is played (#31).
      Step 2 - Another open hi-hat note is played, which chokes the 75% open note with slow decay.
      Step 3 - a 3rd note is played (for example, #44, foot pedal), which is supposed to further quickly fade out the original 75% open note.

      However, that 3rd note does not choke the original note. It is being ignored. It has something to do with eventId, but I am unsure how to get around it.

      How do I quickly fade out a note (in the process of being faded out) with a subsequent event?

      Here is the script:

      //onInit
      //Variable hats 75% open script
      
      reg ccValue = 127; 
      
      const var decay1 = Content.getComponent("decay1");// Regular choke
      const var decay2 = Content.getComponent("decay2");//Choke directed by parent MIDI message
      const var decay3 = Content.getComponent("decay3");//Choke by other open hats
      
      
      //  An Array is also a constant, even if it will be populated later on
      const var evtList = [];
      
      // make sure it has enough storage to avoid allocation during the noteOn callback
      evtList.reserve(1200);
      
      function onNoteOn()
      {
      if (ccValue < 20 || ccValue > 40)//Ignore notes not played in other vari samplers
           {
      	Message.ignoreEvent(true);
           }
      	
      	
      local decayValue1 = decay1.getValue();
      local decayValue3 = decay3.getValue();
           
      for(eventId in evtList)
            {
                 if (ccValue <= 84 && Message.getNoteNumber() != 44)//Mute 75% open hat when other open hats are played
                    {
                           Synth.addVolumeFade(eventId, decayValue3, -100);
                           Console.print("Killing it slowly");
                    }
                   
                   
                  else if (ccValue > 84 || Message.getNoteNumber() == 44)//Choke notes with vari closed hats or foot hats
                      {
                          if(decayValue1 == 0)
                              {
                                  // Send the note off command for the given event id
                                  Synth.noteOffByEventId(eventId);    
                              }
                              else
                              {
                                  // Fade out the note
                                  Synth.addVolumeFade(eventId, decayValue1, -100);
                                  Console.print("Killing it quickly");
                              }
                      }
                }
          // Clear all notes
          evtList.clear(); 
      
          // This is necessary because you will kill the note artificially and HISE
          // can only kill artifical notes for stability reasons
          Message.makeArtificialOrLocal();
          
          // Add this ID to the list (it'll add the artificial event ID)
          evtList.push(Message.getEventId());
      
      	    
      }
       
      
      function onController()
      {
      	if (Message.getControllerNumber() == 4)
          {
              ccValue = Message.getControllerValue();
          }
          
          // Mute notes if parent container sends a message to mute them
          if (Message.getControllerNumber() == 127 && Message.getControllerValue() == 1)
      	   {
      		local decayValue2 = decay2.getValue();
      		for (eventId in evtList)
      		    {
      		        Synth.addVolumeFade(eventId, decayValue2, -100);
      		    }
      	    	// Clear all notes
      	        evtList.clear();
                     Message.makeArtificialOrLocal();
                     evtList.push(Message.getEventId());
      	    }
      
      }
      

      Goran Rista
      https://gorangrooves.com

      Handy Drums and Handy Grooves
      https://library.gorangrooves.com

      gorangroovesG 1 Reply Last reply Reply Quote 0
      • gorangroovesG
        gorangrooves @gorangrooves
        last edited by

        After a careful analysis, I learned that 'Synth.addVolumeFade' kills the note immediately internally, even though it may still be sounding, so it can not be further faded out. The note's eventID gets removed.

        I've resorted to a different make-shift solution to lower the volume of the original open hat notes, when other hat notes are played.

        Goran Rista
        https://gorangrooves.com

        Handy Drums and Handy Grooves
        https://library.gorangrooves.com

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

          @gorangrooves 'Synth.addVolumeFade doesn't kill the note unless the gain value is -100.

          You can see that here - https://github.com/christophhart/HISE/blob/develop/hi_scripting/scripting/api/ScriptingApi.cpp#L5341

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

          gorangroovesG 1 Reply Last reply Reply Quote 0
          • gorangroovesG
            gorangrooves @d.healey
            last edited by

            @d-healey Of course! I overlooked that critical part and only focused on the decay. Thank you so much, Dave! That was illuminating, and I think I am almost finished with the most sophisticated hi-hat script in history of the universe :beaming_face_with_smiling_eyes:

            Goran Rista
            https://gorangrooves.com

            Handy Drums and Handy Grooves
            https://library.gorangrooves.com

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

            20

            Online

            1.7k

            Users

            11.9k

            Topics

            103.6k

            Posts