marp | theme | paginate |
---|---|---|
true |
default |
true |
TONE.JS!
- A Web Audio framework for web-based applications
- Both for musicians and audio programmers (no execuses!)
- higher-level constructs (e.g. pre-built Synth, Sampler, Sequencer)
- pre-built instruments and effects
- built-in Transport to handle timing (e.g. schedule future events)
- MIDI data support
const audioC = new window.AudioContext
const osc= audioC.createOscillator()
const gainN = audioContext.createGain()
osc.type = 'sine'
osc.frequency.setValueAtTime(261.63, audioC.currentTime)
osc.connect(gainN).connect(audioC.destination);
osc.start()
gainN.gain.setValueAtTime(1, audioC.currentTime)
gainN.gain.exponentialRampToValueAtTime(0.001, audioC.currentTime + 1)
osc.stop(audioContext.currentTime + 1)
const synth = new Tone.Synth().toDestination()
synth.triggerAttackRelease("C4", "8n")
- Get Node.js from https://nodejs.org/en/download/package-manager
- Go to terminal:
npm install tone
or
- Use Content Delivery Network to import tone.js directly in html: For example: https://cdnjs.cloudflare.com/ajax/libs/tone/14.8.49/Tone.js
https://tonejs.github.io/docs/15.0.4/index.html
Relationship between the AudioContext time and the Transport's time here: https://github.com/Tonejs/Tone.js/wiki/TransportTime