# TotalMix, Dante, and a Behringer X-Touch: hardware control over my whole studio routing

I have about seventy channels of analog gear in the studio and a software mixer doing the switching. That only works if I can see the mixer without turning around, so I built a controller for it. A Behringer X-Touch sits on the desk, every fader has a motor, every button lights up, and the whole thing talks to RME TotalMix over the network.

This is the writeup of how it works, what the routing lets me do, and the two bugs that made the first version useless.

## The signal path

The heart of the room is an RME MADIface. TotalMix FX is the router: every input, every playback channel from the computer, and every output bus lives in a matrix inside it, and any input can be sent to any bus at any level. On top of that sits Dante, which carries channels to and from the rest of the building over ethernet. Between the two of them there is no patchbay I have to reach for.

What a bus means here is worth being concrete about, because that is where the fun is. Each hardware input has its own bus. The bus carries that input into whatever downstream gear I want, and the gear's output comes back into the interface and becomes another bus. So the signal path is a chain of named destinations rather than a cable.

The compressor rows are named after the hardware in the rack: `73CH1`, `73CH2`, `ACME`, `500C`, `FREQ1`, `FREQ2`, `LA5001`, `LA5002`, `1073-1`, `1073-2`. There are effect buses too: `EFX`, `SUM-VERB`, and `Sum Bus`. Then there are the destinations, `Main` for monitors and `DPHONES` for the headphone amp. Sixty-something additional outputs feed converters and Dante flows.

So when I sit down with the Model D, I press the `EFX` button on the X-Touch and the synthesizer is now feeding the effects bus, which means the Hologram Electronics Chroma Console and the Microcosm are in the signal path, along with the Eventide H90. Press `ACME` instead and it's going through that compressor. Pick up the DFAM and press `SUM-VERB` and it lands on the Audioscape Engineering Reverb Rack.

None of that is a cable. It's one button, and the label on the button matches the bus inside the mixer.

## Why the first attempt failed

My first version of the controller was a MIDI macro machine. TotalMix accepts Mackie Control messages, so I wrote a Node script that translated X-Touch buttons into Mackie commands and drove the mixer's own Mackie surface.

It worked, briefly. Then it started selecting the wrong channels.

The reason is that the Mackie protocol has no way to say "show me channel 27." A real console surface works in banks of eight, and you walk between banks by pressing an arrow. My script kept its own counter of which bank it believed was showing, and pressed the arrow to move it.

Nothing in that loop ever checked. TotalMix never told the script what bank it was actually on. So any drift, a manual bank change at the screen, one dropped message, one timing race in my chained callbacks, and the counter was wrong forever. Press the button for `ACME` and you'd land eight channels away from `ACME` and the script would happily keep believing it.

Any state you maintain without feedback is a guess with confidence attached. That's the whole lesson.

## What changed: OSC, and absolute addresses only

TotalMix has first class OSC support, and it happens to have exactly the two commands the MIDI protocol was missing:

```
/setSubmix    <n>   select an output bus as the active submix, by index
/setBankStart <n>   jump the visible bank of eight faders to a channel, by index
```

Both are absolute. There is nothing to drift, because there is nothing to count.

The second thing OSC gives me is that TotalMix talks back. It echoes parameter values on its outgoing port, continuously, for everything currently visible. So the bridge does not guess at state, it mirrors state that the mixer told it about.

The architecture is two hops and one tiny translation layer:

```
X-Touch --MIDI/MCU--> bridge (Node) --OSC/UDP :7001--> TotalMix
X-Touch <--MIDI/MCU-- bridge (Node) <--OSC/UDP :9001-- TotalMix
```

The bridge is a single Node script of just under a thousand lines. Its only dependency is `easymidi`. The OSC encoder and decoder are about a hundred lines, because TotalMix only uses three OSC argument types: float, int, and string.

## What the controller does

| X-Touch control | TotalMix action |
|---|---|
| Faders 1 to 8 | `/1/volume1..8`, with motor feedback |
| Master fader | `/1/mastervolume` |
| 16 assignable buttons | `/setSubmix <index>`, one per bus, LED follows the mixer |
| Bus row buttons | `/1/busInput`, `/1/busPlayback`, `/1/busOutput` |
| Bank left and right | `/1/bank-`, `/1/bank+` |
| Channel left and right | `/setBankStart <n>`, one channel at a time |
| Mute 1 to 8 | `/1/mute/1/n` with LED feedback |
| Solo 1 to 8 | `/1/solo/1/n` with LED feedback |
| V-Pots 1 to 8 | `/1/pan1..8`, relative |
| V-Pot push | recenters that channel's pan |
| Snapshot 1 to 6 | loads a TotalMix snapshot |
| Channel LED rings | level meters from `/1/levelNLeft` and `/1/levelNRight` |
| Scribble strips | channel names from `/1/trackname1..8` |
| 7-segment display | dB value of the channel you last touched |

Mappings live in `config.json`, so retargeting a button is a one-line edit. Buttons map to buses by **name**, not index:

```json
"submixButtons": {
  "70": "73CH1",
  "71": "73CH2",
  "74": "ACME",
  "76": "EFX",
  "83": "SUM-VERB",
  "90": "Main"
}
```

Names matter because `/setSubmix` indexes mono channels. A stereo-linked output is selected by its left channel alone, which leaves holes in the numbering. If I hard-coded indices, renaming or re-linking an output in TotalMix would silently break the panel.

