How do I get and set pitch bend messages?
-
@VirtualVirgin They'll show up in the on controller callback as CC128
-
@d-healey said in How do I get and set pitch bend messages?:
@VirtualVirgin They'll show up in the on controller callback as CC128
Hi David :)
When I try to do this:
Synth.addController(Message.getChannel(), 128, Math.range(pbInput + pbChange, -8192, 8191), 0);
I get this:
Interface:! onNoteOn() - Line 25, column 22: CC number must be between 0 and 127
-
What about
Synth.sendController()
? -
@d-healey said in How do I get and set pitch bend messages?:
What about
Synth.sendController()
?So I tried Synth.sendController() and it is doing what I was afraid it would do:
Given that there is no input parameter for "channel", it creates all of the pitch bend messages on channel 1.
Here I am playing on channel 2, but the pitch bend remains on channel 1:
Can I change the channel of the pitch bend by script after generating it?
-
@VirtualVirgin said in How do I get and set pitch bend messages?:
Can I change the channel of the pitch bend by script after generating it?
Not that I'm aware of.
I've just been looking at the source code for
sendController
andaddController
and I don't think it would take much work to makeaddController
support pitch bend and aftertouch, it's really just a copy/paste job by the look of it. If you fancy playing with some C++, both functions are inScriptingApi.cpp
-
Actually it looks like there is a problem with
sendController
too when used with pitch bend, the CC value must be positive.I'll fix it up (including addController) and make a pull request.
-
Ok here's the PR https://github.com/christophhart/HISE/pull/626
I've fixed pitch bend handling in sendController and added it to addController. I did the same for aftertouch and program change.
I cleaned up the code quite a bit too because it was very nested which I find difficult to follow. I also added/changed error messages as needed. Hopefully it all works for you.
-
@d-healey said in How do I get and set pitch bend messages?:
Actually it looks like there is a problem with
sendController
too when used with pitch bend, the CC value must be positive.I'll fix it up (including addController) and make a pull request.
So, I looking into it I think pitch bend values are expected to be always positive:
https://studiocode.dev/kb/MIDI/midi-pitch-bend/#:~:text=Pitch Wheel Change (aka%20pitch,and%20the%20largest%20is%2016383.
So I modified my code to put the default input to 8192 and use that as the axis.
"pbChange" here gets updated depending on the conditions, but default is 0.
-
@VirtualVirgin Ah ok, in that case I need to update the change I made, so it should be a min of 0 and a max of 16383?
-
@d-healey said in How do I get and set pitch bend messages?:
@VirtualVirgin Ah ok, in that case I need to update the change I made, so it should be a min of 0 and a max of 16383?
Yes, I checked a few different sources on the spec and they all seem to agree that the expected range is 0-16383.
-
@VirtualVirgin Cool, thanks for checking. I tested in HISE too and it's the same. I'm updating my PR now.