Search the Community
Showing results for tags 'chip sound'.
-
Hi, I'm building a Phaser 3 game currently and looked into the new dynamic sound. I made a tiny bleep maker myself that has a core oscillator, a second oscillator for frequency modulation on the first, pitch bend on the first, and a third oscillator to create an "artifact" trailing sound(using same frequency mod as first oscillator)..its very simple ,I'm new to webaudio and thought someone else might have fun with it for funky bleeps. here's a test html: <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <head> <body> <script> context = new AudioContext(); function start_Sfx(vco,fm,artifact) { context!=undefined?context.close():null; context = new AudioContext(); var core_vco = context.createOscillator(); //waveform type: "sine", "triangle", "square", "sawtooth" core_vco.type = vco.wave; core_vco.frequency.value = vco.freq; //frequency mod fm_source = context.createOscillator(); fm_source.frequency.value = fm.freq; fm_source.type = fm.wave; modulationGain = context.createGain(); modulationGain = context.createGain(); modulationGain.gain.value = 1000; fm_source.connect(modulationGain); modulationGain.connect(core_vco.detune); core_vco.connect(context.destination); //end //cheap pitch bend on first vco core_vco.frequency.setValueAtTime(vco.freq, context.currentTime); core_vco.frequency.linearRampToValueAtTime(vco.freq*vco.bendAmt,context.currentTime+vco.decay); //end //start vco and fm vco fm_source.start(context.currentTime); core_vco.start(context.currentTime); core_vco.stop(vco.decay); fm_source.stop(fm.decay); //artifact if(artifact!=undefined) { artifact_vco = context.createOscillator(); artifact_vco.type = artifact.wave; artifact_vco.frequency.value = artifact.freq; artifact_vco.connect(context.destination); modulationGain.connect(artifact_vco.detune); artifact_vco.start(context.currentTime+artifact.wait); artifact_vco.stop(artifact.decay); } } function playSound() { start_Sfx({wave:'square',freq:50,wait:.1,decay:.2,bendAmt:10},{wave:'sine',freq:10,wait:0,decay:1},{wave:'square',freq:200,wait:.1,decay:.2}); } </script> <button onClick="playSound()"><b>test audio</b></button> </body> </html>
-
- web audio
- chip sound
-
(and 1 more)
Tagged with: