# Complex composed value within two nibbles

**URL:** <https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949>\
**Category:** General discussion\
**Created:** [September 24, 2021, 6:58am UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949 "2021-09-24T06:58:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Feinsveur](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@Feinsveur](https://forum.electra.one/u/Feinsveur)\
**Post date:** [September 24, 2021, 6:58am UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/1 "2021-09-24T06:58:23Z")

</div>

I’m having trouble setting up controls for a Yamaha FB-01. It uses particular bits within two nibbles to control multiple parameters in one message. The Algorithm select (Parameter 4C) uses 3 bits from the MSB, with the LSB bits first. I can change the algorithm successfully, but how do I do so without changing the other parameters within the bytes?

![FB-01](https://europe1.discourse-cdn.com/flex017/uploads/electraone/original/1X/a6fbffee1c7d422aed63d5cae81d3f5155c9f3aa.png)

---

<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:** [September 24, 2021, 7:58am UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/2 "2021-09-24T07:58:46Z")

</div>

the trick here is to have rules that will compose given sysex byte (4C) using multiple parameter values. It sounds cryptic I know 🙂

an example:

Make following controls:

- “Left Output Enable” and mark it as parameter 1000, type sysex
- “Right Output Enable” as a parameter 1001, type sysex
- “Feedback” as a parameter 1002, type sysex
- “Algorithm” as a parameter 1003, type sysex

When you change any of these, you need to make sure that current values of all of them are used to compose the outgoing sysex message and the bits are placed at correct position within the sysex value byte.

```auto
[  
  "43",
  "xx",
  ...
  "xx",
  {  
    "type": "value",
    "rules": [  
      {
        "type": "sysex",
        "parameterNumber": 1000,
        "byteBitPosition": 7,
        "bitWidth": 1
      },
      {
        "type": "sysex",
        "parameterNumber": 1001,
        "byteBitPosition": 6,
        "bitWidth": 1
      },
      {
        "type": "sysex",
        "parameterNumber": 1002,
        "byteBitPosition": 3,
        "bitWidth": 3
      },
      {
        "type": "sysex",
        "parameterNumber": 1003,
        "byteBitPosition": 0,
        "bitWidth": 3
      }

```

for more details, take a look at Writing SysEx templates and / or review operator enable controls in the TX7 preset.

---

<div class="post-metadata">

**Author:** ![Feinsveur](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@Feinsveur](https://forum.electra.one/u/Feinsveur)\
**Post date:** [September 24, 2021, 8:37am UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/3 "2021-09-24T08:37:05Z")

</div>

So this particular situation doesn’t use the “parameterbitposition” that is used in the two nibbles tutorial at all?

I’ll try this out and check out the TX7 setup.

---

<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:** [September 24, 2021, 8:42am UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/4 "2021-09-24T08:42:59Z")

</div>

In the two nibbles tutorial, you work with one parameter and you need to split it into two bytes. That is why the `parameterBitPosition` is used. In your case, the parameters end up in single sysex byte, therefore you just work with `bitWidth` and position of the parameter within the sysex byte `byteBitPosition`. Hope it helps.

---

<div class="post-metadata">

**Author:** ![Feinsveur](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@Feinsveur](https://forum.electra.one/u/Feinsveur)\
**Post date:** [September 24, 2021, 9:21am UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/5 "2021-09-24T09:21:20Z")

</div>

I tried out your example, but it didn’t work unfortunately. I must be missing something, because from what I can understand from the manual the voice parameters do use 2 bytes.

Here’s a snippet from the manual if this helps.  
 ![Untitled](https://europe1.discourse-cdn.com/flex017/uploads/electraone/original/1X/4934edf6c89eec8a609e02299c213a31337f1004.png)

---

<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:** [September 24, 2021, 9:57am UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/6 "2021-09-24T09:57:22Z")

</div>

Ok, I see. Sorry, I missed the part about that the parameter values must be sent as two nibbles. Then I would try following:

providing the `system No` and the `instrument No` are 0.

> [@martin](#):
>
> ```auto
> [  
> "43",
> "75",
> "00",
> "18",
> "4C",
> {  
> "type": "value",
> "rules": [
> {
> "type": "sysex",
> "parameterNumber": 1003,
> "byteBitPosition": 0,
> "bitWidth": 3
> }, 
> {
> "type": "sysex",
> "parameterNumber": 1002,
> "byteBitPosition": 3,
> "bitWidth": 1
> }
> ]
> },
> {  
> "type": "value",
> "rules": [
> {
> "type": "sysex",
> "parameterNumber": 1002,
> "parameterBitPosition": 1,
> "byteBitPosition": 0,
> "bitWidth": 2
> },
> {
> "type": "sysex",
> "parameterNumber": 1001,
> "byteBitPosition": 2,
> "bitWidth": 1
> },
> {
> "type": "sysex",
> "parameterNumber": 1000,
> "byteBitPosition": 3,
> "bitWidth": 1
> }
> ]
> }
> ]
> 
> ```

The first `value` byte consists of all 3 bits of parameter 1003 and 1 bit of 1002. The second `value` byte has remaining 2 bits of 1002 (hence the `parameterBitPosition` is needed) and 1 bit for 1001 and 1000.

---

<div class="post-metadata">

**Author:** ![Feinsveur](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@Feinsveur](https://forum.electra.one/u/Feinsveur)\
**Post date:** [September 24, 2021, 10:46am UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/7 "2021-09-24T10:46:02Z")

</div>

Ok, we’re getting somewhere! With that example the algorithm select is now working again, and isn’t being changed by the other controls, but those other controls don’t seem to be doing anything. This FB-01 sysex implementation… 😓

I’ll try out some other voice parameters with this example and see if I have better luck.

:UPDATE:  
So I’ve done a number of the other parameter changes that use 2 bytes, like the operator enable/disable, and everything is working as is should. The only issue I’m having is the “Feedback” where the 3 bits are split between the bytes. I’m really at a loss as to why this isn’t working.

---

<div class="post-metadata">

**Author:** ![Feinsveur](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@Feinsveur](https://forum.electra.one/u/Feinsveur)\
**Post date:** [September 25, 2021, 12:17pm UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/8 "2021-09-25T12:17:41Z")

</div>

I figured out the issue once I got more parameters set up. The operators in the algorithm diagrams were reversed, so OP4 was actually OP1. The manual lists this incorrectly. 😓

@martin the last example you gave me worked once I fixed that. Thanks for the help! I might be able to figure out my Casio CZ-1 after all of this.

---

<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:** [September 25, 2021, 6:40pm UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/9 "2021-09-25T18:40:50Z")

</div>

It would be great to have CZ-1 on the preset list! 🙂

---

<div class="post-metadata">

**Author:** ![NewIgnis](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/newignis/32/767_2.png) [@NewIgnis](https://forum.electra.one/u/NewIgnis)\
**Post date:** [November 14, 2024, 12:01pm UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/10 "2024-11-14T12:01:37Z")

</div>

@martin @Feinsveur

I’ll plan on starting a preset for a Casio VZ8M. It you know of any worl already done , do let me know.

Ignace

---

<div class="post-metadata">

**Author:** ![Flyweight](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/flyweight/32/342_2.png) [@Flyweight](https://forum.electra.one/u/Flyweight)\
**Post date:** [November 14, 2024, 12:27pm UTC](https://forum.electra.one/t/complex-composed-value-within-two-nibbles/949/11 "2024-11-14T12:27:19Z")

</div>

```auto
function mainWorker(ValueObject, Value)

  local message = ValueObject:getMessage()
  local control = ValueObject:getControl()
  local currentParameterNumber = message:getParameterNumber()
  local curValue = message:getValue()

  if ( currentParameterNumber ~= previousParameterNumber ) then
    
    -- we store the current value as the previous for the next time
    previousParameterNumber = currentParameterNumber

    -- common way to separate the tens digit and the ones digit
    local byte1st = math.floor(currentParameterNumber / 10)
    local byte2nd = currentParameterNumber % 10

    sysexMsg = { 15, 1, 1, parameterSelect, byte1st, byte2nd, valueSelect, endCommand }
    midi.sendSysex(PORT_1, sysexMsg)

  end

```

This is from the Ensoniq Mirage Masos template

[https://app.electra.one/preset/vwkOrt6pJ3RGjpuCN6pl](https://app.electra.one/preset/vwkOrt6pJ3RGjpuCN6pl)

Every control is a virtual one which has a parameter number assigned that matches the sysex,

The controls use the fucntion mainWorker() which nibbles parameter numbers accordingly and send a sysex message to the Mirage.

Cheers
