Updated d-healey's Release Trigger



  • 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;
    	}
    }
    


  • 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.



  • 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.



  • @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:

    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.


Log in to reply
 

9
Online

552
Users

2.1k
Topics

16.1k
Posts