CC filter



  • Hey guys,
    I am trying to mute midi input on a sampler for a particular range of CC.

    For example, I want a sampler to respond to midi and play notes when CC64 is between the values of 21-40, but to mute all midi events when CC is below and above that range.
    Effectively the controller allows or disallows midi input.

    Does anyone have a little script that can share with me, please? 😀

    P.S. I am aware of the table I could create in the gain section to lower the volume based on CC input, but it is not quite achieving desired results.

    Thank you.



  • @gorangrooves I wouldn't use CC64 since this is usually linked to sustain pedal and most sustain pedals act as on/off switches.

    Anyway, all you need to do is save the value of CC64 (or any CC you like) in on controller. You need to store the value in a variable you've declared in on init. Then in on note you just check the value of your variable and ignore the note if it's outside the range you want to use.



  • @d-healey Thank you. The reason I am using CC64 is because it is for a hi-hat controller and CC64 is used by default by drum modules.

    Any chance you could share a HISE snippet of what you described? 😛 As much as I perfectly understand the concept, I have no idea on how to actually code it to work.😕



  • 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 in on init and I'll call it ccvalue. I know that when CC64 is changed the on 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 in on 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 maybe Message.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?



  • @gorangrooves said in CC filter:

    setControllerValue(0);

    Is that a function you defined?



  • @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.

    e4a75e4f-d891-493b-8cbb-7ee69883d0c4-image.png

    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 in on note Message refers to a MIDI note message. This function will only work in the on controller callback.

    This is why I created a variable ccvalue and set its value in the on controller callback. You should be able to use Synth.sendController() in the on 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!


Log in to reply
 

10
Online

552
Users

2.1k
Topics

16.2k
Posts