add volume param to program state and corresponding dial to ui - issue #12

This commit is contained in:
Daniel Top
2021-05-17 16:12:19 -07:00
parent 0e04b0db90
commit 7e5862e582
3 changed files with 8 additions and 3 deletions

View File

@@ -244,9 +244,12 @@ async function start() {
drums: await NineOhUnit(audio),
gen,
delay,
clock
clock,
masterVolume: parameter("Volume", [0,1], 0.5)
}
programState.masterVolume.subscribe(newVolume => { audio.master.in.gain.value = newVolume; });
clock.currentStep.subscribe(step => [...programState.notes, programState.drums].forEach(d => d.step(step)));
const autoPilot = AutoPilot(programState);
const ui = UI(programState, autoPilot, audio.master.analyser);

View File

@@ -107,5 +107,6 @@ export type ProgramState = {
drums: NineOhMachine,
gen: NoteGenerator,
delay: DelayUnit
clock: ClockUnit
}
clock: ClockUnit,
masterVolume: NumericParameter
}

View File

@@ -302,6 +302,7 @@ export function UI(state: ProgramState, autoPilot: AutoPilotUnit, analyser: Anal
NoteGen(state.gen),
DelayControls(state.delay),
controlGroup(label("Clock"), DialSet([state.clock.bpm], "horizontal")),
controlGroup(label("Volume"), DialSet([state.masterVolume], "horizontal")),
controlGroup(label("Meter"), group(AudioMeter(analyser)), "meter")
)