Forum

    • Register
    • Login
    • Search
    • Categories

    Release triggers

    Presets / Snippets
    2
    4
    1080
    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.
    • d.healey
      d.healey last edited by

      Would you mind sharing the code of the built in release trigger script? I want to create a modified version to support a few other features.

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

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

        Never mind, I just realised it's already on GitHub 🙂

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

        1 Reply Last reply Reply Quote 0
        • Christoph Hart
          Christoph Hart last edited by

          Yes here is the source file:

          https://github.com/christophhart/HISE/blob/master/hi_scripting/scripting/HardcodedScriptProcessor.h

          This is C++ though so you might have to change a few things to make it valid Javascript.

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

            Here's my updated release trigger script. I've added a mute button so that release triggers can be disabled. I've also added a legato button: when this is enabled release triggers won't be played for each note of a legato phrase, they will only play when the last key is lifted.

            /**
             * Release Trigger v1.0.1
             * Author: Christoph Hart, David Healey
             * Date: 09/01/2017
             * Modified: 30/06/2017
             */
            
            //Includes 
            
            //Init
            Content.setHeight(175);
            Content.setName("Release Trigger");
            
            reg attenuationLevel = 1.0; 
            reg timeIndex = 0;
            reg time;
            const var velocityValues = Engine.createMidiList();
            const var lengthValues = Engine.createMidiList();
            
            const var btnMute = Content.addButton("btnMute", 0, 10);
            btnMute.set("text", "Mute");
            
            const var btnLegato = Content.addButton("btnLegato", 150, 10);
            btnLegato.set("text", "Legato");
            btnLegato.set("tooltip", "When enabled release samples will only be triggered when no other keys are held.");
            
            const var btnAttenuate = Content.addButton("Attenuate", 300, 10);
            
            const var knbTime = Content.addKnob("Time", 450, 0);
            knbTime.setRange(0, 20, 0.1);
            
            const var tblTime = Content.addTable("tblTime", 140, 0);
            tblTime.setPosition(0, 60, 575, 100);
            
            for(i = 0; i < 127; i++)
            {
            	velocityValues.setValue(i, 0);
            	lengthValues.setValue(i, 0.0);
            }
            
            //Functions
            
            //Callbacks
            function onNoteOn()
            {
            	if (!btnMute.getValue())
            	{
            		Message.ignoreEvent(true);
            		velocityValues.setValue(Message.getNoteNumber(), Message.getVelocity());
            		lengthValues.setValue(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.getValue(Message.getNoteNumber()) > 0)
            	{
            		Message.ignoreEvent(true);
            
            		//Only play release triggers if legato is disabled or legato is enabled and no keys are held
            		if (btnLegato.getValue() == 0 || (btnLegato.getValue() == 1 && Globals.keyCount == 0))
            		{
            			//Calculate attenuation
            			if(btnAttenuate.getValue() == 1)
            			{
            				time = Engine.getUptime() - lengthValues.getValue(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.getValue(Message.getNoteNumber());
            			}
            
            			if (attenuationLevel < 1) attenuationLevel = 1;
            
            			Synth.playNote(Message.getNoteNumber(), attenuationLevel); //Play release note
            		}
            		velocityValues.setValue(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;
            	}
            }
            

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

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

            17
            Online

            1.1k
            Users

            6.8k
            Topics

            62.5k
            Posts