HISE Logo Forum
    • Categories
    • Register
    • Login

    Controller Value To Note On Velocity

    Scheduled Pinned Locked Moved Presets / Scripts / Ideas
    3 Posts 2 Posters 773 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.
    • d.healeyD
      d.healey
      last edited by d.healey

      A simple little script to convert a selected controller's value to note on velocity. Handy if you want to control staccato sample dynamics with a CC instead of velocity for example. Or you could bypass the script to switch back to the default velocity based control.

      /**
       * Title: Controller Value To Note On Velocity v1.0.1
       * Author: David Healey
       * Date: 30/06/2017
       * Modified: 30/06/2017
       * License: Public Domain
      */
      
      Content.setHeight(50);
      
      const var knbCC = Content.addKnob("CC Number", 0, 0);
      knbCC.setRange(1, 127, 1);
      
      reg lastCCValue = 1;
      
      function onNoteOn()
      {
      	Message.setVelocity(lastCCValue);
      }
      
      function onNoteOff()
      {
      }
      
      function onController()
      {
      	if (Message.getControllerNumber() == knbCC.getValue())
      	{
      		lastCCValue = Math.max(1, Message.getControllerValue());
      	}
      }
      
      function onTimer()
      {
      }
      
      function onControl(number, value)
      {
      }
      

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

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

        I'd recommend using a reg variable for the lastCCValue. Also you can use

        lastCCValue = Math.max(1, Message.getControllerValue();
        

        to remove the if branch (shorter and slightly faster).

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

          Oh I'd completely forgotten Math.max(). Good idea! I'll update my original post

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

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

          47

          Online

          1.7k

          Users

          11.7k

          Topics

          102.2k

          Posts