impulse-response

0.0.3 • Public • Published

impulse-response

Uses WebAudio to measure the impulse response of a system, e.g. to model the reverb of a room.

PRs welcome.

Install

npm install impulse-response --save

Example

import { measureImpulseResponse, downloadWav } from 'impulse-response';
 
var audioContext = new AudioContext();
 
function getMic(cb) {
    navigator.getUserMedia(
        { audio: {  optional: [
            {googEchoCancellation: false},
            {googNoiseSuppression: false}, 
            {googHighpassFilter: false}  
        ] } },
        function (stream) {
            cb(audioContext.createMediaStreamSource(stream));
        }
    );    
}
 
getMic(function (micAudioNode) {
    measureImpulseResponse(micAudioNode, audioContext.destination, {
        sineSweepLengthSecs: 5.0,
        startFreq: 60.0,
        endFreq: 16000.0,
        impulseResponseLengthSecs: 1.0        
    }).then(function (impulseResponseWAV, buffers) {
        console.log("impulseResponseWAV is a binary blob: ", impulseResponseWAV);
        
        // Lets have the browser download the blob as ir.wav
        downloadWav(impulseResponseWAV, "ir.wav");
        
        // Or we could apply it to a ConvolverNode to synthesize this room's reverb
        var irAudioBuffer = buffers.irBuffer;
        var convolverNode = audioContext.createConvolver();
        convolverNode.buffer = irAudioBuffer;
        
        // ... now do something with the convolver node...
    });
});
 

License

MIT, see LICENSE.md

Readme

Keywords

none

Package Sidebar

Install

npm i impulse-response

Weekly Downloads

1

Version

0.0.3

License

MIT

Last publish

Collaborators

  • snickell