HISE Logo Forum
    • Categories
    • Register
    • Login

    Humaniser

    Scheduled Pinned Locked Moved Presets / Scripts / Ideas
    3 Posts 2 Posters 1.3k 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

      Here's a humaniser script. It basically applies a random adjustment to all the parameters that have a setting above 0. There are tooltips to explain each control. All bug reports and feedback/suggestions welcome.

      <?xml version="1.0" encoding="UTF-8"?>
      
      <Processor Type="ScriptProcessor" ID="Humaniser" Bypassed="0" Script="/**&#10; * Humaniser v1.0&#10; * Author: David Healey&#10; * Date: 08/01/2017&#10; * License: GPLv3 - https://www.gnu.org/licenses/gpl-3.0.en.html&#10; */&#10;&#10;//Includes &#10;&#10;//Init&#10;&#10;Content.setHeight(100);&#10;reg randNoteOnDelay;&#10;reg randNoteOffDelay;&#10;reg randVelocity;&#10;reg randFineTune;&#10;reg randVolume;&#10;reg randCC;&#10;&#10;const var ccNumbers = [];&#10;&#10;for (i = 0; i &lt; 129; i++)&#10;{&#10;&#9;ccNumbers[i] = i;&#10;}&#10;&#10;//GUI&#10;const var knbNoteOn = Content.addKnob(&quot;Note On&quot;, 0, 0);&#10;knbNoteOn.setRange(0, 100, 0.1);&#10;knbNoteOn.set(&quot;suffix&quot;, &quot;ms&quot;);&#10;knbNoteOn.set(&quot;tooltip&quot;, &quot;Note On: adds random delay (0 ms - 100 ms) to the Note On of each note.&quot;);&#10;&#10;const var knbNoteOff = Content.addKnob(&quot;Note Off&quot;, 150, 0);&#10;knbNoteOff.setRange(0, 100, 0.1);&#10;knbNoteOff.set(&quot;suffix&quot;, &quot;ms&quot;);&#10;knbNoteOff.set(&quot;tooltip&quot;, &quot;Note Off: adds random delay (0 ms - 100 ms) to the Note Off of each note.&quot;);&#10;&#10;const var knbVelocity = Content.addKnob(&quot;Velocity&quot;, 300, 0);&#10;knbVelocity.setRange(0, 100, 1);&#10;knbVelocity.set(&quot;suffix&quot;, &quot;%&quot;);&#10;knbVelocity.set(&quot;tooltip&quot;, &quot;Velocity: adds or subtracts random value in selected +-range of played velocity.&quot;);&#10;&#10;const var knbFineTune = Content.addKnob(&quot;FineTuning&quot;, 450, 0);&#10;knbFineTune.setRange(0, 100, 1);&#10;knbFineTune.set(&quot;tooltip&quot;, &quot;Fine Tuning: detunes each note randomly in the selected +-range - up to 1 semi-tone.&quot;);&#10;&#10;const var knbVolume = Content.addKnob(&quot;Volume&quot;, 600, 0);&#10;knbVolume.setRange(0, 8, 0.1);&#10;knbVolume.set(&quot;suffix&quot;, &quot;dB&quot;);&#10;knbVolume.set(&quot;tooltip&quot;, &quot;Volume: changes the volume of each note randomly from -8db to +8 db.&quot;);&#10;&#10;const var cmbCC1 = Content.addComboBox(&quot;CC 1&quot;, 0, 60);&#10;cmbCC1.set(&quot;items&quot;, ccNumbers.join(&quot;\n&quot;));&#10;cmbCC1.set(&quot;text&quot;, &quot;First CC&quot;);&#10;cmbCC1.set(&quot;tooltip&quot;, &quot;First CC Number: Select a CC number to humaniser.&quot;);&#10;&#10;const var knbCC1 = Content.addKnob(&quot;First CC&quot;, 150, 50);&#10;knbCC1.setRange(0, 100, 1);&#10;knbCC1.set(&quot;suffix&quot;, &quot;%&quot;);&#10;knbCC1.set(&quot;tooltip&quot;, &quot;First CC: adjusts the CC value by a random percentage in the +-range selected.&quot;);&#10;&#10;const var cmbCC2 = Content.addComboBox(&quot;CC 2&quot;, 300, 60);&#10;cmbCC2.set(&quot;items&quot;, ccNumbers.join(&quot;\n&quot;));&#10;cmbCC2.set(&quot;text&quot;, &quot;Second CC&quot;);&#10;cmbCC2.set(&quot;tooltip&quot;, &quot;Second CC Number: Select a CC number to humaniser.&quot;);&#10;&#10;const var knbCC2 = Content.addKnob(&quot;Second CC&quot;, 450, 50);&#10;knbCC2.setRange(0, 100, 1);&#10;knbCC2.set(&quot;suffix&quot;, &quot;%&quot;);&#10;knbCC2.set(&quot;tooltip&quot;, &quot;Second CC: adjusts the CC value by a random percentage in the +-range selected.&quot;);&#10;&#10;//Functions&#10;&#10;//Callbacks&#10;function onNoteOn()&#10;{&#10;&#9;//Note On&#10;&#9;if (knbNoteOn.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randNoteOnDelay = Math.floor(Math.random() * knbNoteOn.getValue());&#10;&#9;&#9;Message.delayEvent(Engine.getSamplesForMilliSeconds(randNoteOnDelay));&#10;&#9;}&#10;&#10;&#9;//Velocity&#10;&#9;if (knbVelocity.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randVelocity = -1;&#10;&#9;&#9;while (randVelocity == -1 || randVelocity &lt; 1 || randVelocity &gt; 127)&#10;&#9;&#9;{&#10;&#9;&#9;&#9;randVelocity = Math.ceil(Message.getVelocity() + ((Math.random() * (127 - -127 + 1)) + -127) * knbVelocity.getValue() / 100);&#10;&#9;&#9;}&#9;&#9;&#10;&#10;&#9;&#9;Message.setVelocity(randVelocity); //Apply random velocity&#10;&#9;}&#10;&#10;&#9;//Fine Tuning&#10;&#9;if (knbFineTune.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randFineTune = Math.floor(Math.random() * (knbFineTune.getValue() - -knbFineTune.getValue() + 1)) + -knbFineTune.getValue();&#10;&#9;&#9;Message.setFineDetune(Message.getFineDetune()+randFineTune);&#10;&#9;}&#10;&#10;&#9;//Volume&#10;&#9;if (knbVolume.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randVolume = Math.random() * (knbVolume.getValue() - -knbVolume.getValue() + 1) + -knbVolume.getValue();&#10;&#9;&#9;Message.setGain(Message.getGain() + randVolume);&#10;&#9;}&#10;}&#10;&#10;function onNoteOff()&#10;{&#10;&#9;//Note Off&#10;&#9;if (knbNoteOff.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randNoteOffDelay = Math.floor(Math.random() * knbNoteOff.getValue());&#10;&#9;&#9;Message.delayEvent(Engine.getSamplesForMilliSeconds(randNoteOffDelay));&#10;&#9;}&#10;}&#10;&#10;function onController()&#10;{&#10;&#9;if (Message.getControllerNumber() == cmbCC1.getValue()-1 &amp;&amp; knbCC1.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randCC = -1;&#10;&#9;&#9;while (randCC == -1 || randCC &lt; 1 || randCC &gt; 127)&#10;&#9;&#9;{&#10;&#9;&#9;&#9;randCC = Math.ceil(Message.getControllerValue() + ((Math.random() * (127 - -127 + 1)) + -127) * knbCC1.getValue() / 100);&#10;&#9;&#9;}&#9;&#10;&#10;&#9;&#9;Message.setControllerValue(randCC);&#10;&#9;}&#10;&#10;&#9;if (Message.getControllerNumber() == cmbCC2.getValue()-1 &amp;&amp; knbCC2.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randCC = -1;&#10;&#9;&#9;while (randCC == -1 || randCC &lt; 1 || randCC &gt; 127)&#10;&#9;&#9;{&#10;&#9;&#9;&#9;randCC = Math.ceil(Message.getControllerValue() + ((Math.random() * (127 - -127 + 1)) + -127) * knbCC2.getValue() / 100);&#10;&#9;&#9;}&#9;&#10;&#10;&#9;&#9;Message.setControllerValue(randCC);&#10;&#9;}&#10;}&#10;&#10;function onTimer()&#10;{&#10;&#9;&#10;}&#10;function onControl(number, value)&#10;{&#10;&#9;&#10;}&#10;">
        <EditorStates BodyShown="1" Visible="1" Solo="0" contentShown="1" onInitOpen="0"
                      onNoteOnOpen="0" onNoteOffOpen="0" onControllerOpen="0" onTimerOpen="0"
                      onControlOpen="0"/>
        <ChildProcessors/>
        <Content>
          <Control type="ScriptSlider" id="Note On" value="0"/>
          <Control type="ScriptSlider" id="Note Off" value="0"/>
          <Control type="ScriptSlider" id="Velocity" value="0"/>
          <Control type="ScriptSlider" id="FineTuning" value="0"/>
          <Control type="ScriptSlider" id="Volume" value="0"/>
          <Control type="ScriptComboBox" id="CC 1" value="2"/>
          <Control type="ScriptSlider" id="First CC" value="0"/>
          <Control type="ScriptComboBox" id="CC 2" value="12"/>
          <Control type="ScriptSlider" id="Second CC" value="0"/>
        </Content>
      </Processor>
      

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

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

        You're on fire :)

        The code looks fine (nothing to improve there except for maybe not writing an equation like this :)

        ((Math.random() * (127 - -127 + 1)) + -127)
        // better - if I got the math right:
        (Math.random()-0.5)*127
        

        Unlike a C++ compiler, the Javascript interpreter won't optimize this into a literal but calculate it each time (it also should be easier to read).

        But there is an issue when using the noteOn random delay and very short notes which cause stuck notes if the delay is longer than the note length (because then the note on will be delayed after the note off. You'll need to add the note on delay to every note off delay with the same note number (not 100% bulletproof, but better than the current solution):

        <?xml version="1.0" encoding="UTF-8"?>
        
        <Processor Type="ScriptProcessor" ID="Humaniser" Bypassed="0" Script="/**&#10; * Humaniser v1.0&#10; * Author: David Healey&#10; * Date: 08/01/2017&#10; * License: GPLv3 - https://www.gnu.org/licenses/gpl-3.0.en.html&#10; */&#10;&#10;//Includes &#10;&#10;//Init&#10;&#10;Content.setHeight(100);&#10;reg randNoteOnDelay;&#10;reg randNoteOffDelay;&#10;reg randVelocity;&#10;reg randFineTune;&#10;reg randVolume;&#10;reg randCC;&#10;&#10;const var ccNumbers = [];&#10;&#13;&#10;const var noteOnDelays = Engine.createMidiList();&#13;&#10;noteOnDelays.fill(0); // default is -1, so we need to set it to zero.&#13;&#10;&#10;for (i = 0; i &lt; 129; i++)&#10;{&#10;&#9;ccNumbers[i] = i;&#10;}&#10;&#10;//GUI&#10;const var knbNoteOn = Content.addKnob(&quot;Note On&quot;, 0, 0);&#10;knbNoteOn.setRange(0, 100, 0.1);&#10;knbNoteOn.set(&quot;suffix&quot;, &quot;ms&quot;);&#10;knbNoteOn.set(&quot;tooltip&quot;, &quot;Note On: adds random delay (0 ms - 100 ms) to the Note On of each note.&quot;);&#10;&#10;const var knbNoteOff = Content.addKnob(&quot;Note Off&quot;, 150, 0);&#10;knbNoteOff.setRange(0, 100, 0.1);&#10;knbNoteOff.set(&quot;suffix&quot;, &quot;ms&quot;);&#10;knbNoteOff.set(&quot;tooltip&quot;, &quot;Note Off: adds random delay (0 ms - 100 ms) to the Note Off of each note.&quot;);&#10;&#10;const var knbVelocity = Content.addKnob(&quot;Velocity&quot;, 300, 0);&#10;knbVelocity.setRange(0, 100, 1);&#10;knbVelocity.set(&quot;suffix&quot;, &quot;%&quot;);&#10;knbVelocity.set(&quot;tooltip&quot;, &quot;Velocity: adds or subtracts random value in selected +-range of played velocity.&quot;);&#10;&#10;const var knbFineTune = Content.addKnob(&quot;FineTuning&quot;, 450, 0);&#10;knbFineTune.setRange(0, 100, 1);&#10;knbFineTune.set(&quot;tooltip&quot;, &quot;Fine Tuning: detunes each note randomly in the selected +-range - up to 1 semi-tone.&quot;);&#10;&#10;const var knbVolume = Content.addKnob(&quot;Volume&quot;, 600, 0);&#10;knbVolume.setRange(0, 8, 0.1);&#10;knbVolume.set(&quot;suffix&quot;, &quot;dB&quot;);&#10;knbVolume.set(&quot;tooltip&quot;, &quot;Volume: changes the volume of each note randomly from -8db to +8 db.&quot;);&#10;&#10;const var cmbCC1 = Content.addComboBox(&quot;CC 1&quot;, 0, 60);&#10;cmbCC1.set(&quot;items&quot;, ccNumbers.join(&quot;\n&quot;));&#10;cmbCC1.set(&quot;text&quot;, &quot;First CC&quot;);&#10;cmbCC1.set(&quot;tooltip&quot;, &quot;First CC Number: Select a CC number to humaniser.&quot;);&#10;&#10;const var knbCC1 = Content.addKnob(&quot;First CC&quot;, 150, 50);&#10;knbCC1.setRange(0, 100, 1);&#10;knbCC1.set(&quot;suffix&quot;, &quot;%&quot;);&#10;knbCC1.set(&quot;tooltip&quot;, &quot;First CC: adjusts the CC value by a random percentage in the +-range selected.&quot;);&#10;&#10;const var cmbCC2 = Content.addComboBox(&quot;CC 2&quot;, 300, 60);&#10;cmbCC2.set(&quot;items&quot;, ccNumbers.join(&quot;\n&quot;));&#10;cmbCC2.set(&quot;text&quot;, &quot;Second CC&quot;);&#10;cmbCC2.set(&quot;tooltip&quot;, &quot;Second CC Number: Select a CC number to humaniser.&quot;);&#10;&#10;const var knbCC2 = Content.addKnob(&quot;Second CC&quot;, 450, 50);&#10;knbCC2.setRange(0, 100, 1);&#10;knbCC2.set(&quot;suffix&quot;, &quot;%&quot;);&#10;knbCC2.set(&quot;tooltip&quot;, &quot;Second CC: adjusts the CC value by a random percentage in the +-range selected.&quot;);&#10;&#10;//Functions&#10;&#10;//Callbacks&#10;function onNoteOn()&#10;{&#10;&#9;//Note On&#10;&#9;if (knbNoteOn.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randNoteOnDelay = Math.floor(Math.random() * knbNoteOn.getValue());&#10;&#9;&#9;Message.delayEvent(Engine.getSamplesForMilliSeconds(randNoteOnDelay));&#13;&#10;&#9;&#9;noteOnDelays.setValue(Message.getNoteNumber(), randNoteOnDelay);&#10;&#9;}&#10;&#10;&#9;//Velocity&#10;&#9;if (knbVelocity.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randVelocity = -1;&#10;&#9;&#9;while (randVelocity == -1 || randVelocity &lt; 1 || randVelocity &gt; 127)&#10;&#9;&#9;{&#10;&#9;&#9;&#9;randVelocity = Math.ceil(Message.getVelocity() + ((Math.random() * (127 - -127 + 1)) + -127) * knbVelocity.getValue() / 100);&#10;&#9;&#9;}&#9;&#9;&#10;&#10;&#9;&#9;Message.setVelocity(randVelocity); //Apply random velocity&#10;&#9;}&#10;&#10;&#9;//Fine Tuning&#10;&#9;if (knbFineTune.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randFineTune = Math.floor(Math.random() * (knbFineTune.getValue() - -knbFineTune.getValue() + 1)) + -knbFineTune.getValue();&#10;&#9;&#9;Message.setFineDetune(Message.getFineDetune()+randFineTune);&#10;&#9;}&#10;&#10;&#9;//Volume&#10;&#9;if (knbVolume.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randVolume = Math.random() * (knbVolume.getValue() - -knbVolume.getValue() + 1) + -knbVolume.getValue();&#10;&#9;&#9;Message.setGain(Message.getGain() + randVolume);&#10;&#9;}&#10;}&#10;&#10;function onNoteOff()&#10;{&#10;&#9;//Note Off&#10;&#9;if (knbNoteOff.getValue() &gt; 0 || knbNoteOn.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randNoteOffDelay = Math.floor(Math.random() * knbNoteOff.getValue());&#13;&#10;&#9;&#9;randNoteOffDelay += noteOnDelays.getValue(Message.getNoteNumber());&#13;&#10;&#9;&#9;&#10;&#9;&#9;Message.delayEvent(Engine.getSamplesForMilliSeconds(randNoteOffDelay));&#10;&#9;}&#10;}&#10;&#10;function onController()&#10;{&#10;&#9;if (Message.getControllerNumber() == cmbCC1.getValue()-1 &amp;&amp; knbCC1.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randCC = -1;&#10;&#9;&#9;while (randCC == -1 || randCC &lt; 1 || randCC &gt; 127)&#10;&#9;&#9;{&#10;&#9;&#9;&#9;randCC = Math.ceil(Message.getControllerValue() + ((Math.random() * (127 - -127 + 1)) + -127) * knbCC1.getValue() / 100);&#10;&#9;&#9;}&#9;&#10;&#10;&#9;&#9;Message.setControllerValue(randCC);&#10;&#9;}&#10;&#10;&#9;if (Message.getControllerNumber() == cmbCC2.getValue()-1 &amp;&amp; knbCC2.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randCC = -1;&#10;&#9;&#9;while (randCC == -1 || randCC &lt; 1 || randCC &gt; 127)&#10;&#9;&#9;{&#10;&#9;&#9;&#9;randCC = Math.ceil(Message.getControllerValue() + ((Math.random() * (127 - -127 + 1)) + -127) * knbCC2.getValue() / 100);&#10;&#9;&#9;}&#9;&#10;&#10;&#9;&#9;Message.setControllerValue(randCC);&#10;&#9;}&#10;}&#10;&#10;function onTimer()&#10;{&#10;&#9;&#10;}&#10;function onControl(number, value)&#10;{&#10;&#9;&#10;}&#10;">
          <EditorStates BodyShown="1" Visible="1" Solo="0" contentShown="1" onInitOpen="0"
                        onNoteOnOpen="0" onNoteOffOpen="1" onControllerOpen="0" onTimerOpen="0"
                        onControlOpen="0"/>
          <ChildProcessors/>
          <Content>
            <Control type="ScriptSlider" id="Note On" value="100"/>
            <Control type="ScriptSlider" id="Note Off" value="0"/>
            <Control type="ScriptSlider" id="Velocity" value="0"/>
            <Control type="ScriptSlider" id="FineTuning" value="0"/>
            <Control type="ScriptSlider" id="Volume" value="0"/>
            <Control type="ScriptComboBox" id="CC 1" value="2"/>
            <Control type="ScriptSlider" id="First CC" value="0"/>
            <Control type="ScriptComboBox" id="CC 2" value="12"/>
            <Control type="ScriptSlider" id="Second CC" value="0"/>
          </Content>
        </Processor>
        
        1 Reply Last reply Reply Quote 1
        • d.healeyD
          d.healey
          last edited by d.healey

          Aha that's interesting, I tried with longer note delays and got stuck notes - now I know why :)

          Edit: Here's the revised version.

          <?xml version="1.0" encoding="UTF-8"?>
          
          <Processor Type="ScriptProcessor" ID="Humaniser" Bypassed="0" Script="/**&#10; * Humaniser v1.1&#10; * Author: David Healey, Christoph Hart&#10; * Date: 08/01/2017&#10; * License: GPLv3 - https://www.gnu.org/licenses/gpl-3.0.en.html&#10; */&#10;&#10;//Includes &#10;&#10;//Init&#10;Content.setHeight(100);&#10;reg randNoteOnDelay;&#10;reg randNoteOffDelay;&#10;reg randVelocity;&#10;reg randFineTune;&#10;reg randVolume;&#10;reg randCC;&#10;&#10;const var noteOnDelays = Engine.createMidiList();&#10;noteOnDelays.fill(0); // default is -1, so we need to set it to zero.&#10;&#10;const var ccNumbers = [];&#10;&#10;for (i = 0; i &lt; 129; i++)&#10;{&#10;&#9;ccNumbers[i] = i;&#10;}&#10;&#10;//GUI&#10;const var knbNoteOn = Content.addKnob(&quot;Note On&quot;, 0, 0);&#10;knbNoteOn.setRange(0, 100, 0.1);&#10;knbNoteOn.set(&quot;suffix&quot;, &quot;ms&quot;);&#10;knbNoteOn.set(&quot;tooltip&quot;, &quot;Note On: adds random delay (0 ms - 100 ms) to the Note On of each note.&quot;);&#10;&#10;const var knbNoteOff = Content.addKnob(&quot;Note Off&quot;, 150, 0);&#10;knbNoteOff.setRange(0, 100, 0.1);&#10;knbNoteOff.set(&quot;suffix&quot;, &quot;ms&quot;);&#10;knbNoteOff.set(&quot;tooltip&quot;, &quot;Note Off: adds random delay (0 ms - 100 ms) to the Note Off of each note.&quot;);&#10;&#10;const var knbVelocity = Content.addKnob(&quot;Velocity&quot;, 300, 0);&#10;knbVelocity.setRange(0, 100, 1);&#10;knbVelocity.set(&quot;suffix&quot;, &quot;%&quot;);&#10;knbVelocity.set(&quot;tooltip&quot;, &quot;Velocity: adds or subtracts random value in selected +-range of played velocity.&quot;);&#10;&#10;const var knbFineTune = Content.addKnob(&quot;FineTuning&quot;, 450, 0);&#10;knbFineTune.setRange(0, 100, 1);&#10;knbFineTune.set(&quot;tooltip&quot;, &quot;Fine Tuning: detunes each note randomly in the selected +-range - up to 1 semi-tone.&quot;);&#10;&#10;const var knbVolume = Content.addKnob(&quot;Volume&quot;, 600, 0);&#10;knbVolume.setRange(0, 8, 0.1);&#10;knbVolume.set(&quot;suffix&quot;, &quot;dB&quot;);&#10;knbVolume.set(&quot;tooltip&quot;, &quot;Volume: changes the volume of each note randomly from -8db to +8 db.&quot;);&#10;&#10;const var cmbCC1 = Content.addComboBox(&quot;CC 1&quot;, 0, 60);&#10;cmbCC1.set(&quot;items&quot;, ccNumbers.join(&quot;\n&quot;));&#10;cmbCC1.set(&quot;text&quot;, &quot;First CC&quot;);&#10;cmbCC1.set(&quot;tooltip&quot;, &quot;First CC Number: Select a CC number to humaniser.&quot;);&#10;&#10;const var knbCC1 = Content.addKnob(&quot;First CC&quot;, 150, 50);&#10;knbCC1.setRange(0, 100, 1);&#10;knbCC1.set(&quot;suffix&quot;, &quot;%&quot;);&#10;knbCC1.set(&quot;tooltip&quot;, &quot;First CC: adjusts the CC value by a random percentage in the +-range selected.&quot;);&#10;&#10;const var cmbCC2 = Content.addComboBox(&quot;CC 2&quot;, 300, 60);&#10;cmbCC2.set(&quot;items&quot;, ccNumbers.join(&quot;\n&quot;));&#10;cmbCC2.set(&quot;text&quot;, &quot;Second CC&quot;);&#10;cmbCC2.set(&quot;tooltip&quot;, &quot;Second CC Number: Select a CC number to humaniser.&quot;);&#10;&#10;const var knbCC2 = Content.addKnob(&quot;Second CC&quot;, 450, 50);&#10;knbCC2.setRange(0, 100, 1);&#10;knbCC2.set(&quot;suffix&quot;, &quot;%&quot;);&#10;knbCC2.set(&quot;tooltip&quot;, &quot;Second CC: adjusts the CC value by a random percentage in the +-range selected.&quot;);&#10;&#10;//Functions&#10;&#10;//Callbacks&#10;function onNoteOn()&#10;{&#10;&#9;//Note On&#10;&#9;if (knbNoteOn.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randNoteOnDelay = Math.floor(Math.random() * knbNoteOn.getValue());&#10;&#9;&#9;Message.delayEvent(Engine.getSamplesForMilliSeconds(randNoteOnDelay));&#10;&#9;&#9;noteOnDelays.setValue(Message.getNoteNumber(), randNoteOnDelay);&#10;&#9;}&#10;&#10;&#9;//Velocity&#10;&#9;if (knbVelocity.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randVelocity = -1;&#10;&#9;&#9;while (randVelocity == -1 || randVelocity &lt; 1 || randVelocity &gt; 127)&#10;&#9;&#9;{&#10;&#9;&#9;&#9;randVelocity = Math.ceil(Message.getVelocity() + ((Math.random() -0.5) * 127) * knbVelocity.getValue() / 100);&#10;&#9;&#9;}&#9;&#9;&#10;&#10;&#9;&#9;Message.setVelocity(randVelocity); //Apply random velocity&#10;&#9;}&#10;&#10;&#9;//Fine Tuning&#10;&#9;if (knbFineTune.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randFineTune = Math.floor(Math.random() * (knbFineTune.getValue() - -knbFineTune.getValue() + 1)) + -knbFineTune.getValue();&#10;&#9;&#9;Message.setFineDetune(Message.getFineDetune()+randFineTune);&#10;&#9;}&#10;&#10;&#9;//Volume&#10;&#9;if (knbVolume.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randVolume = Math.random() * (knbVolume.getValue() - -knbVolume.getValue() + 1) + -knbVolume.getValue();&#10;&#9;&#9;Message.setGain(Message.getGain() + randVolume);&#10;&#9;}&#10;}&#10;&#10;function onNoteOff()&#10;{&#10;&#9;//Note Off&#10;&#9;if (knbNoteOff.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randNoteOffDelay = Math.floor(Math.random() * knbNoteOff.getValue());&#10;&#9;&#9;randNoteOffDelay += noteOnDelays.getValue(Message.getNoteNumber()); //Add any note on delay for this note&#10;&#10;&#9;&#9;Message.delayEvent(Engine.getSamplesForMilliSeconds(randNoteOffDelay));&#10;&#9;}&#10;}&#10;&#10;function onController()&#10;{&#10;&#9;if (Message.getControllerNumber() == cmbCC1.getValue()-1 &amp;&amp; knbCC1.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randCC = -1;&#10;&#9;&#9;while (randCC == -1 || randCC &lt; 1 || randCC &gt; 127)&#10;&#9;&#9;{&#10;&#9;&#9;&#9;randCC = Math.ceil(Message.getControllerValue() + ((Math.random() -0.5) * 127) * knbCC1.getValue() / 100);&#10;&#9;&#9;}&#9;&#10;&#10;&#9;&#9;Message.setControllerValue(randCC);&#10;&#9;}&#10;&#10;&#9;if (Message.getControllerNumber() == cmbCC2.getValue()-1 &amp;&amp; knbCC2.getValue() &gt; 0)&#10;&#9;{&#10;&#9;&#9;randCC = -1;&#10;&#9;&#9;while (randCC == -1 || randCC &lt; 1 || randCC &gt; 127)&#10;&#9;&#9;{&#10;&#9;&#9;&#9;randCC = Math.ceil(Message.getControllerValue() + ((Math.random() -0.5) * 127) * knbCC2.getValue() / 100);&#10;&#9;&#9;}&#9;&#10;&#10;&#9;&#9;Message.setControllerValue(randCC);&#10;&#9;}&#10;}&#10;&#10;function onTimer()&#10;{&#10;&#9;&#10;}&#10;function onControl(number, value)&#10;{&#10;&#9;&#10;}&#10;">
            <EditorStates BodyShown="1" Visible="1" Solo="0" contentShown="1" onInitOpen="0"
                          onNoteOnOpen="0" onNoteOffOpen="0" onControllerOpen="0" onTimerOpen="0"
                          onControlOpen="0"/>
            <ChildProcessors/>
            <Content>
              <Control type="ScriptSlider" id="Note On" value="0"/>
              <Control type="ScriptSlider" id="Note Off" value="0"/>
              <Control type="ScriptSlider" id="Velocity" value="0"/>
              <Control type="ScriptSlider" id="FineTuning" value="0"/>
              <Control type="ScriptSlider" id="Volume" value="0"/>
              <Control type="ScriptComboBox" id="CC 1" value="2"/>
              <Control type="ScriptSlider" id="First CC" value="0"/>
              <Control type="ScriptComboBox" id="CC 2" value="12"/>
              <Control type="ScriptSlider" id="Second CC" value="0"/>
            </Content>
          </Processor>
          

          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

          43

          Online

          1.7k

          Users

          11.7k

          Topics

          101.9k

          Posts