Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
fmalcher committed Dec 27, 2024
1 parent 467f010 commit 3132017
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 2 deletions.
94 changes: 94 additions & 0 deletions docs/docs/features/channelsync.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
# sidebar_position:
---

# Channel Sync

Channel sync allows the synchronization of channel selection across multiple clients. When enabled, selecting a channel in the Web UI will automatically select the same channel in all other clients that share the same SYNC ID. This feature also supports grouping, where different SYNC IDs can be assigned to different groups of clients, ensuring that channel selection is synchronized within each group independently.

Channel Sync must be enabled on each client individually:

- _Settings > Local > Sync Selected Channel_

The default SYNC ID is `SYNC_ID`, but you can customize it to any value you prefer.
Clients with the same SYNC ID will sync their selected channel.

A `ChannelSync` class instance is available through `conn.channelSync`. This class allows you to select channels and read the current selection.

Channels are identified by their index on the master bus, counted from left to right. Refer to the table below for the complete mapping. Note that this library does not offer automatic conversion between the index and the actual channel object.

| Method | Description |
| ----------------------------------- | ------------------------------------------------------------------------------------------ |
| `getSelectedChannelIndex(syncId)` | Get index of the currently selected channel as an Observable stream |
| `selectChannelIndex(index, syncId)` | Select a channel by index. All clients with the same SYNC ID will select the same channel. |

Each method call can receive an optional `syncId`. If none is provided, it will use the default value `SYNC_ID`. Note that you cannot set a SYNC ID globally; it must be specified in every call. This design allows the library to interact with multiple SYNC groups simultaneously.

A full record stream of all SYNC IDs and their current values is available through the `MixerStore` class:

```ts
conn.store.syncState$.subscribe(/* ... */);

// Structure:
// { "SYNC_ID": 3, "anotherSyncId": 10 }
```

## Index/Channel Mapping

| Index | Channel Ui24R | Channel Ui16 | Channel Ui12 |
| ----- | ------------- | ------------ | ------------ |
| `-1` | Master | Master | Master |
| `0` | Input 1 | Input 1 | Input 1 |
| `1` | Input 2 | Input 2 | Input 2 |
| `2` | Input 3 | Input 3 | Input 3 |
| `3` | Input 4 | Input 4 | Input 4 |
| `4` | Input 5 | Input 5 | Input 5 |
| `5` | Input 6 | Input 6 | Input 6 |
| `6` | Input 7 | Input 7 | Input 7 |
| `7` | Input 8 | Input 8 | Input 8 |
| `8` | Input 9 | Input 9 | Line In L |
| `9` | Input 10 | Input 10 | Line In R |
| `10` | Input 11 | Input 11 | Player L |
| `11` | Input 12 | Input 12 | Player R |
| `12` | Input 13 | Line In L | FX 1 |
| `13` | Input 14 | Line In R | FX 2 |
| `14` | Input 15 | Player L | FX 3 |
| `15` | Input 16 | Player R | **TODO** |
| `16` | Input 17 | FX 1 | |
| `17` | Input 18 | FX 2 | |
| `18` | Input 19 | FX 3 | |
| `19` | Input 20 | FX 4 | |
| `20` | Input 21 | SUB 1 | |
| `21` | Input 22 | SUB 2 | |
| `22` | Input 23 | SUB 3 | |
| `23` | Input 24 | SUB 4 | |
| `24` | Line In L | AUX 1 | |
| `25` | Line In R | AUX 2 | |
| `26` | Player L | AUX 3 | |
| `27` | Player R | AUX 4 | |
| `28` | FX 1 | AUX 5 | |
| `29` | FX 2 | AUX 6 | |
| `30` | FX 3 | | |
| `31` | FX 4 | | |
| `32` | SUB 1 | | |
| `33` | SUB 2 | | |
| `34` | SUB 3 | | |
| `35` | SUB 4 | | |
| `36` | SUB 5 | | |
| `37` | SUB 6 | | |
| `38` | AUX 1 | | |
| `39` | AUX 2 | | |
| `40` | AUX 3 | | |
| `41` | AUX 4 | | |
| `42` | AUX 5 | | |
| `43` | AUX 6 | | |
| `44` | AUX 7 | | |
| `45` | AUX 8 | | |
| `46` | AUX 9 | | |
| `47` | AUX 10 | | |
| `48` | VCA 1 | | |
| `49` | VCA 2 | | |
| `50` | VCA 3 | | |
| `51` | VCA 4 | | |
| `52` | VCA 5 | | |
| `53` | VCA 6 | | |
2 changes: 1 addition & 1 deletion packages/mixer-connection/src/lib/facade/channel-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class ChannelSync {
constructor(private conn: MixerConnection, private store: MixerStore) {}

/**
* Get index of the currently selected channel, from left to right on the master bus.
* Get index of the currently selected channel as an Observable stream, from left to right on the master bus.
* @param syncId SYNC ID to use (default: 'SYNC_ID')
* @returns
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<h2 class="mt-4">
ID <code>{{ syncId }}</code>
<small class="ms-3 text-muted"
>Selected: @if (currentIndex) {<code>{{ currentIndex }}</code
>Selected: @if (currentIndex !== undefined) {<code>{{ currentIndex }}</code
>} @else {None}</small
>
</h2>
Expand Down

0 comments on commit 3132017

Please sign in to comment.