export default function StereoBalanceNode ( context , options = { balance : 0 } ) { let balance = 0 ; const upMixer = context . createGain ( ) ; upMixer . channelCount = 2 ; upMixer . channelCountMode = "explicit" ; upMixer . channelInterpretation = "speakers" ; const splitter = context . createChannelSplitter ( 2 ) ; const leftGain = context . createGain ( ) ; const rightGain = context . createGain ( ) ; const merger = context . createChannelMerger ( 2 ) ; upMixer . connect ( splitter ) ; splitter . connect ( leftGain , 0 ) ; splitter . connect ( rightGain , 1 ) ; leftGain . connect ( merger , 0 , 0 ) ; rightGain . connect ( merger , 0 , 1 ) ; function set ( rawValue ) { const value = Number ( rawValue ) ; leftGain . gain . value = value > 0 ? 1 - value : 1 ; rightGain . gain . value = value > 0 ? 1 : 1 + value ; balance = value ; } function get ( ) { return balance ; } const audioParam = { } ; Object . defineProperties ( audioParam , { value : { get , set , enumerable : true , configurable : true } , } ) ; Object . defineProperties ( upMixer , { balance : { value : audioParam , enumerable : true , writable : false , configurable : true , } , connect : { value : AudioNode . prototype . connect . bind ( merger ) , enumerable : false , writable : false , configurable : true , } , disconnect : { value : AudioNode . prototype . disconnect . bind ( merger ) , enumerable : false , writable : false , configurable : true , } , } ) ; if ( balance !== options . balance ) { set ( options . balance ) ; } return upMixer ; }