Change MIDI velocity by knob

Hi all! For my piano set-up via AUM on iPad I have my Ravenscroft piano AUV3 plugin loaded 2 times: 1st is a normal piano, and the other one a +12 transposed piano. These go together into a piano bus channel where I load effects unto it. And where I control their volume together. The transposed piano also has it’s own volume, since I normally only play the normal piano, but then I sometimes like to mix some of the transposed piano into it.

However, for the sake of CPU, I was thinking of combining the MIDI signals so that I could just use one instance of the Ravenscroft. The challenge is that I don’t just want to turn the transposed piano on/off, but I would like to mix it in with a knob..

My idea is to split my keyboards midi signal into 2 midi channels, 1 going into the Ravenscroft right away (let’s call it channel A) and the other going through Mozaic first and then to the Ravenscroft app (let’s call this one channel B).

Then were I get stuck; is it possible to make a ‘volume’ knob for channel B? I guess it would sort of have to make the general MIDI velocity go up or down? I would like to still be able to play soft or loud so the sound is still adaptive to my playing.

In Ableton I saw someone achieve this same goal using the Chord Midi functionality that’s in there. Hope anyone can help me out figure out how to do this on my iPad! Thank you!

4 comments on “Change MIDI velocity by knob
  • pianotour on said:

    This should work for you. The first slider will control the octave shift from -4 to +4 and the second slider will modify the incoming velocity by the amount of the slider from -127 to +127. So +1 on the octave and -40 on the velocity will play a note one octave higher but with 40 less velocity.

    @OnLoad
    ShowLayout 3

    // Initialize our actual variables to 0
    octaveShift = 0
    velocityShift = 0

    // Set the physical knobs to the center (64)
    // because 64 represents ‘0’ in our scaled ranges.
    SetKnobValue 0, 64
    SetKnobValue 1, 64

    // Label them with the starting values (0)
    LabelKnob 0, {Octave: }, octaveShift
    LabelKnob 1, {Velocity: }, velocityShift
    @End

    @OnKnobChange
    if LastKnob = 0
    // Get the raw knob value (0-127)
    rawVal = GetKnobValue 0

    // Map 0-127 to -4 to +4
    scaledVal = TranslateScale rawVal, 0, 127, -4, 4

    // Round to nearest whole number so we don’t get 1.3 octaves
    octaveShift = Round scaledVal

    // Update label
    LabelKnob 0, {Octave: }, octaveShift

    elseif LastKnob = 1
    // Get the raw knob value (0-127)
    rawVal = GetKnobValue 1

    // Map 0-127 to -50 to +50
    scaledVal = TranslateScale rawVal, 0, 127, -64, 64

    // Round to whole number
    velocityShift = Round scaledVal

    // Update label
    LabelKnob 1, {Velocity: }, velocityShift
    endif
    @End

    @OnMidiNoteOn

    if octaveShift 0

    newNote = MIDINote + (octaveShift * 12)
    newVelocity = Clip (MIDIVelocity + velocityShift), 0, 127

    SendMIDINoteOn MIDIChannel, MIDINote, MIDIVelocity
    SendMIDINoteOn MIDIChannel, newNote, newVelocity

    else

    SendMIDINoteOn MIDIChannel, MIDINote, MIDIVelocity

    endif

    @End

    @OnMidiNoteOff

    if octaveShift 0

    newNote = MIDINote + (octaveShift * 12)

    SendMIDINoteOff MIDIChannel, newNote, 0

    else

    SendMIDINoteOff MIDIChannel, MIDINote, 0

    endif

    @End

  • stephan on said:

    Thank you so much!! That is exactly what I needed!

    Only one problem; it seems like when I play through this, the sustain pedal is for some reason always activated? Makes the notes really long. Do you know by any chance how to solve this? So that sustain pedal is only on when I press it?

    I also get the following messages in log, maybe that helps:
    [OnMidiNoteOff] Syntax Error: expected a mathematical or logical operator “0”
    [OnMidiNoteOn] Syntax Error: expected a mathematical or logical operator “0”

    Thank you so much again!

  • stephan on said:

    I actually found a fix! By having both the input of my midi keyboard and the patch going to my piano auv3 instead of just the patch signal. So that works great now! Thank you so much for the code!

    I also did find another possible improvement; if I want, let’s say, the volume of both my normal note and the octivated note the same, then I turn up the velocity. But now when I play more dynamically, my octivated note has no dynamic volume, it is stuck on the set velocity. So let’s say my octivater is on high, but I play something quiet, the octivated notes are way louder then the rest. Does anyone have any idea how to add this dynamic? So that my input velocity would have effect on the actual velocity of the note played?

  • stephan on said:

    Never mind, I think this actually seems to be working! I figure when velocity is just so high, quiet sounds loud already. But it seems like it definitely has dynamics. Thanks so much again! Really!

  • Leave a Reply