diff --git a/src/app.ts b/src/app.ts index 34e6722..c771ea0 100644 --- a/src/app.ts +++ b/src/app.ts @@ -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); diff --git a/src/interface.ts b/src/interface.ts index cc4b4a9..3b8c84c 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -107,5 +107,6 @@ export type ProgramState = { drums: NineOhMachine, gen: NoteGenerator, delay: DelayUnit - clock: ClockUnit -} \ No newline at end of file + clock: ClockUnit, + masterVolume: NumericParameter +} diff --git a/src/ui.ts b/src/ui.ts index 5c3e7ec..45e2a58 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -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") )