CC filter
-
I'm sure you could have figured this out. One thing I find helpful when trying to work out how to make a script do what I want is to write it out in English (or your language of choice), then all I have to do is replace the English with the scripting language - this works for any scripting language.
This example is pretty straightforward because it only has two sentences.
I want to save the value of CC64 whenever it changes.
If the value of CC64 that I have saved is in a certain range I want to ignore incoming notes.
Now I just need to convert it into a script.
I want to save the value of CC64 whenever it changes.
From this line I know I'm going to need a variable. So I'll put one inon init
and I'll call itccvalue
. I know that when CC64 is changed theon controller
callback will trigger. So I'll put a bit of code in that callback to set the value of my variable.If the value of CC64 that I have saved is in a certain range I want to ignore incoming notes.
This line tells me that I need to check the value of my variable inon note
(since that's where incoming notes are detected). And since I started that sentence with the word if it's likely that I'm going to need an if statement ;) I also used the word ignore so maybeMessage.ignore()
will come in handy.I haven't tested this and I've left setting up the exact CC value range to you, but it should do what you need.
reg ccValue = 0; function onNoteOn() { if (ccValue > 50) { Message.ignoreEvent(true); } } function onNoteOff() { } function onController() { if (Message.getControllerNumber() == 64) { ccValue = Message.getControllerValue(); } } function onTimer() { } function onControl(number, value) { }
-
@d-healey Thank you so much! I really appreciate you teaching me. I am learning bits, but it is going to take some time for sure.
I'll play with this code, analyze it and see if I can become a few bits smarter :)
Thank you !!! -
@d-healey Happy to report that the script works great! Further, I managed to edit Christoph's script for hi-hat choking and combine with this one to achieve choking controlled by CC. Wonderful stuff!
Thank you so much, once again!
-
@d-healey So, I am trying to get the last piece of the hi-hat puzzle sorted. I want to have a note (that I specify) set the controller value to 0 when played. I thought I had the right code, but I am getting "Ilegal operation in audio thread: String creation" error.
This is the code:
function onNoteOn() { local number = Message.getNoteNumber() + 1; if(number == trigger.getValue() || number == trigger2.getValue()) { setControllerValue(0); } }
setControllerValue(0);
is the line of code causing the error. Am I not using it correctly? Should I use something else or am I missing something?
-
-
@d-healey No. I was looking up Api commands.
-
@d-healey In your script you defined ccValue to be Message.getControllerValue();
Should I be referring to ccValue instead of setControllerValue and if so, how do I force the ccValue to be 0? -
@gorangrooves Ah I see.
When you look up a function in the API browser you will see it listed under the class name. In this case Message or MessageHolder. That means the function can only be used on instances of those classes.
To put it another way, you need to write it like this
Message.setControllerValue(0)
However this won't work in
on note
callback because inon note
Message
refers to a MIDI note message. This function will only work in theon controller
callback.This is why I created a variable
ccvalue
and set its value in theon controller
callback. You should be able to useSynth.sendController()
in theon note
callback, I think. -
how do I force the ccValue to be 0?
ccValue = 0;
The value is only set in
on controller
when CC64 changes, so as long is it hasn't changed you can set it to whatever value you like. -
@d-healey Thank you. I am running in circles here, no closer to solving it :)
How do I get it to set the controller to 0 as soon as a particular note is pressed?
I used
Synth.sendController(64,0);
And it sets the controller to 0, but only after I press a note twice. It doesn't do it right away. What am I missing here?...
-
@gorangrooves I'd need to see the rest of the code. Make a minimal example that demonstrates the issue
-
@d-healey I am trying to do that by opening 2 HISE samplers VST's and copying from to the other, but it is not working. How do you do it?
-
@gorangrooves I always work in the standalone version unless I'm testing something in a DAW.
-
@d-healey Managed to get it copied and simplified. Here is the link to the 13MB project (includes basic samples):
https://drive.google.com/open?id=1j2HXIoMjLVOQ3nOgbS-OnRqVBL0dEdIH
There are only samples on A0, 2 types: tight close and 100% open. Use the CC64 to switch between them. The first one sounds on the bottom 20 cc values and the second one is at the top 27 cc values.
When the cc64 is somewhere between 100-127 and open hat is sounding, it should be able to be muted by pressing either F#1 or G#1. Currently, either needs to be pressed twice for the choke to take effect. We want to achieve that with a single press.
I hope I managed to explain it clearly enough. Thank you so much for taking a look at it!