├── 01 Introducing the Web Audio API ├── .vscode │ └── launch.json ├── HelloWorld │ ├── HelloWorld.html │ ├── HelloWorld2.html │ └── HelloWorld3.html ├── README.md ├── UserInteraction │ ├── UserInteraction.html │ └── UserInteraction.js └── index.html ├── 02 Oscillators ├── Detuning │ ├── detune.html │ └── detune.js ├── OscillatorNode │ ├── Oscillator.html │ └── Oscillator.js ├── PeriodicWave │ ├── CustomSquareWave.html │ └── PulseWave.html ├── README.md └── index.html ├── 03 Audio Buffer Sources ├── Backwards.html ├── BufferedNoise.html ├── BufferedSquareWave.html ├── Pause.html ├── Playback │ ├── Playback.html │ └── Playback.js ├── README.md └── index.html ├── 04 Constant Sources ├── ConstantSourceSquareWave │ ├── ConstantSourceSquareWave.html │ └── NoConstantSourceSquareWave.html ├── DCoffset.html ├── Grouping tracks │ ├── 01_Congas.wav │ ├── 02_Bass.wav │ ├── 03_UkeleleMic.wav │ ├── 04_UkeleleDI.wav │ ├── 05_Viola.wav │ ├── 06_Cello.wav │ ├── 07_LeadVox.wav │ ├── 08_BackingVox.wav │ ├── Grouping.html │ ├── Grouping.js │ └── Readme.txt ├── README.md └── index.html ├── 05 Parameter automation ├── Beep │ ├── Beep.js │ └── beep.html ├── Bells │ ├── Bells.html │ └── Bells.js ├── Crossfade │ ├── Crossfade.html │ └── Crossfade.js ├── README.md ├── RepeatBeep │ └── RepeatBeep.html ├── SetValueCurve.html └── index.html ├── 06 Connecting audio parameters and modulation ├── AM Synthesis │ ├── AMSynthesis.html │ └── AMSynthesis.js ├── FM Synthesis │ ├── FMSynthesis.html │ └── FMSynthesis.js ├── README.md └── index.html ├── 07 Analysis and visualization ├── Analyser.html ├── Analyser.js ├── README.md └── index.html ├── 08 Loading and recording ├── LevelMeter.html ├── MediaElement │ ├── MediaElement.html │ ├── MediaElement2.html │ ├── SimpleMediaElement.html │ └── beat1.mp3 ├── MediaStreamToAudioBuffer.html ├── README.md ├── Record an Audio Node │ ├── MediaRecorderExample.html │ ├── RecorderExample.html │ └── recorder.js ├── decodeAudioData │ ├── beat1.mp3 │ ├── decodeWithFetch.html │ ├── decodeWithRequest.html │ └── playbackMultipleInSequence.html └── index.html ├── 09 OfflineAudioContext ├── OfflineContext.html ├── OfflineContext2.html ├── OfflineContext3.html ├── README.md ├── bufferToWave.js └── index.html ├── 10 Delay ├── KarplusStrong │ ├── KarplusStrong.html │ └── KarplusStrong.js ├── README.md ├── Vibrato │ ├── trumpet.wav │ ├── vibrato.html │ └── vibrato.js ├── combFilter.html ├── doppler.html ├── feedbackDelay.html └── index.html ├── 11 Filters ├── BiquadFilterNode │ ├── biquad.html │ └── biquad.js ├── IIRFilterNode │ ├── IIRFilter.html │ ├── audio.js │ ├── flange love.mp3 │ └── graphics.js ├── Instability │ ├── BiquadInstability.html │ ├── IIRInstability.html │ └── flange love.mp3 ├── README.md └── index.html ├── 12 Waveshaper ├── BitCrusher.html ├── Clipper.html ├── README.md └── index.html ├── 13 Dynamic Range Compression ├── Attack and release │ ├── AttackRelease.html │ └── AttackRelease.js ├── Compressor │ ├── compressor.html │ └── compressor.js ├── README.md └── index.html ├── 14 Reverb ├── ConvolutionReverb.html ├── NormalizeIR │ ├── NormalizeIR.html │ ├── applause.mp3 │ ├── unit_long.wav │ └── unit_short.wav ├── README.md └── index.html ├── 15 Mixing audio ├── ChannelFlip.html ├── PingPongDelay.html ├── README.md └── index.html ├── 16 Stereo panning ├── README.md ├── Stereo Enhancer │ ├── Stereo speech.wav │ ├── stereoEnhancer.html │ └── symphonic_warmup.wav ├── index.html └── stereoPanning.html ├── 17 Spatial audio ├── README.md ├── index.html ├── listener │ ├── listener.html │ └── listener.js ├── notes.TXT └── pannerNode │ ├── drone.wav │ ├── panner.html │ └── panner.js ├── 18 Working with AudioWorklets ├── 1Noise worklet │ ├── basicNoise.html │ └── basicNoise.js ├── 2async await format │ ├── asyncNoise.html │ └── basicnoise.js ├── 3Multiple Inputs │ ├── multipleInputs.html │ └── multipleInputs.js ├── 4PanX │ ├── panX.html │ └── panX.js ├── 5Gain worklet │ ├── gain.html │ └── worklets.js ├── 6Smoothing Filter worklet │ ├── noiseWorklet.js │ ├── smoothing.html │ └── smoothingWorklet.js ├── 7First order filter options │ ├── filterOptions.html │ ├── filterOptionsWorklet.js │ └── noiseWorklet.js ├── 8First order filter messaging │ ├── filterMessaging.html │ ├── filterMessagingWorklet.js │ └── noiseWorklet.js ├── README.md └── index.html ├── 19 Wonders of audio worklets ├── Bit crusher worklet │ ├── bitCrush.html │ └── bitCrushWorklet.js ├── CircularBufferWorklets.js ├── CompressorWorklet │ ├── compressor.html │ ├── compressor.js │ └── compressorWorklet.js ├── KarplusStrong │ ├── KSWorklets.js │ ├── KarplusStrongV2.html │ └── KarplusStrongV2.js ├── PulseWave │ ├── Pulse.html │ └── PulseWorklet.js ├── README.md ├── StereoWidenerWorklet │ ├── Stereo speech.wav │ ├── stereoWidenerNode.html │ └── stereoWidenerWorklet.js └── index.html ├── README.md └── index.html /01 Introducing the Web Audio API/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "pwa-chrome", 9 | "request": "launch", 10 | "name": "Launch Chrome against localhost", 11 | "url": "http://localhost:8080", 12 | "webRoot": "${workspaceFolder}" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /01 Introducing the Web Audio API/HelloWorld/HelloWorld.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /01 Introducing the Web Audio API/HelloWorld/HelloWorld2.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /01 Introducing the Web Audio API/HelloWorld/HelloWorld3.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /01 Introducing the Web Audio API/README.md: -------------------------------------------------------------------------------- 1 | # Introducing the Web Audio API 2 | 3 | 'hello world' application presented as a code example, showing perhaps the simplest use of the Web Audio API to produce and manipulate sound. 4 | 5 | We then extend this application to show alternative approaches to its implementation, coding practices, and how sound is manipulated in an audio graph. 6 | -------------------------------------------------------------------------------- /01 Introducing the Web Audio API/UserInteraction/UserInteraction.html: -------------------------------------------------------------------------------- 1 | 2 |
Gain
3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /01 Introducing the Web Audio API/UserInteraction/UserInteraction.js: -------------------------------------------------------------------------------- 1 | var context = new AudioContext() 2 | var Tone = context.createOscillator() 3 | var Volume = new GainNode(context,{gain:0.1}) 4 | Tone.start() 5 | var Connected = false 6 | Volume.connect(context.destination) 7 | function StartStop() { 8 | if (Connected == false) { 9 | context.resume() 10 | Tone.connect(Volume) 11 | Connected = true 12 | } else { 13 | Connected = false 14 | Tone.disconnect(Volume) 15 | } 16 | } 17 | VolumeSlider.oninput = function() { 18 | VolumeLabel.innerHTML = this.value 19 | Volume.gain.value = this.value 20 | } 21 | -------------------------------------------------------------------------------- /01 Introducing the Web Audio API/index.html: -------------------------------------------------------------------------------- 1 |Frequency
3 | 4 |Gain
5 | 6 |Type
7 | 13 | 14 | -------------------------------------------------------------------------------- /02 Oscillators/OscillatorNode/Oscillator.js: -------------------------------------------------------------------------------- 1 | //Define variables 2 | var context = new AudioContext() 3 | var Tone = new OscillatorNode(context) 4 | var Amplitude = new GainNode(context,{gain: 0.2 }) 5 | 6 | //Set up audio graph 7 | Tone.connect(Amplitude) 8 | Amplitude.connect(context.destination) 9 | Tone.start() 10 | 11 | //User interface callbacks 12 | Frequency.oninput = function() { Tone.frequency.value = this.value } 13 | Volume.oninput = function() { Amplitude.gain.value = this.value } 14 | Type.onchange = function() { Tone.type = this.value } 15 | -------------------------------------------------------------------------------- /02 Oscillators/PeriodicWave/CustomSquareWave.html: -------------------------------------------------------------------------------- 1 | 2 |Frequency
3 | 4 | 16 | -------------------------------------------------------------------------------- /02 Oscillators/PeriodicWave/PulseWave.html: -------------------------------------------------------------------------------- 1 | 2 |Frequency
3 | 4 |Duty Cycle
5 | 6 | 26 | -------------------------------------------------------------------------------- /02 Oscillators/README.md: -------------------------------------------------------------------------------- 1 | # oscillators 2 | 3 | This Chapter focuses on OscillatorNodes. 4 | 5 | - OscillatorNode demonstrates use of the built-in oscillator types and varying the oscillator's frequency 6 | - Detuning shows use of detuning the pitch and how it relates to musical notation. 7 | - There are two examples of creating custom oscillators using the PeriodicWave. 8 | - creating a square wave 9 | - creating a pulse wave, which is like a square wave but with a duty cycle parameter which controls how much of its period it spends near its peak value. 10 | -------------------------------------------------------------------------------- /02 Oscillators/index.html: -------------------------------------------------------------------------------- 1 |Frequency
3 | 4 |Attack
5 | 6 |Decay
7 | 8 | 9 | -------------------------------------------------------------------------------- /05 Parameter automation/Bells/Bells.html: -------------------------------------------------------------------------------- 1 | 2 |Duration
3 | 4 |Pitch
5 | 6 | 7 | -------------------------------------------------------------------------------- /05 Parameter automation/Bells/Bells.js: -------------------------------------------------------------------------------- 1 | var context = new AudioContext() 2 | var DBToAmp = function(db) { return Math.pow(10, db / 20) } 3 | Strike.onclick = function() { 4 | context.resume() 5 | var gNode=[],osc=[],FinalAmp 6 | for (i=0;iDuration
5 | 6 | 7 | -------------------------------------------------------------------------------- /05 Parameter automation/Crossfade/Crossfade.js: -------------------------------------------------------------------------------- 1 | var context = new AudioContext() 2 | var Tone1 = new OscillatorNode(context,{type:'sine',frequency:500}) 3 | var Tone2 = new OscillatorNode(context,{type:'sine',frequency:300}) 4 | var Gain1 = new GainNode(context,{gain:1}) 5 | var Gain2 = new GainNode(context,{gain:0}) 6 | Tone1.start() 7 | Tone2.start() 8 | Tone1.connect(Gain1).connect(context.destination) 9 | Tone2.connect(Gain2).connect(context.destination) 10 | var N=100 11 | var curveUp = new Float32Array(N), curveDown = new Float32Array(N) 12 | for (i=0;iDuration
3 | 4 | 17 | -------------------------------------------------------------------------------- /05 Parameter automation/index.html: -------------------------------------------------------------------------------- 1 |Carrier Frequency
3 | 4 | 5 |Modulation Depth
6 | 7 | 8 |Modulation Frequency
9 | 10 | 11 | 29 | 30 | -------------------------------------------------------------------------------- /06 Connecting audio parameters and modulation/AM Synthesis/AMSynthesis.js: -------------------------------------------------------------------------------- 1 | context = new AudioContext() 2 | var Carrier = new OscillatorNode(context) 3 | var ModulatorOsc = new OscillatorNode(context,{frequency:100,type:'square'}) 4 | var Modulator = context.createGain() 5 | var AM = context.createGain() 6 | Carrier.start() 7 | ModulatorOsc.start() 8 | ModulatorOsc.connect(Modulator) 9 | Modulator.connect(AM.gain) 10 | Carrier.connect(AM) 11 | AM.connect(context.destination) 12 | -------------------------------------------------------------------------------- /06 Connecting audio parameters and modulation/FM Synthesis/FMSynthesis.html: -------------------------------------------------------------------------------- 1 | 2 |Carrier Frequency
3 | 4 | 5 |Modulation Depth
6 | 7 | 8 |Modulation Frequency
9 | 10 | 11 | 30 | 31 | -------------------------------------------------------------------------------- /06 Connecting audio parameters and modulation/FM Synthesis/FMSynthesis.js: -------------------------------------------------------------------------------- 1 | //Define context and nodes 2 | context = new AudioContext() 3 | var Carrier = new OscillatorNode(context,{frequency:CarrierFrequency.value}) 4 | var ModulatorOsc = new OscillatorNode(context,{frequency:ModulationFrequency.value}) 5 | var Modulator = new GainNode(context,{gain:ModulationDepth.value}) 6 | //start any scheduled sources 7 | Carrier.start() 8 | ModulatorOsc.start() 9 | //Modulator is a gain node, so this multiples ModulatorOsc with the modulation depth 10 | ModulatorOsc.connect(Modulator) 11 | //Carrier frequency is the sum of the intrinsic frequency offset and the modulator 12 | Modulator.connect(Carrier.frequency) 13 | Carrier.connect(context.destination) 14 | -------------------------------------------------------------------------------- /06 Connecting audio parameters and modulation/README.md: -------------------------------------------------------------------------------- 1 | # Connecting audio parameters and modulation 2 | 3 | Here, we look at how an audio node’s output can be connected to a parameter of another node. There are two examples. 4 | 5 | - FMSynthesis: shows how FM synthesis is performed by connecting a Low Frequency Oscillator to the frequency parameter of another oscillator. 6 | - AMSynthesis: for implementing AM synthesis by connecting a Low Frequency Oscillator to the gain parameter of a gain node. 7 | -------------------------------------------------------------------------------- /06 Connecting audio parameters and modulation/index.html: -------------------------------------------------------------------------------- 1 |Bit depth
3 |Clipping Threshold
3 | 4 | 20 | -------------------------------------------------------------------------------- /12 Waveshaper/README.md: -------------------------------------------------------------------------------- 1 | # Waveshaper 2 | 3 | - Clipper: This simply clips an audio signal so that all output samples are in the range -1 to +1 4 | - BitCrusher: This quantises samples to be represented with 2^N levels, where N is some number of bits. It reduces the perceived bit depth in a signal. 5 | -------------------------------------------------------------------------------- /12 Waveshaper/index.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
31 |
--------------------------------------------------------------------------------
/14 Reverb/NormalizeIR/NormalizeIR.html:
--------------------------------------------------------------------------------
1 |