In order to solve the "data race" issue in WebAudio (bug 22725), this proposal restricts access to the internal PCM data of an AudioBuffer. This does not require AudioBuffers to be immutable, but that modifying their contents occurs through an API which enforces no-data-race semantics.
Since this will involve breaking API changes, this proposal incorporates suggestions from Issue 48 to simplify the AudioBuffer interface, and will also adopt a constructor, as opposed to a factory method.
The new constructor provides an upgrade path for existing pages while not breaking those pages. The factory method can continue to create the "legacy" AudioBuffer in prefixed implementations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fallbacks = {} | |
, networks = {} | |
, cacheName = "OldSchoolAppCache" | |
; | |
this.onmessage = function (e) { | |
var msg = e.data; | |
if (msg.type && msg.type === "manifest") { | |
var lines = msg.manifest.split(/\n+/) | |
, mode = "cache" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Takes string of Note + Octave | |
// Example: | |
// var frequency = getFrequency('C3'); | |
var getFrequency = function (note) { | |
var notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'], | |
octave, | |
keyNumber; | |
if (note.length === 3) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html, body { | |
background-color: black; | |
width: 100%; | |
height: 100%; | |
margin: 0; | |
} | |
canvas { | |
display: block; | |
margin: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example usage, a MIDI proxy that picks the first available MIDI input and routes its messages to the first MIDI outputs | |
navigator.getUserMedia({midi: true}, function (MIDIAccess) { | |
try { | |
var input = MIDIAccess.getInput(MIDIAccess.enumerateInputs()[0]); | |
var output = MIDIAccess.getOutput(MIDIAccess.enumerateInputs()[0]); | |
} catch (e) { | |
console.error("Couldn't find suitable MIDI devices"); | |
} |