Skip to content

Commit a7c3e74

Browse files
committed
Add delay control
1 parent 3af9fb8 commit a7c3e74

File tree

6 files changed

+223
-0
lines changed

6 files changed

+223
-0
lines changed

src/actions/common.ts

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
GetColorDropdown,
1616
GetNumberField,
1717
GetSoloDropdown,
18+
getDelayModes,
1819
} from '../choices/common.js'
1920
import { getNodeNumber, getNumber, runTransition } from './utils.js'
2021
import { InstanceBaseExt } from '../types.js'
@@ -50,6 +51,9 @@ export enum CommonActions {
5051
RestorePanorama = 'restore-panorama',
5152
DeltaPanorama = 'panorama-delta',
5253
UndoDeltaPanorama = 'undo-panorama',
54+
// Delay
55+
SetDelay = 'set-delay',
56+
SetDelayAmount = 'set-delay-amount',
5357

5458
//////////// SEND
5559
SetSendMute = 'set-send-mute',
@@ -504,6 +508,132 @@ export function createCommonActions(self: InstanceBaseExt<WingConfig>): Companio
504508
}
505509
},
506510
},
511+
////////////////////////////////////////////////////////////////
512+
// Delay
513+
////////////////////////////////////////////////////////////////
514+
[CommonActions.SetDelay]: {
515+
name: 'Set Delay',
516+
description: 'Enable or disable the delay of a bus, matrix or main.',
517+
options: [
518+
GetDropdown('Selection', 'sel', [
519+
...state.namedChoices.mains,
520+
...state.namedChoices.matrices,
521+
...state.namedChoices.busses,
522+
]),
523+
{
524+
type: 'checkbox',
525+
label: 'Delay On/Off',
526+
id: 'delay',
527+
default: false,
528+
},
529+
],
530+
callback: async (event) => {
531+
const sel = event.options.sel as string
532+
const cmd = ActionUtil.getDelayOnCommand(sel, getNodeNumber(event, 'sel'))
533+
send(cmd, event.options.delay ? 1 : 0)
534+
},
535+
},
536+
537+
[CommonActions.SetDelayAmount]: {
538+
name: 'Set Delay Mode',
539+
description: 'Set the delay mode of a bus, matrix or main.',
540+
options: [
541+
GetDropdown('Selection', 'sel', [
542+
...state.namedChoices.mains,
543+
...state.namedChoices.matrices,
544+
...state.namedChoices.busses,
545+
]),
546+
GetDropdown('Delay Mode', 'mode', getDelayModes()),
547+
{
548+
type: 'number',
549+
label: 'Amount (meters)',
550+
id: 'amount_m',
551+
min: 0,
552+
max: 150,
553+
step: 0.1,
554+
default: 0,
555+
range: true,
556+
isVisible: (options) => {
557+
console.log('options: ', options)
558+
return (options.mode as string) === 'M'
559+
},
560+
},
561+
{
562+
type: 'number',
563+
label: 'Amount (ft)',
564+
id: 'amount_ft',
565+
min: 0.5,
566+
max: 500,
567+
step: 0.5,
568+
default: 0.5,
569+
range: true,
570+
isVisible: (options) => {
571+
return options.mode === 'FT'
572+
},
573+
},
574+
{
575+
type: 'number',
576+
label: 'Amount (ms)',
577+
id: 'amount_ms',
578+
min: 0.5,
579+
max: 500,
580+
step: 0.1,
581+
default: 0.5,
582+
range: true,
583+
isVisible: (options) => {
584+
return options.mode === 'MS'
585+
},
586+
},
587+
{
588+
type: 'number',
589+
label: 'Amount (samples)',
590+
id: 'amount_samples',
591+
min: 16,
592+
max: 500,
593+
step: 1,
594+
default: 16,
595+
range: true,
596+
isVisible: (options) => {
597+
return options.mode === 'SMP'
598+
},
599+
},
600+
],
601+
callback: async (event) => {
602+
const sel = event.options.sel as string
603+
const mode = event.options.mode as string
604+
send(ActionUtil.getDelayModeCommand(sel, getNodeNumber(event, 'sel')), mode)
605+
switch (mode) {
606+
case 'M':
607+
send(
608+
ActionUtil.getDelayAmountCommand(sel, getNodeNumber(event, 'sel')),
609+
event.options.amount_m as number,
610+
true,
611+
)
612+
break
613+
case 'FT':
614+
send(
615+
ActionUtil.getDelayAmountCommand(sel, getNodeNumber(event, 'sel')),
616+
event.options.amount_ft as number,
617+
true,
618+
)
619+
break
620+
case 'MS':
621+
send(
622+
ActionUtil.getDelayAmountCommand(sel, getNodeNumber(event, 'sel')),
623+
event.options.amount_ms as number,
624+
true,
625+
)
626+
break
627+
case 'SMP':
628+
send(
629+
ActionUtil.getDelayAmountCommand(sel, getNodeNumber(event, 'sel')),
630+
event.options.amount_samples as number,
631+
true,
632+
)
633+
break
634+
}
635+
},
636+
},
507637

