@@ -6,6 +6,13 @@ import { PinsPanel } from "./PinsPanel";
66import { MenuItem } from "../menu/menu" ;
77import { getNoteForKey } from "./PatternEditorHelper" ;
88
9+ function colorWithBrightness ( r : number , g : number , b : number , brightness : number ) {
10+ const red = Math . max ( 0 , Math . min ( 255 , Math . round ( r * brightness ) ) ) ;
11+ const green = Math . max ( 0 , Math . min ( 255 , Math . round ( g * brightness ) ) ) ;
12+ const blue = Math . max ( 0 , Math . min ( 255 , Math . round ( b * brightness ) ) ) ;
13+ return "rgb(" + red + ", " + green + ", " + blue + ")" ;
14+ }
15+
916const boxWidth = 100 ;
1017const boxHeight = 61 ; // 1.618
1118const arrowSize = 10 ;
@@ -170,6 +177,7 @@ export class MixerCanvas implements IComponent {
170177 this . app . song . addEventListener ( "createInstrument" , this . onResize ) ;
171178 this . app . song . addEventListener ( "updateInstrument" , this . onResize ) ;
172179 this . app . song . addEventListener ( "deleteInstrument" , this . onResize ) ;
180+ this . app . song . addEventListener ( "setInstrumentMuted" , this . onResize ) ;
173181 this . app . song . addEventListener ( "createConnection" , this . onResize ) ;
174182 this . app . song . addEventListener ( "deleteConnection" , this . onResize ) ;
175183 } ;
@@ -178,6 +186,7 @@ export class MixerCanvas implements IComponent {
178186 this . app . song . removeEventListener ( "createInstrument" , this . onResize ) ;
179187 this . app . song . removeEventListener ( "updateInstrument" , this . onResize ) ;
180188 this . app . song . removeEventListener ( "deleteInstrument" , this . onResize ) ;
189+ this . app . song . removeEventListener ( "setInstrumentMuted" , this . onResize ) ;
181190 this . app . song . removeEventListener ( "createConnection" , this . onResize ) ;
182191 this . app . song . removeEventListener ( "deleteConnection" , this . onResize ) ;
183192 } ;
@@ -469,25 +478,28 @@ export class MixerCanvas implements IComponent {
469478 ctx . lineWidth = 3 ;
470479 }
471480
472- const hasIn = this . app . song . connections . find ( c => c . to === instrument ) ;
473- const hasOut = this . app . song . connections . find ( c => c . from === instrument ) ;
481+ const instrumenteer = this . app . playerSongAdapter . instrumentMap . get ( instrument ) ;
482+ const hasIn = ! ! instrumenteer . instrument . inputNode ;
483+ const hasOut = ! ! instrumenteer . instrument . outputNode ;
484+ const brightness = instrument . muted ? 0.6 : 1.0 ;
474485 if ( hasIn && ! hasOut ) {
475- ctx . fillStyle = "#5C704C" ;
486+ ctx . fillStyle = colorWithBrightness ( 92 , 112 , 76 , brightness ) ;
476487 } else if ( hasIn && hasOut ) {
477- ctx . fillStyle = "#101010" ;
488+ ctx . fillStyle = colorWithBrightness ( 68 , 68 , 68 , brightness ) ;
478489 } else {
479- ctx . fillStyle = "#2A614B" ;
490+ ctx . fillStyle = colorWithBrightness ( 42 , 97 , 75 , brightness ) ;
480491 }
481492
482493 ctx . strokeStyle = "#000" ;
483494
484495 ctx . fillRect ( c [ 0 ] - boxWidth / 2 , c [ 1 ] - boxHeight / 2 , boxWidth , boxHeight ) ;
485496 ctx . strokeRect ( c [ 0 ] - boxWidth / 2 , c [ 1 ] - boxHeight / 2 , boxWidth , boxHeight ) ;
486497
487- const mt = ctx . measureText ( instrument . name ) ;
498+ const name = instrument . muted ? "(" + instrument . name + ")" : instrument . name ;
499+ const mt = ctx . measureText ( name ) ;
488500
489501 ctx . fillStyle = "#FFF" ;
490- ctx . fillText ( instrument . name , c [ 0 ] - mt . width / 2 , c [ 1 ] + mt . fontBoundingBoxAscent - fontHeight / 2 ) ;
502+ ctx . fillText ( name , c [ 0 ] - mt . width / 2 , c [ 1 ] + mt . fontBoundingBoxAscent - fontHeight / 2 ) ;
491503
492504 ctx . restore ( ) ;
493505
0 commit comments