Instead a scanner builds the truth. It sweeps every possible index, sends `/setSubmix`, waits for TotalMix to report the bus name, and writes what it finds to `submixes.json`:

```
index 4   EFX        stereo
index 14  SUM-VERB   stereo
index 62  Main       stereo
```

Re-run it after renaming anything. That file is also what the mapping GUI I owe myself will present as a dropdown.

## Three things that took real debugging

### Motor faders snapping backward

TotalMix pushes the current fader position in a periodic dump of the whole visible page. The problem is that the dump lags. Move a fader to a new value, release it, and TotalMix keeps reporting the *old* value for seconds afterward. The bridge faithfully drove the motor back down to where you had just moved it from.

The fix is to remember what the bridge itself sent and only accept feedback that matches. Once TotalMix's dump reports our value, the mismatch resolves and normal feedback resumes. Alongside that there is a cooldown window per channel, and a check on the fader's own touch sensor plus its pitch messages, since a hand that is actively riding a fader should never be overridden by feedback at all.

The subtlety I got wrong twice: the touch sensor note lags the first pitch message, so a naive "is anyone touching this" test says no at exactly the wrong moment. I extend the touched state by 200 ms whenever pitch messages are arriving.

### The 7-segment display encoding

The big timecode-style display on an X-Touch is driven by ten control changes, one per digit, and the value is `ASCII & 0x3F`. Which looks elegant until you send `"dB"`: `d` is `0x64`, which masks to `0x24`, which is `S`. So it displayed `3   -5.9S` for a while. Now the suffix gets stripped and the digits are what matter.

Also, the display reads right to left, so `CC 0x49` holds the leftmost character. Get that backwards and your levels print mirrored.

### Which buttons the LEDs believe

The submix button LEDs are not set when you press them. Pressing sets nothing. TotalMix replies with `/1/labelSubmix` carrying the active bus name, and *that* message decides which button lights.

That sounds like an extra hop until you notice what it buys. Clicking a bus inside TotalMix with the mouse lights the correct button on the panel for free. Panel and screen cannot disagree, because the mixer is the only source of truth.

The same trick is on mute and solo. TotalMix's page-1 mute address is absolute on or off, not a toggle, so pressing the button sends the inverse of the state the bridge last heard rather than a blind `1.0`. It costs a little logic and prevents a mute that has drifted out of sync with the LED.

## Small stuff that earns its keep

On startup the panel runs a snake animation along its own LEDs, cycles a rainbow across the scribble strips, and drives a travelling sine wave through the eight motor faders and the meter rings. It is entirely unnecessary, and it is also how I know in two seconds that the bridge is up and the MIDI path works.

The functional part of startup is one message. Sending `/1/busInput 1.0` makes TotalMix re-send the whole page 1 dump, which initializes every motor fader, scribble strip and LED without the bridge having to ask for anything.

Snapshot buttons are a mild gotcha. TotalMix addresses snapshots on OSC page 3, and they are numbered in reverse, so snapshot 1 is `/3/snapshots/8/1`. Loading one also makes page 3 the active page, which stops the fader and meter feedback I depend on. So after a snapshot the bridge re-asserts the current bus on page 1 a moment later and feedback comes back.

Snapshots are how I recall a whole session's routing, which turns a patching session into a button press.

## Running it

```bash
npm start              # foreground
npm run service:start  # launchd agent, restarts on crash, retries until the X-Touch is plugged in
tail -f osc-bridge.log
```

The LaunchAgent is deliberately *not* in `~/Library/LaunchAgents`, so it never autostarts at login. I start it when I want the controller and stop it when I don't. Because the script exits non-zero when the X-Touch isn't connected, launchd retries it every ten seconds, which means plugging the device in is the only step.

TotalMix needs four settings, once: enable Remote Controller 1, incoming port 7001, outgoing port 9001, host 127.0.0.1, and "Submix linked to OSC Control" in the Options menu. The last one is easy to miss; without it `/setSubmix` is accepted and does nothing. The bridge checks whether TotalMix is actually talking back at startup and prints which port to fix if it isn't, because I lost an afternoon to exactly that.

If the old Mackie remote is still enabled in TotalMix, disable it. Two controllers driving the same faders produces behavior that looks like a bug in the bridge and isn't.

## Where it is going

The script is in daily use and I am happy with its shape. The gap is configuration. Adding a bus today means running the scanner and editing JSON by hand, and that is a step most people with a rack full of gear and no interest in Node are not going to take. The plan is a Tauri app around the same core, Rust on the back, a small UI on the front, with a click-to-learn button mapper, a scanner behind a button, and a live status readout. The port map is already written. The logic is proven, it just needs a face.

The useful abstraction in here is not the X-Touch. It is that TotalMix is a router with an OSC API, and any hardware panel that can speak UDP is a control surface for it. Once the addresses are absolute and the state comes from the mixer, the controller becomes a display of the routing rather than a controller of it, which is the version that actually works.

## If you want this in your room

I do studio programming and networked audio, Dante specifically, in the Asheville area. That is routing design, clocking, and the control layer on top, the part that turns a rack of gear into something you can operate without thinking about it. My company is [Blue Oak Interactive](https://blueoakinteractive.com). Reach me through the site if you want to talk about your room.