508638
////////////////////////////////////////////////////////////////
509639
// Send Fader

src/actions/utils.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,42 @@ export function getPanoramaCommand(sel: string, val: number): string {
192192
return cmd
193193
}
194194

195+
export function getDelayOnCommand(sel: string, val: number): string {
196+
let cmd = ''
197+
if (sel.startsWith('/bus')) {
198+
cmd = BusCommands.DelayOn(val)
199+
} else if (sel.startsWith('/mtx')) {
200+
cmd = MatrixCommands.DelayOn(val)
201+
} else if (sel.startsWith('/main')) {
202+
cmd = MainCommands.DelayOn(val)
203+
}
204+
return cmd
205+
}
206+
207+
export function getDelayModeCommand(sel: string, val: number): string {
208+
let cmd = ''
209+
if (sel.startsWith('/bus')) {
210+
cmd = BusCommands.DelayMode(val)
211+
} else if (sel.startsWith('/mtx')) {
212+
cmd = MatrixCommands.DelayMode(val)
213+
} else if (sel.startsWith('/main')) {
214+
cmd = MainCommands.DelayMode(val)
215+
}
216+
return cmd
217+
}
218+
219+
export function getDelayAmountCommand(sel: string, val: number): string {
220+
let cmd = ''
221+
if (sel.startsWith('/bus')) {
222+
cmd = BusCommands.DelayAmount(val)
223+
} else if (sel.startsWith('/mtx')) {
224+
cmd = MatrixCommands.DelayAmount(val)
225+
} else if (sel.startsWith('/main')) {
226+
cmd = MainCommands.DelayAmount(val)
227+
}
228+
return cmd
229+
}
230+
195231
export function getSendMuteCommand(sel: string, src: number, dest: number): string {
196232
let cmd = ''
197233
if (sel.startsWith('/ch')) {

src/choices/common.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,12 @@ export function getTriStateTextColor(
431431
return thirdColor ?? combineRgb(0, 0, 0)
432432
}
433433
}
434+
435+
export function getDelayModes(): DropdownChoice[] {
436+
return [
437+
getIdLabelPair('M', 'Meters'),
438+
getIdLabelPair('FT', 'Feet'),
439+
getIdLabelPair('MS', 'Milliseconds'),
440+
getIdLabelPair('SMP', 'Samples'),
441+
]
442+
}

src/commands/bus.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,20 @@ export namespace BusCommands {
111111
export function MatrixSendLevel(bus: number, matrix: number): string {
112112
return `${MatrixSendNode(bus, matrix)}/lvl`
113113
}
114+
115+
export function DelayNode(bus: number): string {
116+
return `${Node(bus)}/dly`
117+
}
118+
119+
export function DelayOn(bus: number): string {
120+
return `${DelayNode(bus)}/on`
121+
}
122+
123+
export function DelayMode(bus: number): string {
124+
return `${DelayNode(bus)}/mode`
125+
}
126+
127+
export function DelayAmount(bus: number): string {
128+
return `${DelayNode(bus)}/dly`
129+
}
114130
}

src/commands/main.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,20 @@ export namespace MainCommands {
8787
export function MatrixSendLevel(main: number, matrix: number): string {
8888
return `${MatrixSendNode(main, matrix)}/lvl`
8989
}
90+
91+
export function DelayNode(main: number): string {
92+
return `${Node(main)}/dly`
93+
}
94+
95+
export function DelayOn(main: number): string {
96+
return `${DelayNode(main)}/on`
97+
}
98+
99+
export function DelayMode(main: number): string {
100+
return `${DelayNode(main)}/mode`
101+
}
102+
103+
export function DelayAmount(main: number): string {
104+
return `${DelayNode(main)}/dly`
105+
}
90106
}

src/commands/matrix.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,20 @@ export namespace MatrixCommands {
9595
export function MonitorMode(matrix: number): string {
9696
return `${Node(matrix)}/mon`
9797
}
98+
99+
export function DelayNode(matrix: number): string {
100+
return `${Node(matrix)}/dly`
101+
}
102+
103+
export function DelayOn(matrix: number): string {
104+
return `${DelayNode(matrix)}/on`
105+
}
106+
107+
export function DelayMode(matrix: number): string {
108+
return `${DelayNode(matrix)}/mode`
109+
}
110+
111+
export function DelayAmount(matrix: number): string {
112+
return `${DelayNode(matrix)}/dly`
113+
}
98114
}

0 commit comments

Comments
 (0)