最終更新:2013-03-08 (金) 00:05:13 (4039d)
AudioBuffer
Top / AudioBuffer
https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AudioBuffer
The Web Audio API uses an AudioBuffer for short- to medium-length sounds. The basic approach is to use XMLHttpRequest for fetching sound files.
インターフェイス
interface AudioBuffer { readonly attribute float sampleRate; readonly attribute long length; // in seconds readonly attribute double duration; readonly attribute long numberOfChannels; Float32Array getChannelData(unsigned long channel); };
例
var soundBuffer = null; var context = new webkitAudioContext(); function loadDogSound(url) { var request = new XMLHttpRequest(); request.open('GET', url, true); request.responseType = 'arraybuffer'; // Decode asynchronously request.onload = function() { context.decodeAudioData(request.response, function(buffer) { soundBuffer = buffer; }, onError); } request.send(); }
関連
- The audio file data is binary (not text), so we set the XMLHttpRequest.responseType? of the request to 'arraybuffer'.
- ArrayBuffer
- Float32Array