Jump to content

A simple script to manually generate MIDI CC messages


Recommended Posts

Hey all,

Just made this simple script for Scripter, mainly as a workaround for plugins that don't show mod wheel in their piano roll, but you can use it to trigger any CC message down to the plugin. Used it for example to to some midi learn onto zebra, without having any midi keyboard connected. You can even automate the sliders of the script so it'll generate the corresponding midi messages (track automation doesn't allow you to write CC automation, you need to do that in midi regions).

Hope that helps anyone 😉

File should be put in: /Users/username/Music/Audio\ Music\ Apps/Plug-In\ Settings/Scripter

image.png.4f617b09fd2e36c7305fc264123ece1d.png

GenerateCC.pst

  • Like 4
Link to comment
Share on other sites

  • 4 weeks later...
  • 6 months later...
  • 1 month later...
  • 1 month later...

@Altar of Wisdom,

Thanks for sharing your script!

I noticed something peculiar with the implementation of your Pitch Bend parameter.

You set a range of -127/127  in the Pitch Bend slider, and then in your ParameterChanged function you multiply the values by 128. This results in some values being outside the normal Pitch Bend range of -8192/8191. So, any values below -64 or above 63 will produce malformed Pitch Bend data (which will be ignored by whichever instrument receives it):Screenshot2023-12-15at17_13_51.thumb.png.884b71da18cce34764ab4d3c1612c614.png

This could be solved by using the full range and using the values "as is" (without multiplying them):

{
  name: 'Pitch Bend',
  type: 'lin',
  minValue: -8192,
  maxValue: 8191,
  numberOfSteps: 16383,
  defaultValue: 0,
}

 

 else if (param == 1) // Pitch Bend
 {
 	var pb = new PitchBend;
 	pb.value = value;
 	pb.channel = channel;
 	pb.send();
 }

 J.

  • Like 4
Link to comment
Share on other sites

On 12/15/2023 at 5:23 PM, Jordi Torres said:

@Altar of Wisdom,

Thanks for sharing your script!

I noticed something peculiar with the implementation of your Pitch Bend parameter.

You set a range of -127/127  in the Pitch Bend slider, and then in your ParameterChanged function you multiply the values by 128. This results in some values being outside the normal Pitch Bend range of -8192/8191. So, any values below -64 or above 63 will produce malformed Pitch Bend data (which will be ignored by whichever instrument receives it):Screenshot2023-12-15at17_13_51.thumb.png.884b71da18cce34764ab4d3c1612c614.png

This could be solved by using the full range and using the values "as is" (without multiplying them):

{
  name: 'Pitch Bend',
  type: 'lin',
  minValue: -8192,
  maxValue: 8191,
  numberOfSteps: 16383,
  defaultValue: 0,
}

 

 else if (param == 1) // Pitch Bend
 {
 	var pb = new PitchBend;
 	pb.value = value;
 	pb.channel = channel;
 	pb.send();
 }

 J.

Yes, sure, it's a bit awkward that some implemtentations use -128/127 and others -8192/8191, so I end up not being sure what to do. And Using -8192/8191 gives a huge range to that slider, no ?

Link to comment
Share on other sites

3 hours ago, Altar of Wisdom said:

And Using -8192/8191 gives a huge range to that slider, no ?

True, and with some synths you would hear no immediate change if you increase/decrease by one step at a time, but moving the slider up and down with the mouse gives the desired effect and no out-of-range values.

You could use a smaller range (as to be able to hear immediate change in pitch when increasing/decreasing by one step), but to not have values out of range in that context, you need to do some scaling of the range.

For example, to keep that range you have in your preset (-127 to 127) while scaling it, you could do something like this on you Pitch Bend plugin parameter:

{
  name: 'Pitch Bend',
  type: 'lin',
  minValue: -127,
  maxValue: 127,
  numberOfSteps: 254,
  defaultValue: 0,
}

Then add a scaling function which you would call inside ParameterChanged:

function scalePBRange(pbValue) {
    // Define the slider range
    const sliderMin = -127;
    const sliderMax = 127;

    // Define the full Pitch Bend range
    const pbMin = -8192;
    const pbMax = 8191;

    // Calculate the scaling factor
    const scaleFactor = (pbMax - pbMin) / (sliderMax - sliderMin);

    // Scale the value
    const scaledValue = Math.round(pbValue * scaleFactor + (pbMin + pbMax) / 2);

    // Ensure the scaled value is within the new range
    return Math.min(Math.max(scaledValue, pbMin), pbMax);
}

// Call scaling function inside ParameterChanged
 else if (param == 1) // Pitch Bend
 {
 	var pb = new PitchBend;
 	pb.value = scalePBRange(value);
 	pb.channel = channel;
 	pb.send();
 }

J.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...