feross / timidity

Play MIDI files in the browser w/ Web Audio, WebAssembly, and libtimidity
https://bitmidi.com
MIT License
368 stars 38 forks source link

Volume control #22

Open connorjclark opened 2 years ago

connorjclark commented 2 years ago

Is there anyway to control the volume?

connorjclark commented 2 years ago

This works:

const gainNode = this.midiPlayer._audioContext.createGain();
    gainNode.gain.value = 0.25;
    gainNode.connect(this.midiPlayer._audioContext.destination);
    this.midiPlayer._node.disconnect(this.midiPlayer._audioContext.destination)
    this.midiPlayer._node.connect(gainNode);