enzienaudio / heavy

heavy public issue tracker and static dsp code releases
https://enzienaudio.com
ISC License
71 stars 4 forks source link

MIDI note off message retriggers note in Linux VST #152

Open jrdooley opened 7 years ago

jrdooley commented 7 years ago

System setup: Linux Mint 18; Bitwig Studio/Ardour; VST created from Pd kick synth patch

Using Pd's notein object to receive MIDI note messages seems to cause the above problem. The notein object is used to receive the note on and off message to trigger a velocity sensitive kick drum synth.

Sending a MIDI note on message from the DAW sequencer (this has been tried in Bitwig and Ardour) triggers the kick synth. When the sequencer sends the note off message it retriggers the kick synth, though sending a velocity value of 0 should not.

Upon further investigation, changing the velocity of the note in the sequencer does not change the amplitude of the sound coming from the VST synth.

Pd patches used attached. kick-synth.zip

mhroth commented 7 years ago

Thanks for such a helpful bug report @jrdooley. Can you tell me if it works if you connect the left outlet of notein (instead of the middle)? If it does then I have a fix.

jrdooley commented 7 years ago

@mhroth . When the left outlet is connected, I can trigger the kick, but I still get the "double hit" effect when the note releases and retriggers the kick sound.

mhroth commented 7 years ago

Ok "super". Are you familiar with how to use the uploader script? I have a fix in the dev release.

As for the "double trigger" issue, could it be that your DAW is sending a non-zero velocity with the note-off MIDI command?

jrdooley commented 7 years ago

Yes, I've used the uploader script before. Where can I download it? I think I deleted the copy on my hard drive when pre-built Linux VST binaries became available!

I was thinking the same thing about the DAW sending non-zero velocity messages. Unfortunately, I haven't been able to investigate this further yet,

mhroth commented 7 years ago

You can download the uploader script here.

Currently we simply pass though whatever MIDI data the DAW sends us (in the case of note off). Potentially you could look at the right outlet of notein to check the command.

jrdooley commented 7 years ago

I've fallen at the first hurdle! When I run the script with the following command: python2.7 uploader.py /home/formuls/Desktop/kick --out /home/formuls/Desktop --name fkick --gen vst2 --release dev I get the following error: Unknown username or password. However, I'm not prompted to enter my username or password.

mhroth commented 7 years ago

Try passing the -z flag.

jrdooley commented 7 years ago

-z flag works.

I'm still getting the double trigger. I've also tried this in Ardour, as well as Bitwig and the problem is the same. However, using the VST with another VST host it works without any problems. So the problem must lie in the DAW sending a none-zero velocity off message.

diplojocus commented 7 years ago

@jrdooley are you using a MIDI controller that supports aftertouch by any chance? Or is this sequenced via Bitwig?

jrdooley commented 7 years ago

@diplojocus It's sequenced by Bitwig (and Ardour). Some further exploration has revealed that you can change the release-velocity of each note in Bitwig to zero, but this has to be done for every note entered into the sequencer. You don't seem to be able to globally switch off the release-velocity, which is rather annoying.

I'm guessing that I need to isolate the MIDI note-off command that comes out of the right outlet, and filter these out in the patch. Sorry for perhaps a silly question, but what would this message be?! I know that in binary the first 4 digits of the note off message are 1000, but I'm guessing I would need to convert whatever message is coming in, then filter that part of the message out somehow?

diplojocus commented 7 years ago

It may be more legacy but some systems treat a note-on message with a velocity of 0 as a note off message. Which is what Pd does here, it doesn't distinguish between note on or off messages.

I'm sure not what a solution could be here without breaking compatibility with Pd's [notein].

If you're comfortable with editing the VST plugin source code, you could modify it to send your note off events to a different receiver which would solve your issue with Bitwig.

jrdooley commented 7 years ago

@diplojocus Well, I'm no c/c++ coder, but if it's something not too complex I'd be OK with it!

I've had a look at the HeavyVst2_fkick.cpp file and noticed that there is a function call VstInt32 HeavyVst2_fkick::processEvents(VstEvents* events) and a bit further on from that some switch and case statements withnote off and note on comments. Would I be correct in thinking that that is where I would need to edit the code?

mhroth commented 7 years ago

Yes, that's absolutely correct. You'll want something like:

case 0x80: { // note off
  _context->sendMessageToReceiverV(0x67E37CA3, // __hv_notein
      1000.0*vste->deltaFrames/sampleRate, "fff",
      (float) data0, // pitch
      0.0f,          // force zero velocity on note off
      (float) channel);
  break;
}
case 0x90: { // note on
  _context->sendMessageToReceiverV(0x67E37CA3, // __hv_notein
      1000.0*vste->deltaFrames/sampleRate, "fff",
      (float) data0, // pitch
      (float) data1, // velocity
      (float) channel);
  break;
}
jrdooley commented 7 years ago

@mhroth : Super! That worked a treat :+1: Many thanks.

Is there anyway for me to upload the modified code to my project's page on the Heavy website so I can download pre-built Windows and Mac binaries? Can this be done with the uploader script somehow?

I have a feeling I'm asking for the moon on a stick now...!

diplojocus commented 7 years ago

Hi @jrdooley yeah that's not something that is possible currently.

The way to do that would be to use the uploader script to download the source code, and then create a post-download script to modify the implementation with your custom change and compile the code.

MikeMorenoDSP commented 6 years ago

System Setup: OS X Yosemite 10.10.5; Ableton Live 9 Suite, REAPER 64; midi-polys-synth VST from https://github.com/BelaPlatform/Bela/tree/master/examples/10-Instruments/midi-poly-synth

I'm also having the noteoff retrigger issue with with Ableton's Computer MIDI Keyboard, Sequencer, etc.

Surprisingly it didn't retrigger with REAPER's Virtual Midi Keyboard or sequencer. But you could only use one or the other, because the moment you tried changing from sending notes with sequencer to sending notes with the virtual midi keyboard or vice versa, the vst's sound stopped.

So far the workaround I found for this issue was to omit velocity 64.