Skip to content

Instantly share code, notes, and snippets.

@raphaelrk
Created October 29, 2015 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raphaelrk/9c79f66c1edccd0812c7 to your computer and use it in GitHub Desktop.
Save raphaelrk/9c79f66c1edccd0812c7 to your computer and use it in GitHub Desktop.
talked about javascript, functions/passing functions, objects, classes, async/callbacks
audio as a pipeline
source is audio data generater or loaded
oscillator, mp3, mic
destination is output
laptop speakers, ScriptProcessorNode
context = new AudioContext()
context.currentTime
context.destination
script processer more complicated, to be talked about later
Web MIDI API to e.g. use keyboard information
osc = context.createOscillator() // generates a tone
gain = context.createGain() // sets volume
buf = context.CreateBuffer() // in-memory audio data
bfil = context.CreateBiquadFilter() // simple low-pass filter (remove bass)
context.destination // audio destination
etc.., use console
join pieces of pipeline (nodes) with the connect method
Common pipeline:
Source -> Dest
2nd most common
Source -> GainNode -> Dest
context = new AudioContext()
osc = c.createOscillator()
osc.frequency.value = 440
osc.connect(c.destination)
osc.start(0)
osc.stop()
use xhr for mic
filters choose parts of freq spectrum
filters can be used for certain noise types
AudioPannerNode mixing to change pan (L/R)
Crossfading
context = new AudioContext()
osc = c.createOscillator()
gain = context.createGain()
osc.frequency.value = 440
osc.connect(gain)
gain.gain.value = 0.6
buffer-loader library
play song
bufferLoad = new BufferLoader(
context,
[
'../song.mp3'
],
finishedLoading
);
bufferLoader.load()
func stop song
context.createBufferSource
source.buffer = bufferList[0]
source.connext(context.destination);
source.start(0);
hughzabriskie.com/sequencer // can probs copy his js code there
add piano(g4) on 1 2 // midi notes
d generator(piano, Amaj something)
add piano(b2,e3,gs3) on 1 // three notes on b3
add dry-kick someth
add ride-2 every 16th gain(0.6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment