this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add filter to example

+14 -9
+14 -9
src/main.ts
··· 2 2 import "./style.css"; 3 3 4 4 let audioCtx: AudioContext; 5 - let osc1: OscillatorNode; 6 5 7 6 function start() { 8 7 const startButton = document.getElementById("start"); ··· 17 16 audioCtx = new AudioContext(); 18 17 const freq = 261.625565; // Middle C 19 18 20 - osc1 = new OscillatorNode(audioCtx, { 19 + const osc1 = new OscillatorNode(audioCtx, { 21 20 frequency: freq, 22 21 type: "sawtooth", 23 22 }); 23 + osc1.start(); 24 + 25 + const vca1 = new GainNode(audioCtx); 26 + vca1.gain.value = 0.0; 24 27 25 28 const adsr1 = new AdsrNode(audioCtx, { 26 - attack: 0.01, 29 + attack: 0.1, 27 30 decay: 0.11, 28 - sustain: 0.0, 31 + sustain: 0.3, 29 32 release: 0.1, 30 33 }); 31 34 adsr1.start(); 35 + adsr1.connect(vca1.gain); 32 36 33 - const vca1 = new GainNode(audioCtx); 34 - vca1.gain.value = 0.0; 37 + const filter = new BiquadFilterNode(audioCtx, { 38 + type: "lowpass", 39 + frequency: 500, 40 + Q: 10.0, 41 + }); 35 42 36 43 const vol = new GainNode(audioCtx); 37 44 vol.gain.value = 1.0; 38 45 39 - adsr1.connect(vca1.gain); 40 - osc1.connect(vca1).connect(vol).connect(audioCtx.destination); 41 - osc1.start(); 46 + osc1.connect(vca1).connect(filter).connect(vol).connect(audioCtx.destination); 42 47 43 48 const play = () => { 44 49 if (audioCtx.state === "suspended") {