Introdução ao áudio da web
Sintetizando áudio
Usando efeitos no áudio
Gravando áudio de uma fonte de microfone
Reproduzindo áudio
Alteração em tempo real de duas fontes de áudio
Configurar
Começamos criando um contexto de áudio e depois criamos um oscilador que é a maneira mais fácil de verificar se sua configuração funciona. (Exemplo de violino)
// We can either use the standard AudioContext or the webkitAudioContext (Safari)
var audioContext = (window.AudioContext || window.webkitAudioContext);
// We create a context from which we will create all web audio nodes
var context = new audioContext();
// Create an oscillator and make some noise
var osc = context.createOscillator();
// set a frequecy, in this case 440Hz which is an A note
osc.frequency.value = 440;
// connect the oscillator to the context destination (which routes to your speakers)
osc.connect(context.destination);
// start the sound right away
osc.start(context.currentTime);
// stop the sound in a second
osc.stop(context.currentTime + 1);