Combined MIDI controllers 14-bit

Home Forums General Programming Combined MIDI controllers 14-bit

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #116422
    human fly
    Participant
    • Topics: 124
    • Replies: 1057
    • Total: 1181
    • ★★★★

    hi everyone,

    lazy initial question (passing thought), re: 14-bit MIDI CC protocol.

    eg: ‘combined controllers’ – you use two MIDI CC to send your higher resolution message,
    as MSB/LSB pair (‘coarse/fine’).

    you can have a look at Atom’s Synth Lite2 panel to see how this is implemented in Ctrlr,
    as a standard feature of Ctrlr. but i would like to code this in Lua. i’m a bit rusty,
    so i’m polling some advice before attacking it.

    essentially, the ‘low’/MSB CC will 0-31 ,and the ‘high’/LSB CC will be 32-63 (eg: n + 32 )

    i want to make a controller for MFB PolyLite, the ‘multi’/poly version of the SynthLite2,
    with a bit of flexibility, rather than relying on the built-in Ctrlr CC handling.

    thanks for any thought on this :tu:

    #116426
    dnaldoogdnaldoog
    Participant
    • Topics: 1
    • Replies: 183
    • Total: 184
    • ★★

    You can do that with BigInteger getBitRangeAsInt() method:

    To convert a Multi CC message as in:

    
    CC,ByteValue,MSB7bitValue,23,-1
    CC,ByteValue,LSB7bitValue,55,-1
    

    In Lua:

    
    --
    -- Called when a modulator value changes
    -- @mod   http://ctrlr.org/api/class_ctrlr_modulator.htmla
    -- @value    new numeric value of the modulator
    --
    myMultiCC = function(mod,value,source)
    local myChannel=panel:getProperty("panelMidiOutputChannelDevice")
    local add=0xb0+(myChannel-1)
          local bv=BigInteger(value) --break the value into 4bit nibbles
          local msb=bv:getBitRangeAsInt(7,16) -- position of msb
          local lsb=bv:getBitRangeAsInt(0,7) -- position of lsb
        m = CtrlrMidiMessage({add, 23, msb}) 
        l = CtrlrMidiMessage({add, 55, lsb}) 
        panel:sendMidiMessageNow(m)
        panel:sendMidiMessageNow(l)
    end--f
    

    Where 23 and 55 are the MSB/LSB Bank Select control numbers for adsr2Sustain uiSlider [ADSR Sustain] on that panel by Atom.

    … or alternatively you could split the value this way:

    
    msb=bit.rshift(value, 7)
    lsb=bit.band(value, 127)
    

    Regards,

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
There is currently 0 users and 33 guests online
No users are currently active
Forum Statistics
Threads: 2,265, Posts: 15,872, Members: 56,734
Most users ever online was 12 on January 22, 2019 3:47 pm
Do NOT follow this link or you will be banned from the site!