@@ -4,6 +4,7 @@ import {Config} from "../synth/SynthConfig";
44import { SongDocument } from "./SongDocument" ;
55import { HTML } from "imperative-html/dist/esm/elements-strict" ;
66import { ColorConfig } from "./ColorConfig" ;
7+ import { LiveInput } from "./LiveInput" ;
78
89export class Piano {
910 private readonly _pianoContainer : HTMLDivElement = HTML . div ( { style : "width: 100%; height: 100%; display: flex; flex-direction: column-reverse; align-items: stretch;" } ) ;
@@ -31,7 +32,7 @@ export class Piano {
3132 private _renderedKey : number = - 1 ;
3233 private _renderedPitchCount : number = - 1 ;
3334
34- constructor ( private _doc : SongDocument ) {
35+ constructor ( private _doc : SongDocument , private _liveInput : LiveInput ) {
3536 for ( let i : number = 0 ; i < Config . drumCount ; i ++ ) {
3637 const scale : number = ( 1.0 - ( i / Config . drumCount ) * 0.35 ) * 100 ;
3738 const brightness : number = 1.0 + ( ( i - Config . drumCount / 2.0 ) / Config . drumCount ) * 0.5 ;
@@ -83,15 +84,14 @@ export class Piano {
8384 const octaveOffset : number = this . _doc . getBaseVisibleOctave ( this . _doc . channel ) * Config . pitchesPerOctave ;
8485 const currentPitch : number = this . _cursorPitch + octaveOffset ;
8586 if ( this . _playedPitch == currentPitch ) return ;
87+ this . _liveInput . removeNote ( this . _playedPitch ) ;
8688 this . _playedPitch = currentPitch ;
87- this . _doc . synth . liveInputDuration = Number . MAX_SAFE_INTEGER ;
88- this . _doc . synth . liveInputPitches = [ this . _playedPitch ] ;
89- this . _doc . synth . liveInputStarted = true ;
89+ this . _liveInput . addNote ( currentPitch ) ;
9090 }
9191
9292 private _releaseLiveInput ( ) : void {
93+ this . _liveInput . removeNote ( this . _playedPitch ) ;
9394 this . _playedPitch = - 1 ;
94- this . _doc . synth . liveInputDuration = 0 ;
9595 }
9696
9797 private _whenMouseOver = ( event : MouseEvent ) : void => {
@@ -181,8 +181,6 @@ export class Piano {
181181 this . _pitchHeight = this . _editorHeight / this . _pitchCount ;
182182 this . _updateCursorPitch ( ) ;
183183 if ( this . _mouseDown ) this . _playLiveInput ( ) ;
184- this . _doc . synth . liveInputChannel = this . _doc . channel ;
185- this . _doc . synth . liveInputInstruments = this . _doc . recentPatternInstruments [ this . _doc . channel ] ;
186184
187185 if ( ! this . _doc . showLetters ) return ;
188186 if ( this . _renderedScale == this . _doc . song . scale && this . _renderedKey == this . _doc . song . key && this . _renderedDrums == isDrum && this . _renderedPitchCount == this . _pitchCount ) return ;
0 commit comments