Control velocity from each incoming midi note with a Knob / Slider?
-
I know it is possible to link a button to incoming each midi note.
Can the same be accomplished with a Knob for each note?
( controlling the velocity while the note is being pressed )
I often do this in Max/Msp, PureData.Thanks I hope :)
-
@Rognvald Do you want the knob to set the velocity or the velocity to set the knob value?
-
@d-healey Ahh, the Knob to control the Velocity
-
Ok let's say your knob is called
knbVelocityand you have a reference to it inonInitconst knbVelocity = Content.getComponent("knbVelocity");In the
onNoteOncallback you can use the knob's value to set the Message's velocity.Message.setVelocity(knbVelocity.getValue());Ideally this should be done using two MIDI processors. The Interface script should be deferred - which means you won't be able to use
setVelocitythere. A second MIDI processor should be used for setting the velocity, and the knob on the GUI should be connected the knob of the second MIDI processor. -
@d-healey Ok thanks for all this info, I will have a blast and see what comes out :)
-
@d-healey I am currently using this code for buttons to midi. Is there any way to insert this velocity function or would I also need to put this code on the second Midi Processor? Little confused but I am sure it can work.
onInt
const Buttons = Content.getAllComponents("Button"); // this list will save the played note eventIds reg eventIds = Engine.createMidiList(); // this played keys will trigger the buttons reg keysThatTrigger = [48, 49, 50, 51]; // this notes will sound reg triggeredNotes = [48, 49, 50, 51]; inline function onButtonsControl(component, value) { local index = Buttons.indexOf(component); if (value) eventIds.setValue(triggeredNotes[index], Synth.playNote(triggeredNotes[index], 60)); else Synth.noteOffByEventId(eventIds.getValue(triggeredNotes[index])); }; for (b in Buttons) b.setControlCallback(onButtonsControl);onNoteOn
function onNoteOn() { Message.ignoreEvent(true); if (keysThatTrigger.contains(Message.getNoteNumber())) { local index = keysThatTrigger.indexOf(Message.getNoteNumber()); Buttons[index].setValue(true); Buttons[index].changed(); } }onNoteOff
function onNoteOff() { if (keysThatTrigger.contains(Message.getNoteNumber())) { local index = keysThatTrigger.indexOf(Message.getNoteNumber()); Buttons[index].setValue(false); Buttons[index].changed(); } }