How to Modify this script to allow endless MIDI Rotary Knob to be able to also scroll up and down with one knob?
Hello, please can somebody help me with this?
How to modify or add to this this script to allow endless MIDI Rotary Knob to be able to also scroll down?
So basically if I turn the knob the knob to the right scroll up and to the left down
I am using a MIDI Controller with an endless rotary kob that I set it up as CC and Rel 1 mode and I made it work in controllermate. but I want to replicate thisbehavior in Soundflow.
So the part is how to allow Soundflow to discern the change to scroll down when the input value is equal to 127 and to the scroll up when is equal to 1. or maybe you guys have a better way?
in this moment moving the knob up or down only scrolls up .
Thank you!
var win = sf.ui.proTools.windows.whoseTitle.startsWith("Plug-in: EQ").first;
if (!win.exists) throw 'Could not find window';
var winPos = win.position;
var pos = { x: winPos.x + 110, y: winPos.y + 150 };
var oldPos = sf.mouse.setPosition({
position: pos,
}).oldPosition;
sf.mouse.scroll({
delta: 1,
unit: 'Line',
});
sf.mouse.setPosition({ position: oldPos });
- Kitch Membery @Kitch2022-08-19 20:02:35.425Z
Hi @Reuven_Amiel,
Unfortunately I don't have any MIDI Rotary Knob's to test this out, however here is some information that may help.
A lot of MIDI controllers have an increment/decrement mode. In this mode, a controller continuously emits a value of 65 for every clockwise change (to the right) and a value of 63 for every counterclockwise change (to the left).
Based off this, you should be able to make an if else statement to trigger a + or - delta value to the mouse scroll.
This is untested, but you should be able to read the MIDI trigger event information by adding the following line of code to the script that has your rotary knob assigned.
const midiEventValue = event.trigger.midiBytes[0]; log(midiEventValue); if (midiEventValue === 65) { log("MIDI rotary encoder was turned clockwise (to the right)"); } else if (midiEventValue === 63) { log("MIDI rotary encoder was turned anti-clockwise (to the left)"); }
If this doesn't work or give you the information you need let me know and I'll see if I can get my hands on a rotary controller.
Reuven Amiel @Reuven_Amiel
Hi Kitch, thanks for your help.
Yes, you are right, depending of the translator, and yes values 63 Left, 65 Right counterclockwise and respectively clockwise . I was using other translator that basically when read equal goes left reads and when reads 127 goes right ... to just enable the increments ....so the numbers you are giving strictly MIDI wise make sense.
Will check it out in a few and keep you posted
Thanks
- In reply toKitch⬆:
Chris Shaw @Chris_Shaw2022-08-20 00:29:58.709Z
To make the the above snippet more robust I'd change it slightly as different controllers push different values for increment/decrement:
const midiEventValue = event.trigger.midiBytes[0]; log(midiEventValue); if (midiEventValue > 64) { log("MIDI rotary encoder was turned clockwise (to the right)"); } else if (midiEventValue < 64) { log("MIDI rotary encoder was turned anti-clockwise (to the left)"); }
Reuven Amiel @Reuven_Amiel
Yes you can limits de range between both values... I tried to make it clockwise:64 and anticlockwise:63 so when you turn left gives always 63 as in ON and right always 64
Thanks for the help Chris:Is not working yet, I do not know if the script specifies well that is a scroll and we can set the delta as the delta wiith " + or -" values dictates the direction of the scroll .
For example:
anti-clockwise: value:63 scroll. delta: -1
Clockwise : value: 64 scroll delta: +1so connect this to a Midi Value 63:
sf.mouse.scroll({
delta: -1,
unit: 'Line',
});and this to a Midi Value 64
sf.mouse.scroll({
delta: +1,
unit: 'Line',
});Thanks
- In reply toReuven_Amiel⬆:Reuven Amiel @Reuven_Amiel
Hi...
I tried it is not working... and yes I set the knob to give me a continues 63 value anti-clockwise and 65 Clockwise
this is the error soundflow reports:
20.08.2022 01:12:46.91 [Backend]: JavaScript error with InnerException: null
!! Command Error: Scroll Up Copy [user:ckjdi4ajl000anw10igxo5qwv:cl6y0pld90001ui10pyejz9gy]:
ReferenceError: midiEventValue is not defined
(Scroll Up Copy line 1)this works:
sf.mouse.scroll({ delta: +1, unit: 'Line', });
But if you move left or right goes always up obviously as De1ta: +1 and there is not any values that separates from going left or right .
The idea is to set a part where as you said when MIDI is 65 scrolls delta +1 (up) Unit Line
and when MIDI is 63 Scrolls delta -1 (Down)I am using to test this the Behringer BRC2000 that is very Flexible
You have 2 Values for increment and decrement that can be each from 0 to 127
I set the Knobs like this:
Type: CC Ch:1 Value1: 63 Value2: 65 Mode: Relative 1We can set the Value 1 and 2 any way...most common are 63 and 65 and 1 and 127.
What is very important is to be able to change the delta value as this allows you to set the sensitivity of the knob.Thank you so much and hope you can help with this.
- In reply toReuven_Amiel⬆:
Kitch Membery @Kitch2022-08-20 07:14:11.333Z
Hi @Reuven_Amiel,
On further inspection into what you are trying to achieve, there is extensive testing and troubleshooting involved, and without access to an endless MIDI Rotary Knob. I'm not in a position to be able to provide much more assistance.
In the script I provided in my last post I noticed a few things that needed changing along with @Chris_Shaw's suggestion. The midi message that I was reading was not the CC value. The following change should fix that.
const midiEventValue = event.trigger.midiBytes[2]; if (midiEventValue >64) { log("MIDI rotary encoder was turned clockwise (to the right)"); } else if (midiEventValue <64) { log("MIDI rotary encoder was turned anti-clockwise (to the left)"); }
However, this will only get you part of the way as there may be multiple MIDI messages that need to be dealt with once you start triggering the script.
Regarding your question on the direction of the scroll, yes the
delta
+1 value scrolls up and thedelta: -1
scrolls down.If this sort of functionality is something you would like to see in a future version of SoundFlow please be sure to request the feature in the Ideas Section of the SoundFlow Forum
On a side note: Please check this tutorial for how to quote code in the SoundFlow forum, so that it displays in a readable format:
Reuven Amiel @Reuven_Amiel
@Kitch_Membery Thanks for your help, hopefully in the near future for MIDI functionality and mouse emulation Features are implements in Soundflow.
In the meantime will continue trying this
- In reply toKitch⬆:AAndrew Sherman @Andrew_Sherman8
Hi Kitch, I hope you're well. Is there any further update on when we might see more midi emulation and functionality in Soundflow? I know it's coming at some point. I'm trying to use endless rotary encoders on my controller but I'm not getting anywhere with it.
Kitch Membery @Kitch2022-10-27 18:53:07.573Z
Hi @Andrew_Sherman8,
There have been no further updates made in regard to MIDI functionality, unfortunately. I'll let you know if anything changes. :-)
- AAndrew Sherman @Andrew_Sherman8
No worries Kitch, looking forward to what comes next from Soundflow.
Kitch Membery @Kitch2022-10-27 20:12:30.153Z
Thanks, Andrew :-) Rock on!