Implemented sound and lighting sliders
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Main } from './main';
|
||||
import { Main, UnityWebSocketStatus } from './main';
|
||||
|
||||
export class Sound {
|
||||
private _Main: Main;
|
||||
@@ -18,5 +18,99 @@ export class Sound {
|
||||
|
||||
constructor(Main: Main) {
|
||||
this._Main = Main;
|
||||
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
update(state: UnityWebSocketStatus) {
|
||||
if (state?.parameters?.dataSliders == null) return;
|
||||
|
||||
const volumeSliderIndex = state.parameters?.dataSliders.findIndex(
|
||||
(slider) => slider.sliderName === 'Volume',
|
||||
);
|
||||
const volumeSlider =
|
||||
state.parameters?.dataSliders[volumeSliderIndex ?? -1];
|
||||
|
||||
const eqLowSliderIndex = state.parameters?.dataSliders.findIndex(
|
||||
(slider) => slider.sliderName === 'EQ_Low',
|
||||
);
|
||||
const eqLowSlider =
|
||||
state.parameters?.dataSliders[eqLowSliderIndex ?? -1];
|
||||
|
||||
const eqMidSliderIndex = state.parameters?.dataSliders.findIndex(
|
||||
(slider) => slider.sliderName === 'EQ_Mid',
|
||||
);
|
||||
const eqMidSlider =
|
||||
state.parameters?.dataSliders[eqMidSliderIndex ?? -1];
|
||||
|
||||
const eqHighSliderIndex = state.parameters?.dataSliders.findIndex(
|
||||
(slider) => slider.sliderName === 'EQ_High',
|
||||
);
|
||||
const eqHighSlider =
|
||||
state.parameters?.dataSliders[eqHighSliderIndex ?? -1];
|
||||
|
||||
this.volumeInput.valueAsNumber =
|
||||
volumeSlider?.outputValue ?? this.volumeInput.valueAsNumber;
|
||||
this.eqLowInput.valueAsNumber =
|
||||
eqLowSlider?.outputValue ?? this.eqLowInput.valueAsNumber;
|
||||
this.eqMidInput.valueAsNumber =
|
||||
eqMidSlider?.outputValue ?? this.eqMidInput.valueAsNumber;
|
||||
this.eqHighInput.valueAsNumber =
|
||||
eqHighSlider?.outputValue ?? this.eqHighInput.valueAsNumber;
|
||||
|
||||
this.volumeInput.setAttribute(
|
||||
'index',
|
||||
volumeSliderIndex?.toString() ?? '-1',
|
||||
);
|
||||
this.eqLowInput.setAttribute(
|
||||
'index',
|
||||
eqLowSliderIndex?.toString() ?? '-1',
|
||||
);
|
||||
this.eqMidInput.setAttribute(
|
||||
'index',
|
||||
eqMidSliderIndex?.toString() ?? '-1',
|
||||
);
|
||||
this.eqHighInput.setAttribute(
|
||||
'index',
|
||||
eqHighSliderIndex?.toString() ?? '-1',
|
||||
);
|
||||
}
|
||||
|
||||
private registerListeners() {
|
||||
this.volumeInput.onchange = () => {
|
||||
this._Main.socket.emit(
|
||||
'unityWebSocket',
|
||||
'dataParameterValue',
|
||||
parseInt(this.volumeInput.getAttribute('index') ?? '-1'),
|
||||
this.volumeInput.valueAsNumber,
|
||||
);
|
||||
};
|
||||
|
||||
this.eqLowInput.onchange = () => {
|
||||
this._Main.socket.emit(
|
||||
'unityWebSocket',
|
||||
'dataParameterValue',
|
||||
parseInt(this.eqLowInput.getAttribute('index') ?? '-1'),
|
||||
this.eqLowInput.valueAsNumber,
|
||||
);
|
||||
};
|
||||
|
||||
this.eqMidInput.onchange = () => {
|
||||
this._Main.socket.emit(
|
||||
'unityWebSocket',
|
||||
'dataParameterValue',
|
||||
parseInt(this.eqMidInput.getAttribute('index') ?? '-1'),
|
||||
this.eqMidInput.valueAsNumber,
|
||||
);
|
||||
};
|
||||
|
||||
this.eqHighInput.onchange = () => {
|
||||
this._Main.socket.emit(
|
||||
'unityWebSocket',
|
||||
'dataParameterValue',
|
||||
parseInt(this.eqHighInput.getAttribute('index') ?? '-1'),
|
||||
this.eqHighInput.valueAsNumber,
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user