1
1
import * as ld from '@synesthesia-project/light-desk' ;
2
2
import { throttle } from 'lodash' ;
3
+ import { ModulateModule } from '@synesthesia-project/compositor/lib/modules/modulate' ;
3
4
import { TransitionModule } from '@synesthesia-project/compositor/lib/modules/transition' ;
4
5
import FillModule from '@synesthesia-project/compositor/lib/modules/fill' ;
5
6
import { RGBA_TRANSPARENT } from '@synesthesia-project/compositor/lib/color' ;
@@ -60,14 +61,19 @@ export const Stage = async (plugins: Plugin[], configPath: string) => {
60
61
const inputManager = createInputManager ( ) ;
61
62
62
63
const compositor : {
63
- root : TransitionModule ;
64
+ transition : TransitionModule ;
65
+ modulate : ModulateModule ;
64
66
current : null | string ;
65
67
cues : Map < string , InputSocket > ;
66
- } = {
67
- root : new TransitionModule ( new FillModule ( RGBA_TRANSPARENT ) ) ,
68
- current : null ,
69
- cues : new Map ( ) ,
70
- } ;
68
+ } = ( ( ) => {
69
+ const transition = new TransitionModule ( new FillModule ( RGBA_TRANSPARENT ) ) ;
70
+ return {
71
+ transition,
72
+ modulate : new ModulateModule ( transition ) ,
73
+ current : null ,
74
+ cues : new Map ( ) ,
75
+ } ;
76
+ } ) ( ) ;
71
77
72
78
/**
73
79
* Map from output key to active instance of the output
@@ -117,6 +123,18 @@ export const Stage = async (plugins: Plugin[], configPath: string) => {
117
123
}
118
124
} ;
119
125
126
+ // Setup Dimmer
127
+ desk . compositorDimmer . addListener ( 'change' , ( value ) =>
128
+ updateConfig ( ( config ) => ( {
129
+ ...config ,
130
+ compositor : {
131
+ current : config . compositor ?. current ?? null ,
132
+ dimmer : value ,
133
+ cues : config . compositor ?. cues || { } ,
134
+ } ,
135
+ } ) )
136
+ ) ;
137
+
120
138
// Setup Sequences
121
139
122
140
const sequences = Sequences ( {
@@ -171,7 +189,7 @@ export const Stage = async (plugins: Plugin[], configPath: string) => {
171
189
}
172
190
} ;
173
191
const render : OutputContext < ConfigT > [ 'render' ] = ( map , pixels ) =>
174
- compositor . root . render ( map , pixels ) ;
192
+ compositor . modulate . render ( map , pixels ) ;
175
193
const setChannels : OutputContext < ConfigT > [ 'setChannels' ] = ( channels ) => {
176
194
activeOutput . channels = channels ;
177
195
sendChannelsToSequences ( ) ;
@@ -310,6 +328,8 @@ export const Stage = async (plugins: Plugin[], configPath: string) => {
310
328
311
329
const updateInputsFromConfig = ( prev : Config ) => {
312
330
const cues = config . compositor ?. cues || { } ;
331
+ compositor . modulate . setAlpha ( config . compositor ?. dimmer ?? 1 ) ;
332
+ desk . compositorDimmer . setValue ( config . compositor ?. dimmer ?? 1 ) ;
313
333
desk . compositorCueTriggers . removeAllChildren ( ) ;
314
334
for ( const [ cueId , cueConfig ] of Object . entries ( cues ) ) {
315
335
if ( cueConfig === undefined ) continue ;
@@ -322,6 +342,7 @@ export const Stage = async (plugins: Plugin[], configPath: string) => {
322
342
...current ,
323
343
compositor : {
324
344
current : current . compositor ?. current ?? null ,
345
+ dimmer : current . compositor ?. dimmer ?? 1 ,
325
346
cues : {
326
347
...current . compositor ?. cues ,
327
348
[ cueId ] : existing && update ( existing ) ,
@@ -339,6 +360,7 @@ export const Stage = async (plugins: Plugin[], configPath: string) => {
339
360
...current ,
340
361
compositor : {
341
362
current : current . compositor ?. current ?? null ,
363
+ dimmer : current . compositor ?. dimmer ?? 1 ,
342
364
cues : {
343
365
...current . compositor ?. cues ,
344
366
[ cueId ] : undefined ,
@@ -383,6 +405,7 @@ export const Stage = async (plugins: Plugin[], configPath: string) => {
383
405
...config ,
384
406
compositor : {
385
407
current : cueId ,
408
+ dimmer : config . compositor ?. dimmer ?? 1 ,
386
409
cues : config . compositor ?. cues || { } ,
387
410
} ,
388
411
} ) )
@@ -404,9 +427,9 @@ export const Stage = async (plugins: Plugin[], configPath: string) => {
404
427
? compositor . cues . get ( compositor . current ) ?. getModlue ( )
405
428
: null ;
406
429
if ( module ) {
407
- compositor . root . transition ( module , 1 ) ;
430
+ compositor . transition . transition ( module , 1 ) ;
408
431
} else {
409
- compositor . root . transition ( new FillModule ( RGBA_TRANSPARENT ) , 1 ) ;
432
+ compositor . transition . transition ( new FillModule ( RGBA_TRANSPARENT ) , 1 ) ;
410
433
}
411
434
}
412
435
} ;
@@ -424,6 +447,7 @@ export const Stage = async (plugins: Plugin[], configPath: string) => {
424
447
...config ,
425
448
compositor : {
426
449
current : config . compositor ?. current ?? null ,
450
+ dimmer : config . compositor ?. dimmer ?? 1 ,
427
451
cues : { ...config . compositor ?. cues , [ uuidv4 ( ) ] : { } } ,
428
452
} ,
429
453
} ) ) ,
0 commit comments