then amp (and chan) are automatically packed into the midi message to the MIDIOut object. VSTPluginController.midi mimics a MIDIOut but it doesn’t seem to take over velocity. Did I get the something wrong or is this missing currently?
MIDI velocity works fine for me (tested with “Dexed”). I suspect you are using a VST instrument without velocity sensitivity (e.g. a digital organ). In this case, the exact velocity is ignored by the instrument, it only matters if it’s greater 0 (= note on) or equal 0 (= note off).
I just checked with Dexed and it doesn’t work here (on OSX):
// start synth and controller
~synth = Synth(\vst);
~ctrl = VSTPluginController.new(~synth);
~ctrl.open("/Library/Audio/Plug-Ins/VST/Dexed");
// define pattern
(
p = Pbind(
\type, \midi,
\midiout, ~ctrl.midi,
\dur, 0.3,
\amp, Pseq([1/126, 0.9], inf),
// at least this works, every second event is silent:
// \amp, Pseq([1/128, 0.5], inf),
\midinote, Pwhite(70, 90)
);
)
// constant amplitude though
x = p.trace.play
x.stop
Am I doing something wrong? I checked the same example with a genuine MIDIOut and SimpleSynth and it works.
Could there be a problem when converting to Integer values from 0 to 127 ? Note that method ‘round’ doesn’t produce Integers but Floats, it demands an addtional ‘asInteger’
Again, it depends on the sound. The default program 0 in Dexed is an organ-like sound. Try for example program 4 with the following amplitude values: \amp, Pseq([0.1, 0.9], inf) - you should hear a clear difference in velocity.
Note that the \amp to velocity conversion in the Event is done with asInteger((amp * 127).clip(0, 127)). I think it should rather be asInteger((amp * 127).clip(0, 127) + 0.5) to round to the nearest velocity step, so you can do \amp = 1/127 and reliably get MIDI velocity 1 (which is very quiet).
.