I'm trying to build what should be one of the simpler MIDI modules possible, but I'm not seeing my events in the debugger.
What I want to do is write an inverter for CC messages; if a CC 11 comes in with a value of 4, I want it to be converted to CC 11 with a value of 123. Basically, (-1*value)+127... as I have an expression pedal that doesn't have an inversion switch.
I have a knob (to select the CC parameter), a label whose value matches the knob, a MIDI input jack, a MIDI output jack.
My event handling for the knob seems to be correct; when I twiddle the knob, the value on the label changes as expected.
But my ProcessSample() is doing something wrong, and I don't know what; I actually put a System.out.println() in it to forcibly examine some values (namely, the state of the jacks) and I get *nothing*, no output. It's not a note-on or note-off event that I'm looking for, so I'm not sure how to capture MIDI CC messages; my thought is that ProcessSample isn't really the right spot for it, but I don't know where the right spot would BE.
Any advice?
MIDI Event processing
Re: MIDI Event processing
I can't help with your actual problem, but trying to debug ProcessSample with println (or breakpoints) isn't going to be much fun. Even using the VM logging functions in there can be a challenge (since PS is getting called 48k times/second and is very latency sensitive). When I've *had* to debug in there, I've had some luck with using a DigitalCounter GUI object to display value(s). Calling its SetValue that often isn't a good idea either, but it work better than println.josephbottinger wrote: ↑Fri Aug 14, 2020 2:29 pm But my ProcessSample() is doing something wrong, and I don't know what; I actually put a System.out.println() in it to forcibly examine some values (namely, the state of the jacks) and I get *nothing*, no output.
Good luck!
Cheers,
--
Terry McG
-
- Posts: 35
- Joined: Tue Oct 29, 2019 4:03 pm
Re: MIDI Event processing
Yeah, well, the GOOD news is that MIDI CC events don't seem to really make any different for ProcessSample; I couldn't get the system to register ANY messages from there, which makes me wonder where the event handling would go. Note_On and Note_Off events wouldn't fit - it's CC, not note events - so what I'm wondering is if they're simply event types that VM isn't expecting to handle AT ALL, although that doesn't make much sense either.
Re: MIDI Event processing
If you haven't already, might I suggest looking at the MIDI Light example in the sample code shipped with the Designer. It shows how to handle MIDI events in ProcessSample().
-
- Posts: 49
- Joined: Sun Aug 25, 2019 10:26 am
Re: MIDI Event processing
Great idea for a simple midi processing module.
I have done some debugging on midi tonight in a new debug module I am building (code & doco linked below). I'd recommend trying out that module to see what midi messages are firing for you. (I get midi messages and notes coming through).
Midi messages (including notes and CCs) are able to be processed through the ProcessSample code. I was able to process these using:
... Where message is a javax.sound.midi.ShortMessage (doco: https://docs.oracle.com/javase/7/docs/a ... ssage.html)
I would intercepting by adding code along the lines of the following just before sending the message out to the midi jack in the above loop (may need some work as I haven't compiled/tested it ) .
If you the module is working in the designer but you are having the issue in the DAW, there are some challenges with midi (in VST land) that I have previously read about but haven't yet debugged through:
I have also put a midi ShortMessage formatter in https://github.com/arbuxMusic/voltage-m ... atter.java that shows how I am decoding the messages. Should I be using the built-in java constants? Probably, but this is for my learnings on Midi .
I have done some debugging on midi tonight in a new debug module I am building (code & doco linked below). I'd recommend trying out that module to see what midi messages are firing for you. (I get midi messages and notes coming through).
Midi messages (including notes and CCs) are able to be processed through the ProcessSample code. I was able to process these using:
Code: Select all
var messages = midiInputJack1.GetMessages();
if (messages != null) {
for(var message : messages) {
midiOutputJack1.AddMessage(message);
}
}
I would intercepting by adding code along the lines of the following just before sending the message out to the midi jack in the above loop (may need some work as I haven't compiled/tested it ) .
Code: Select all
if (message.getCommand() == ShortMessage.CONTROL_CHANGE && message.getData1() == 11) {
// change the message to a new message with the inverted data 2 value
message = new ShortMessage(message.getCommand(),
message.getChannel(),
message.getData1(),
127 - message.getData2());
}
- VST3 midi out implementation was not as good as it was in VST2. I have seen previous advice from developers to use the VST2 version if you need midi integration with DAWs.
- Not all DAWs honour the CCs through to the VSTs directly. e.g. Ableton seems to intercept them and requires you to hook them up to the VSTs manually. Studio One sometimes intercepts them, but in my test tonight CCs were being passed through - I forget the rules.
I have also put a midi ShortMessage formatter in https://github.com/arbuxMusic/voltage-m ... atter.java that shows how I am decoding the messages. Should I be using the built-in java constants? Probably, but this is for my learnings on Midi .
-
- Posts: 35
- Joined: Tue Oct 29, 2019 4:03 pm
Re: MIDI Event processing
Grrr! Annoying: this actually works, and it's pretty much a 1:1 analog of what I was *already doing* that didn't work. Will continue to work out where the failure is/was, and test this out. Much thanks.
-
- Posts: 49
- Joined: Sun Aug 25, 2019 10:26 am
Re: MIDI Event processing
If you need any further assistance to identify the issue, let me know!