HISE Logo Forum
    • Categories
    • Register
    • Login

    Updated d-healey's Release Trigger

    Scheduled Pinned Locked Moved Presets / Scripts / Ideas
    4 Posts 2 Posters 341 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.
    • E
      Ensou
      last edited by Ensou

      Hello! My first time here on this website and first time using HISE this week! and I love it!

      I was using @d-healey 's release trigger script that he shared here from 2017 and it was broken, so I fixed it.
      for some reason using createMidiList() messes up the noteOn-noteOff timer so i just swapped it out with an array.
      I re-arranged the UI as well to fit in better with the new HISE editor. Removed the Legato mode for now as it was also broken.

      I didn't see anyone sharing a fixed version so i decided to share it for everyone else.

      /**
       * Release Trigger v2.0.0
       * Author: Christoph Hart, David Healey, Lorenzo Artigas (Ensou)
       * Date: 09/01/2017
       * Updated: 10/26/2019
       */
      
      //Includes 
      
      //Init
      Content.setHeight(150);
      Content.setName("Release Trigger");
      
      reg attenuationLevel = 1.0; 
      reg timeIndex = 0;
      reg time;
      const var velocityValues = [];
      const var lengthValues = [];
      
      const var btnMute = Content.addButton("btnMute", 20, 20);
      btnMute.set("text", "Mute");
      
      const var btnAttenuate = Content.addButton("Attenuate", 20, 50);
      
      const var knbTime = Content.addKnob("Time", 20, 80);
      knbTime.setRange(0, 20, 0.1);
      
      const var tblTime = Content.addTable("tblTime", 140, 0);
      tblTime.setPosition(170, 20, 580, 110);
      
      for(i = 0; i < 127; i++)
      {
      	velocityValues[i] = 0;
      	lengthValues[i] = 0.0;
      }
      
      function onNoteOn()
      {
      	Message.ignoreEvent(true);
      	if (!btnMute.getValue())
      	{
      		velocityValues[Message.getNoteNumber()] = Message.getVelocity();
      		lengthValues[Message.getNoteNumber()] = Engine.getUptime();
      	}
      }
      
      function onNoteOff()
      {
      	//If not muted and a velocity was recorded in the note on callback - this prevents release triggering for the wrong articulation
      	if (!btnMute.getValue() && velocityValues[Message.getNoteNumber()] > 0)
      	{
      		Message.ignoreEvent(true);
              //Calculate attenuation
      		if(btnAttenuate.getValue() == 1)
      		{
      			//time = Engine.getUptime() - lengthValues.getValue(Message.getNoteNumber());
      		    time = Engine.getUptime() - lengthValues[Message.getNoteNumber()];
      			    
      			timeIndex = (time / (knbTime.getValue()) * 127.0);
      
      			if (timeIndex > 127) timeIndex = 127;
      			if (timeIndex < 0) timeIndex = 0;
      			attenuationLevel = /*velocityValues.getValue(Message.getNoteNumber()) **/ parseInt(tblTime.getTableValue(timeIndex) * 127);
      		} else {
      			attenuationLevel = velocityValues[Message.getNoteNumber()];
      		}
      
      		if (attenuationLevel < 1) attenuationLevel = 1;
      
      		Synth.playNote(Message.getNoteNumber(), attenuationLevel); //Play release note
      		velocityValues[Message.getNoteNumber()] = 0; //Reset velocity for note
      	}
      }
      
      function onController()
      {
      	
      }
      
      function onTimer()
      {
      	
      }
      
      function onControl(number, value)
      {
      	switch (number)
      	{
      		case btnMute:
      			velocityValues.clear();
      			lengthValues.clear();
      		break;
      
      		case btnAttenuate:
      			knbTime.set("visible", value);
      			tblTime.set("visible", value);
      		break;
      	}
      }
      
      1 Reply Last reply Reply Quote 1
      • d.healeyD
        d.healey
        last edited by d.healey

        I remember posting that, but looking at it I can't see what modification I made to Christoph's original script (the one that comes with HISE). Must have been a minor change (maybe I just added a mute button???).

        I have a different release trigger script that I use nowadays, under a different license too.

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

        1 Reply Last reply Reply Quote 1
        • E
          Ensou
          last edited by

          thanks for sharing that. i'll give it a try later.

          I used this one instead of the stock release trigger because it is way more consistent.
          For some weird reason the stock release trigger's Time Attenuation is giving me issues by not being consistent.
          eg: when it supposed to give the velocity value at 0.500ms but instead it gives out the value at 0ms.

          Only happens to me when the attenuation time table are maxed out.

          1 Reply Last reply Reply Quote 1
          • E
            Ensou
            last edited by Ensou

            @d-healey i just tried your script, it had the same issues as the original one before.
            Time Attenuation just "marches" across the table every note press instead of actually giving the note length.

            EDIT: Here's a video for demonstration:
            https://www.youtube.com/watch?v=Is_Q9DLsnK0&feature=youtu.be

            I assume the fix is the same as i did for the first one, apparently changing the collection type for the noteLength to an Array fixes it for me.

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

            20

            Online

            1.7k

            Users

            11.9k

            Topics

            103.2k

            Posts