Sustain Pedal Question
-
This post is deleted! -
To use MidiMuters you don't bypass/unbypass them, you instead set the
ignoreButton
parameter usingsetAttribute()
.However in this case I wouldn't use a midi muter. I would just write a script that blocks notes if the sustain pedal is pressed and drop that into the sampler.
Here's an example
HiseSnippet 1163.3oc2X8taZbDDeOfypPZbShhh5GOE0O.RtNPqqakrrhMXHxpFajOG21OYs9tAXiua2q6tmqQU8cqOB8QIuAsyd2g4HPwXZRqRQB7sye1Y14O+l8LbiF39f+EJNKJBzDhUwdRgGnTBIwp7Yih.h0mZ6NhqG1ZHkwIGd.wZc6tTkFjNojZNJhpTfOwxp3qLDrJWhj74surIMfx8fIjHjyELO3HVHSOgZu89dVPPGpObFKLmzas2gdBdKQfHF8mh10IQTuqnCfioFwJXSrVqsOSKjtZpFTnLME9ibGJ9Edp7myTrKC.yhFDWbiRISZMjE3e6YUgmb6bm7hom7mZ2k4ytk9jHviRX3LQi7w.qBKxkZbObIqbtToTW5w1tdRVjdBGi+7.6C4XBoOEC04ckTYIV+tcKAJ.WuYH8JniDWbqBU2td8MbvepsS+XtmlI3NB9wBMbBuZsJ+ZkxU9sJNuKq98mKOiYjhf.PNW1lrqbQJVkGGdIH2v4ZZPLbqf3we5X5ZKWL0K8TmSPA+PNSeRDjstiHv2DqLOOaFfjE1vmd8gGP0TSRIiFJWDH0Li6Xc.bMVUmlhJae.ntRKhv55YxeXkivONfpmtbxz2jw.iGSkCMIJthoGkuu5dTiUeg0XKqK9X6dLs2v46iEliOhQpOD9XVm4Csa2uO3om3fkr67iqZa3xa90SM+CrcYbHAVLw3OKYsyOPuFbdEvAoI30XAHi+wxhLFszHim3oQyeljxUQB0TarKDxNSvMQgIDesBABfe9TS1LO8VBpbtrd6K6fGx4piKUGKSJK1OTDy0SUFTb57Pokq0c5NhbxOGbxR+G.cW+8Dz8mYGFafZciU52cZZF7cgexxFS1JsykZdWTZmccFimS88aFq0Bd0ma377MbZT278uELm02oZ11r4.PetAmsZsZUJWtK5T3n0MYC3BIz9Zb6qpkHJ7N+CF.XL23MFM2D1Gm.zWslyt65r8VF6O1qTi8pj9qMYprPSOvmFb.lKP2cmOTCVreeMXYQCSRmgfdEJpNo1X8rZizbIggo+0rMQCRh+lueZklDYjMLBg.L8lktKadCFGrpflZz3G9HXR1TsbkG6itrvn.nM+ZH.CRI93SvnReZbfdL0oAp6J3hngBNyKeT+TPKYCF.x799bOP6q03cTmP4o6cJD.z7HxewdGgHoTIFmfULVb+u43byWetcp65XZfb938FHE++8MPNUDqY7AcoXQno4DAOcwA+d.ZcNGBL.WVELPLoqqaVmN4m6mr3OwOYLaXVakwrwXl+qXiPpmTbgWJ3moN8SRnfmadxKzUFeyRbsSiYg8Bwo1W34M8VMihe0pp3WupJt0pp32rpJt8pp32tpJ9c2shlKUserVDl1ZRHc60NYLkkUaNEqxS5HH.ND1GegqzIOIu1celoEnf4OoV8KsOcHMRg8JMEHQYD1tCufw8Bh8A0KNRHtZeteG.B17MpwShS9mAPlYudjMdmUD09R7Rs92s30Vro6QQ.HPc26yyxaVbxanfe2J8PLZyY8AkdFYuMrwga5fJXvD9K.8.piN
The script
muteOnSustain
has a button on the UI calledMute
. When the sustain button is pressed or released the value of the button changes. In the on note on callback we check the value of the button and if it's 1 we ignore the incoming event. It doesn't do anything in the on note off callback because generally you don't want to ignore notes there otherwise you might get hanging notes, but in some situations (release triggers for example) you might want to put it there as well.If you want to invert the behaviour, so it only allows notes through when the mute button is enabled, change line 3 in the on note on callback to
if (!btnMute.getValue())
. -
@d-healey This seems like a better method than using midi muters, but I'm having trouble importing the HISE snippet, with HISE telling me its not a valid snippet or container file, so I've just tried to recreate what you are describing.
I have created a button on my NotesWithoutPedal Sampler interface, and I have specified my variables in the onInit like so...
Content.makeFrontInterface(600, 600); const var NotesWithoutPedal = Synth.getSampler("NotesWithoutPedal"); const var Button1 = Content.getComponent("Button1");
Then in my onNoteOn callback of the sampler I have these lines
function onNoteOn() { if (Synth.isSustainPedalDown() == true) Button1.setValue(1); Message.ignoreEvent(true); }
But now my sampler is not triggering any samples regardless of whether any button is pressed.
-
@ATWAW I'll take a look when I'm home in a few hours
-
@d-healey okay sounds good, thank you!
-
@ATWAW said in Sustain Pedal Question:
with HISE telling me its not a valid snippet or container file
The snippet will import correctly, this message is a bug in the latest develop branch, I've already reported the issue so you can ignore it.
@ATWAW said in Sustain Pedal Question:
I have created a button on my NotesWithoutPedal Sampler interface,
This is not part of the interface so shouldn't be in the interface script. Take a look at my snippet, the code goes in a separate midi processor within the sampler (sine wave generator in my snippet).
@ATWAW said in Sustain Pedal Question:
Then in my onNoteOn callback of the sampler I have these lines
That if statement won't work because you don't have curly braces, but I wouldn't do it that way anyway. The check for the sustain pedal state should be in the on controller callback. This then sets the button. You can skip the button altogether and just put the check directly in the on note on callback as you have done, but I think having a button is more elegant and makes it easier to test or link with other modules or the UI if that's something you need in the future.
-
I believe I got it working! Thank you, I still seem to have not been able to get the HISE snippet to work to see your exact code but thanks to the information you gave in your responses I was able to get it working. I am worried the way that I have done it is inefficient, so I am open to any suggestions for improvements.
I ended up using a global variable for my button on the interface, and I was wondering if that was the optimal way to do this or if there is a better way...
(interface) onInit
Content.makeFrontInterface(600, 600); Globals.Button1 = Content.getComponent("Button1");
(interface) onController
function onController() { if(Synth.isSustainPedalDown() == true) { Button1.setValue(1); } else { Button1.setValue(0); } }
(Piano Notes Without Pedal, Sampler1) onNoteOn
function onNoteOn() { if (Button1.getValue() == 1) { Message.ignoreEvent(true); } }
(Piano Notes With Pedal, Sampler2) onNoteOn
function onNoteOn() { if (Button1.getValue() == 0) { Message.ignoreEvent(true); } }
-
@ATWAW said in Sustain Pedal Question:
I ended up using a global variable
Global variables should be a last resort for any situation. Use setAttribute or parameter and processor id to communicate between modules.
What's the button on the interface for?
Can you show a video of what you see when you import the snippet?
-
@d-healey
Okay good to know,I was using the button on the interface to communicate the state of the sustain pedal on the UI itself, as well as a way to tell my other script modules to not play if the sustain is engaged. As I am explaing this I am realizing I could just use the "isSustainPedalDown" to accomplish the same thing :man_facepalming: am actively updating the code for both samplers as we speak.
(Notes with pedal, Sampler2) onNoteOn
function onNoteOn() { if (Synth.isSustainPedalDown() == 0) { Message.ignoreEvent(true); } }
How would I use the setAttribute or processor ID to communicate between modules? Would it be as simple as defining the "const var (insert ID)" within the onInit of the sampler I want to communicate with?
Here is the video of what happens when I try to import the HISE snippet into a new project
video of error message -
@ATWAW said in Sustain Pedal Question:
Here is the video of what happens when I try to import the HISE snippet into a new project
Ah that's different to the error I'm seeing, are you using the latest develop branch?
@Christoph-Hart Might want to take a look at this.
@ATWAW said in Sustain Pedal Question:
I was using the button on the interface to communicate the state of the sustain pedal on the UI itself, as well as a way to tell my other script modules to not play if the sustain is engaged.
So the button is both an indicator of the sustain pedal status and a functional button? I've actually just added something like this to one of my projects. In my case I am considering users who don't have a sustain pedal, so instead of only responding to CC64 they can right-click the button and assign which ever CC they like (the default though is still CC64). Is this something you'd like to do or do you only ever want it to respond to CC64?
-
I might not be on the latest version, I compiled four or so weeks ago, where would I find what version of HISE I am on?
It would be awesome to have the button be assignable for those few who don't have a sustain pedal, or just want to map sustain to something else. How would I go about getting the separate sampler scripts to communicate with one another to recognize the buttons state, you mentioned using "setAttribute" but I don't think I understand the context to use it under. Are buttons midi assignable by default in HISE, or does that require additional scripting?
-
@ATWAW said in Sustain Pedal Question:
where would I find what version of HISE I am on?
git log
but if you're not using git then the best you could do is look at the date the executable was modified.@ATWAW said in Sustain Pedal Question:
Are buttons midi assignable by default in HISE
Yes, there is a check box in the property editor to turn it on/off.
In the button's callback you can use
scriptReference.setAttribute(myAttribute, myValue);
to set any attribute of any of your other scripts. This is exactly the same as setting the attributes for built in modulators and effects. -
@d-healey
Wow thanks for the fast reply! It looks like the date on the executable is 03/20/2024, which does not seem to be the latest version, so that may be my issue with the snippet importing...My onController callback code seems to be working for triggering the different samplers, I am going to have to mess with the button features to get it to be able to trigger the sustain pedal. What function would I use to turn on a sustain pedal via a button on the interface, like I know how to reference the button but how do I actually get it to trigger the sustain pedal (without having to press the actual pedal in real life...)
-
@ATWAW said in Sustain Pedal Question:
What function would I use to turn on a sustain pedal via a button on the interface,
If you're only using the sustain pedal for standard sustain pedal sustaining, then you just need to send a CC64 message.
In the button's callback you could use.
Synth.sendController(64, component.getValue() == 0 ? 1 : 80);