Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Sisyfos): add sisyfos action to load mixer preset #360

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/timeline-state-resolver-types/src/generated/sisyfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,22 @@ export interface SetSisyfosChannelStatePayload {
channel: number
}

export interface LoadMixerPresetPayload {
/**
* The name of the preset to load
*/
name: string
}

export enum SisyfosActions {
Reinit = 'reinit',
SetSisyfosChannelState = 'setSisyfosChannelState'
SetSisyfosChannelState = 'setSisyfosChannelState',
LoadMixerPreset = 'loadMixerPreset'
}
export interface SisyfosActionExecutionResults {
reinit: () => void,
setSisyfosChannelState: (payload: SetSisyfosChannelStatePayload) => void
setSisyfosChannelState: (payload: SetSisyfosChannelStatePayload) => void,
loadMixerPreset: (payload: LoadMixerPresetPayload) => void
}
export type SisyfosActionExecutionPayload<A extends keyof SisyfosActionExecutionResults> = Parameters<
SisyfosActionExecutionResults[A]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@
},
"destructive": false,
"timeout": 5000
},
{
"id": "loadMixerPreset",
"name": "Load Mixer Preset",
"destructive": false,
"timeout": 5000,
"payload": {
"type": "object",
"properties": {
"name": {
"description": "The name of the preset to load",
"type": "string"
}
},
"required": ["name"],
"additionalProperties": false
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ export class SisyfosApi extends EventEmitter<SisyfosApiEvents> {
...command.values,
}
this.setSisyfosChannel(command.channel + 1, channelState)
} else if (command.type === SisyfosCommandType.LOAD_MIXER_PRESET) {
this.sendLoadMixerPresetCommand(command.presetName)
}
}

Expand Down Expand Up @@ -371,6 +373,21 @@ export class SisyfosApi extends EventEmitter<SisyfosApiEvents> {

return deviceState
}

protected sendLoadMixerPresetCommand(presetName: string) {
if (!this._oscClient) {
throw new Error(`Can't load mixer preset, OSC client not initialised`)
}
this._oscClient.send({
address: `/loadmixerpreset`,
args: [
{
type: 's',
value: presetName,
},
],
})
}
}

export enum SisyfosCommandType {
Expand All @@ -387,6 +404,7 @@ export enum SisyfosCommandType {
RESYNC = 'resync',
RESYNC_CHANNEL = 'resyncChannel',
SET_CHANNEL = 'setChannel',
LOAD_MIXER_PRESET = 'loadMixerPreset',
}

export interface BaseCommand {
Expand All @@ -399,6 +417,11 @@ export interface SetChannelCommand {
values: Partial<SisyfosChannelAPI>
}

export interface LoadMixerPresetCommand {
type: SisyfosCommandType.LOAD_MIXER_PRESET
presetName: string
}

export interface ChannelCommand extends BaseCommand {
type:
| SisyfosCommandType.SET_FADER
Expand All @@ -417,6 +440,10 @@ export interface GlobalCommand extends BaseCommand {
type: SisyfosCommandType.CLEAR_PST_ROW | SisyfosCommandType.TAKE | SisyfosCommandType.RESYNC
}

export interface GlobalCommand extends BaseCommand {
type: SisyfosCommandType.CLEAR_PST_ROW | SisyfosCommandType.TAKE | SisyfosCommandType.RESYNC
}

export interface BoolCommand extends ChannelCommand {
type: SisyfosCommandType.VISIBLE | SisyfosCommandType.SET_MUTE
value: boolean
Expand Down Expand Up @@ -448,6 +475,7 @@ export type SisyfosCommand =
| BoolCommand
| StringCommand
| SetChannelCommand
| LoadMixerPresetCommand

export interface SisyfosChannel extends SisyfosChannelAPI {
timelineObjIds: string[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import {
ActionExecutionResultCode,
SisyfosActionExecutionPayload,
SisyfosActionExecutionResult,
SetSisyfosChannelStatePayload,
LoadMixerPresetPayload,
} from 'timeline-state-resolver-types'

import { DoOnTime, SendMode } from '../../devices/doOnTime'

import { SisyfosApi, SisyfosCommand, SisyfosState, SisyfosChannel, SisyfosCommandType } from './connection'
import Debug from 'debug'
import { startTrace, endTrace, actionNotFoundMessage } from '../../lib'
import { startTrace, endTrace, actionNotFoundMessage, t } from '../../lib'
const debug = Debug('timeline-state-resolver:sisyfos')

export interface DeviceOptionsSisyfosInternal extends DeviceOptionsSisyfos {
Expand Down Expand Up @@ -206,7 +208,7 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp

async executeAction<A extends SisyfosActions>(
actionId0: A,
payload: SisyfosActionExecutionPayload<A>
payload0: SisyfosActionExecutionPayload<A>
): Promise<SisyfosActionExecutionResult<A>> {
const actionId = actionId0
switch (actionId) {
Expand All @@ -218,7 +220,8 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
.catch(() => ({
result: ActionExecutionResultCode.Error,
}))
case SisyfosActions.SetSisyfosChannelState:
case SisyfosActions.SetSisyfosChannelState: {
const payload = payload0 as SetSisyfosChannelStatePayload
if (typeof payload?.channel !== 'number') {
return {
result: ActionExecutionResultCode.Error,
Expand All @@ -228,6 +231,14 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
return {
result: ActionExecutionResultCode.Ok,
}
}
case SisyfosActions.LoadMixerPreset: {
const payload = payload0 as LoadMixerPresetPayload
if (!payload?.name) {
return { result: ActionExecutionResultCode.Error, response: t('Missing name') }
}
return this._handleLoadMixerPreset(payload.name)
}
default:
return actionNotFoundMessage(actionId)
}
Expand Down Expand Up @@ -685,4 +696,18 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
private _connectionChanged() {
this.emit('connectionChanged', this.getStatus())
}

private _handleLoadMixerPreset(presetName: string) {
if (!this._sisyfos.connected || !this._sisyfos.mixerOnline)
return {
result: ActionExecutionResultCode.Error,
}
this._sisyfos.send({
type: SisyfosCommandType.LOAD_MIXER_PRESET,
presetName,
})
return {
result: ActionExecutionResultCode.Ok,
}
}
}
Loading