var flag_396=false; var flag_417=false; var flag_528=false; var flag_639=false; var flag_741=false; var flag_852=false; var bwave_1 = 8; var jsVolume = 0.08; var flg_bgSound = false; var oscillatorR , oscillatorL; var context = new AudioContext(); function switchFQ ( freq, mode ) { if ( freq == 396 ) { if ( mode == 1 ) { if ( flag_396 == true ) { }else { $("#on396" ).addClass ("active"); $("#off396").removeClass("active"); flag_396=true; soundStart396( ); } }else { $("#on396" ).removeClass("active"); $("#off396").addClass ("active"); flag_396=false; soundStop396(); } } if ( freq == 417 ) { if ( mode == 1 ) { if ( flag_417 == true ) { }else { $("#on417" ).addClass ("active"); $("#off417").removeClass("active"); flag_417=true; soundStart417( ); } }else { $("#on417" ).removeClass("active"); $("#off417").addClass ("active"); flag_417=false; soundStop417(); } } if ( freq == 528 ) { if ( mode == 1 ) { if ( flag_528 == true ) { }else { $("#on528" ).addClass ("active"); $("#off528").removeClass("active"); flag_528=true; soundStart528( ); } }else { $("#on528" ).removeClass("active"); $("#off528").addClass ("active"); flag_528=false; soundStop528(); } } if ( freq == 639 ) { if ( mode == 1 ) { if ( flag_639 == true ) { }else { $("#on639" ).addClass ("active"); $("#off639").removeClass("active"); flag_639=true; soundStart639( ); } }else { $("#on639" ).removeClass("active"); $("#off639").addClass ("active"); flag_639=false; soundStop639(); } } if ( freq == 741 ) { if ( mode == 1 ) { if ( flag_741 == true ) { }else { $("#on741" ).addClass ("active"); $("#off741").removeClass("active"); flag_741=true; soundStart741( ); } }else { $("#on741" ).removeClass("active"); $("#off741").addClass ("active"); flag_741=false; soundStop741(); } } if ( freq == 852 ) { if ( mode == 1 ) { if ( flag_852 == true ) { }else { $("#on852" ).addClass ("active"); $("#off852").removeClass("active"); flag_852=true; soundStart852( ); } }else { $("#on852" ).removeClass("active"); $("#off852").addClass ("active"); flag_852=false; soundStop852(); } } }//function switchFQ function soundStart396( ) { window.AudioContext = window.AudioContext || window.webkitAudioContext; flg_396 = true; sfreq_1 = 396; //------------------------------------------------------Define R //Create the instance of oscillatorRNode var oscillatorR = context.createOscillator(); //Set parameters oscillatorR.type = 'sine' ; oscillatorR.frequency.value = sfreq_1 - bwave_1/2 ; // Hz oscillatorR.detune.value = 0; //100 cent //for legacy browsers oscillatorR.start = oscillatorR.start || oscillatorR.noteOn; oscillatorR.stop = oscillatorR.stop || oscillatorR.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeR = context.createGain(); gainNodeR.gain.value = jsVolume ; //PAN var pannerR = context.createPanner(); pannerR.setPosition(-1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorR.connect(gainNodeR); gainNodeR.connect(pannerR); pannerR.connect(context.destination); //------------------------------------------------------Define L //Create the instance of oscillatorRNode var oscillatorL = context.createOscillator(); //Set parameters oscillatorL.type = 'sine' ; oscillatorL.frequency.value = sfreq_1 + bwave_1/2 ; // Hz oscillatorL.detune.value = 0; //100 cent //for legacy browsers oscillatorL.start = oscillatorL.start || oscillatorL.noteOn; oscillatorL.stop = oscillatorL.stop || oscillatorL.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeL = context.createGain(); gainNodeL.gain.value = jsVolume ; //PAN var pannerL = context.createPanner(); pannerL.setPosition(1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorL.connect(gainNodeL); gainNodeL.connect(pannerL); pannerL.connect(context.destination); //ŠJŽn ------------------------------ oscillatorR.start(0); oscillatorL.start(0); //’âŽ~ ------------------------------ soundStop396 = function ( ) { flg_396 = false; oscillatorR.stop(0); oscillatorL.stop(0); } } soundStop396 = function ( ) {} function soundStart417( ) { window.AudioContext = window.AudioContext || window.webkitAudioContext; flg_417 = true; sfreq_1 = 417; //------------------------------------------------------Define R //Create the instance of oscillatorRNode var oscillatorR = context.createOscillator(); //Set parameters oscillatorR.type = 'sine' ; oscillatorR.frequency.value = sfreq_1 - bwave_1/2 ; // Hz oscillatorR.detune.value = 0; //100 cent //for legacy browsers oscillatorR.start = oscillatorR.start || oscillatorR.noteOn; oscillatorR.stop = oscillatorR.stop || oscillatorR.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeR = context.createGain(); gainNodeR.gain.value = jsVolume ; //PAN var pannerR = context.createPanner(); pannerR.setPosition(-1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorR.connect(gainNodeR); gainNodeR.connect(pannerR); pannerR.connect(context.destination); //------------------------------------------------------Define L //Create the instance of oscillatorRNode var oscillatorL = context.createOscillator(); //Set parameters oscillatorL.type = 'sine' ; oscillatorL.frequency.value = sfreq_1 + bwave_1/2 ; // Hz oscillatorL.detune.value = 0; //100 cent //for legacy browsers oscillatorL.start = oscillatorL.start || oscillatorL.noteOn; oscillatorL.stop = oscillatorL.stop || oscillatorL.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeL = context.createGain(); gainNodeL.gain.value = jsVolume ; //PAN var pannerL = context.createPanner(); pannerL.setPosition(1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorL.connect(gainNodeL); gainNodeL.connect(pannerL); pannerL.connect(context.destination); //ŠJŽn ------------------------------ oscillatorR.start(0); oscillatorL.start(0); //’âŽ~ ------------------------------ soundStop417 = function ( ) { flg_417 = false; oscillatorR.stop(0); oscillatorL.stop(0); } } soundStop417 = function ( ) {} function soundStart528( ) { window.AudioContext = window.AudioContext || window.webkitAudioContext; flg_528 = true; sfreq_1 = 528; //------------------------------------------------------Define R //Create the instance of oscillatorRNode var oscillatorR = context.createOscillator(); //Set parameters oscillatorR.type = 'sine' ; oscillatorR.frequency.value = sfreq_1 - bwave_1/2 ; // Hz oscillatorR.detune.value = 0; //100 cent //for legacy browsers oscillatorR.start = oscillatorR.start || oscillatorR.noteOn; oscillatorR.stop = oscillatorR.stop || oscillatorR.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeR = context.createGain(); gainNodeR.gain.value = jsVolume ; //PAN var pannerR = context.createPanner(); pannerR.setPosition(-1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorR.connect(gainNodeR); gainNodeR.connect(pannerR); pannerR.connect(context.destination); //------------------------------------------------------Define L //Create the instance of oscillatorRNode var oscillatorL = context.createOscillator(); //Set parameters oscillatorL.type = 'sine' ; oscillatorL.frequency.value = sfreq_1 + bwave_1/2 ; // Hz oscillatorL.detune.value = 0; //100 cent //for legacy browsers oscillatorL.start = oscillatorL.start || oscillatorL.noteOn; oscillatorL.stop = oscillatorL.stop || oscillatorL.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeL = context.createGain(); gainNodeL.gain.value = jsVolume ; //PAN var pannerL = context.createPanner(); pannerL.setPosition(1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorL.connect(gainNodeL); gainNodeL.connect(pannerL); pannerL.connect(context.destination); //ŠJŽn ------------------------------ oscillatorR.start(0); oscillatorL.start(0); //’âŽ~ ------------------------------ soundStop528 = function ( ) { flg_528 = false; oscillatorR.stop(0); oscillatorL.stop(0); } } soundStop528 = function ( ) {} function soundStart639( ) { window.AudioContext = window.AudioContext || window.webkitAudioContext; flg_639 = true; sfreq_1 = 639; //------------------------------------------------------Define R //Create the instance of oscillatorRNode var oscillatorR = context.createOscillator(); //Set parameters oscillatorR.type = 'sine' ; oscillatorR.frequency.value = sfreq_1 - bwave_1/2 ; // Hz oscillatorR.detune.value = 0; //100 cent //for legacy browsers oscillatorR.start = oscillatorR.start || oscillatorR.noteOn; oscillatorR.stop = oscillatorR.stop || oscillatorR.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeR = context.createGain(); gainNodeR.gain.value = jsVolume ; //PAN var pannerR = context.createPanner(); pannerR.setPosition(-1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorR.connect(gainNodeR); gainNodeR.connect(pannerR); pannerR.connect(context.destination); //------------------------------------------------------Define L //Create the instance of oscillatorRNode var oscillatorL = context.createOscillator(); //Set parameters oscillatorL.type = 'sine' ; oscillatorL.frequency.value = sfreq_1 + bwave_1/2 ; // Hz oscillatorL.detune.value = 0; //100 cent //for legacy browsers oscillatorL.start = oscillatorL.start || oscillatorL.noteOn; oscillatorL.stop = oscillatorL.stop || oscillatorL.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeL = context.createGain(); gainNodeL.gain.value = jsVolume ; //PAN var pannerL = context.createPanner(); pannerL.setPosition(1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorL.connect(gainNodeL); gainNodeL.connect(pannerL); pannerL.connect(context.destination); //ŠJŽn ------------------------------ oscillatorR.start(0); oscillatorL.start(0); //’âŽ~ ------------------------------ soundStop639 = function ( ) { flg_639 = false; oscillatorR.stop(0); oscillatorL.stop(0); } } soundStop639 = function ( ) {} function soundStart741( ) { window.AudioContext = window.AudioContext || window.webkitAudioContext; flg_741 = true; sfreq_1 = 741; //------------------------------------------------------Define R //Create the instance of oscillatorRNode var oscillatorR = context.createOscillator(); //Set parameters oscillatorR.type = 'sine' ; oscillatorR.frequency.value = sfreq_1 - bwave_1/2 ; // Hz oscillatorR.detune.value = 0; //100 cent //for legacy browsers oscillatorR.start = oscillatorR.start || oscillatorR.noteOn; oscillatorR.stop = oscillatorR.stop || oscillatorR.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeR = context.createGain(); gainNodeR.gain.value = jsVolume ; //PAN var pannerR = context.createPanner(); pannerR.setPosition(-1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorR.connect(gainNodeR); gainNodeR.connect(pannerR); pannerR.connect(context.destination); //------------------------------------------------------Define L //Create the instance of oscillatorRNode var oscillatorL = context.createOscillator(); //Set parameters oscillatorL.type = 'sine' ; oscillatorL.frequency.value = sfreq_1 + bwave_1/2 ; // Hz oscillatorL.detune.value = 0; //100 cent //for legacy browsers oscillatorL.start = oscillatorL.start || oscillatorL.noteOn; oscillatorL.stop = oscillatorL.stop || oscillatorL.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeL = context.createGain(); gainNodeL.gain.value = jsVolume ; //PAN var pannerL = context.createPanner(); pannerL.setPosition(1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorL.connect(gainNodeL); gainNodeL.connect(pannerL); pannerL.connect(context.destination); //ŠJŽn ------------------------------ oscillatorR.start(0); oscillatorL.start(0); //’âŽ~ ------------------------------ soundStop741 = function ( ) { flg_741 = false; oscillatorR.stop(0); oscillatorL.stop(0); } } soundStop741 = function ( ) {} function soundStart852( ) { window.AudioContext = window.AudioContext || window.webkitAudioContext; flg_852 = true; sfreq_1 = 852; //------------------------------------------------------Define R //Create the instance of oscillatorRNode var oscillatorR = context.createOscillator(); //Set parameters oscillatorR.type = 'sine' ; oscillatorR.frequency.value = sfreq_1 - bwave_1/2 ; // Hz oscillatorR.detune.value = 0; //100 cent //for legacy browsers oscillatorR.start = oscillatorR.start || oscillatorR.noteOn; oscillatorR.stop = oscillatorR.stop || oscillatorR.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeR = context.createGain(); gainNodeR.gain.value = jsVolume ; //PAN var pannerR = context.createPanner(); pannerR.setPosition(-1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorR.connect(gainNodeR); gainNodeR.connect(pannerR); pannerR.connect(context.destination); //------------------------------------------------------Define L //Create the instance of oscillatorRNode var oscillatorL = context.createOscillator(); //Set parameters oscillatorL.type = 'sine' ; oscillatorL.frequency.value = sfreq_1 + bwave_1/2 ; // Hz oscillatorL.detune.value = 0; //100 cent //for legacy browsers oscillatorL.start = oscillatorL.start || oscillatorL.noteOn; oscillatorL.stop = oscillatorL.stop || oscillatorL.noteOff; context.createGain = context.createGain || context.createGainNode; //Create the instance of GainNode var gainNodeL = context.createGain(); gainNodeL.gain.value = jsVolume ; //PAN var pannerL = context.createPanner(); pannerL.setPosition(1,0,0); //oscillatorRNode (input) -> GainNode -> AudioDestinationNode (output) oscillatorL.connect(gainNodeL); gainNodeL.connect(pannerL); pannerL.connect(context.destination); //ŠJŽn ------------------------------ oscillatorR.start(0); oscillatorL.start(0); //’âŽ~ ------------------------------ soundStop852 = function ( ) { flg_852 = false; oscillatorR.stop(0); oscillatorL.stop(0); } } soundStop852 = function ( ) {} //$ary_freq = array(396,417,528,639,741,852); function changeBwave(){ soundStop852(); soundStop741(); soundStop639(); soundStop528(); soundStop417(); soundStop396(); bwave_1 = document.getElementById("selectBWave").options[document.getElementById("selectBWave").selectedIndex].value; if ( flag_852 ) { soundStart852(); } if ( flag_741 ) { soundStart741(); } if ( flag_639 ) { soundStart639(); } if ( flag_528 ) { soundStart528(); } if ( flag_417 ) { soundStart417(); } if ( flag_396 ) { soundStart396(); } } function allstop( ) { switchFQ(396,0); switchFQ(417,0); switchFQ(528,0); switchFQ(639,0); switchFQ(741,0); switchFQ(852,0); document.getElementById("BgSound").selectedIndex = 0; }