# 14-Bit Rotary Output using Arbitrary MSB CC

**URL:** <https://forum.electra.one/t/14-bit-rotary-output-using-arbitrary-msb-cc/2937>\
**Category:** General discussion\
**Created:** [May 22, 2024, 11:57am UTC](https://forum.electra.one/t/14-bit-rotary-output-using-arbitrary-msb-cc/2937 "2024-05-22T11:57:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkram53](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@rkram53](https://forum.electra.one/u/rkram53)\
**Post date:** [May 22, 2024, 11:57am UTC](https://forum.electra.one/t/14-bit-rotary-output-using-arbitrary-msb-cc/2937/1 "2024-05-22T11:57:34Z")

</div>

Hi. I need a controller that can output 14-bit values from a rotary where MSB will be either CC86 or CC97 and the LSB will be CCn, MSB has to be send before LSB for every rotary motion that outputs a 14-bit value. Can Electra One do this. Likely not out of the box - but how about with a LUA script? Thanks.

---

<div class="post-metadata">

**Author:** ![christianvogel](https://avatars.discourse-cdn.com/v4/letter/c/b19c9b/32.png) [@christianvogel](https://forum.electra.one/u/christianvogel)\
**Post date:** [May 22, 2024, 4:01pm UTC](https://forum.electra.one/t/14-bit-rotary-output-using-arbitrary-msb-cc/2937/2 "2024-05-22T16:01:57Z")

</div>

Hi this should be possible with a script. A preset can contain a Lua script. In this script you can add this listener for changes of controllers:

```auto
function parameterMap.onChange(valueObjects, origin, midiValue)

```

This lets you observe any change to the controls. You can then manually send out midi signals over the MIDI ports of the Electra One.

See here for the parameterMap documentation: [Preset Lua extension | Electra One Documentation](https://docs.electra.one/developers/luaext.html#parameter-map), and here for the MIDI functions for sending out data: [Preset Lua extension | Electra One Documentation](https://docs.electra.one/developers/luaext.html#midi-functions)

That way you can verify if what you need gets covered by the API.

---

<div class="post-metadata">

**Author:** ![rkram53](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@rkram53](https://forum.electra.one/u/rkram53)\
**Post date:** [May 22, 2024, 4:05pm UTC](https://forum.electra.one/t/14-bit-rotary-output-using-arbitrary-msb-cc/2937/3 "2024-05-22T16:05:09Z")

</div>

Great. Thanks for this information!! My use case will be talking to Haken Audio EaganMatrix for controlling the new Specialty Synth function applied to Haken Continuum devices and Expressive E Osmose.

---

<div class="post-metadata">

**Author:** ![christianvogel](https://avatars.discourse-cdn.com/v4/letter/c/b19c9b/32.png) [@christianvogel](https://forum.electra.one/u/christianvogel)\
**Post date:** [May 22, 2024, 9:40pm UTC](https://forum.electra.one/t/14-bit-rotary-output-using-arbitrary-msb-cc/2937/4 "2024-05-22T21:40:13Z")

</div>

Sounds great. Love the Osmose.

---

<div class="post-metadata">

**Author:** ![martin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/martin/32/145_2.png) [@martin](https://forum.electra.one/u/martin)\
**Post date:** [May 23, 2024, 6:28am UTC](https://forum.electra.one/t/14-bit-rotary-output-using-arbitrary-msb-cc/2937/5 "2024-05-23T06:28:44Z")

</div>

> [@rkram53](#):
>
> Hi. I need a controller that can output 14-bit values from a rotary where MSB will be either CC86 or CC97 and the LSB will be CCn, MSB has to be send before LSB for every rotary motion that outputs a 14-bit value. Can Electra One do this. Likely not out of the box - but how about with a LUA script? Thanks.

this also can be done by adding a control with 14-bit virtual message and linking a Lua function to it. The logic of the function should then send the LSB value with every value change. The MSB should be sent out only when LSB passes zero. Simplified Lua would be something like this:

```auto
local CONTROL_CHANGE_MSB_INC = 86
local CONTROL_CHANGE_MSB_DEC = 97
local DEVICE_PORT = PORT_1
local DEVICE_CHANNEL = 1

local prevValueMsb = 0

function sendCustomCc(valueObject, value)
    local valueMsb = value >> 7
    local valueLsb = value & 0x7f
    local controlChangeLsb = valueObject:getMessage():getParameterNumber()

    if valueMsb ~= prevValueMsb then
        midi.sendControlChange(
            DEVICE_PORT,
            DEVICE_CHANNEL,
            (valueMsb > prevValueMsb) and CONTROL_CHANGE_MSB_INC or CONTROL_CHANGE_MSB_DEC,
            valueMsb)
        prevValueMsb = valueMsb
    end

    midi.sendControlChange(DEVICE_PORT, DEVICE_CHANNEL, controlChangeLsb, valueLsb)
end

```

[Custom 14-bit CC](https://app.electra.one/preset/gJuUf646BqZL2qL30qWJ) preset.

For a real-world preset, I would suggest getting the `port` and `device` out of the associated device and possibly using a Lua upvalue for `prevValueMsb` instead of the global.

---

<div class="post-metadata">

**Author:** ![rkram53](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@rkram53](https://forum.electra.one/u/rkram53)\
**Post date:** [May 23, 2024, 12:54pm UTC](https://forum.electra.one/t/14-bit-rotary-output-using-arbitrary-msb-cc/2937/6 "2024-05-23T12:54:45Z")

</div>

Wow. Thank you so much for taking the to show me this!

---

<div class="post-metadata">

**Author:** ![rkram53](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@rkram53](https://forum.electra.one/u/rkram53)\
**Post date:** [May 27, 2024, 11:51pm UTC](https://forum.electra.one/t/14-bit-rotary-output-using-arbitrary-msb-cc/2937/7 "2024-05-27T23:51:35Z")

</div>

Hi,  
It’s not clear from the documentation how I get the (valueObject, value) assigned in the GUI config for Selected Object I assign sendCustomCC in the Function slot (I assume that is what is needed to assign functions to specific selected objects). Thanks!  
 ![image](https://europe1.discourse-cdn.com/flex017/uploads/electraone/original/2X/b/b611cfc26cc2c4d2d704a376e057f1eeb4d785a8.png)
