[Webkit-unassigned] [Bug 57676] Add support for offline audio rendering to AudioContext API

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Apr 1 16:27:47 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=57676





--- Comment #3 from Chris Rogers <crogers at google.com>  2011-04-01 16:27:47 PST ---
This adds a new constructor to AudioContext for offline rendering into an AudioBuffer.  Offline rendering will be an important part of the audio layout test system.  It will also have some other interesting applications.

This is an early version of the patch for initial review.  It's still incomplete, since a few new files have been added but not all of the necessary makefiles have yet been updated.

A few notes:

* I've re-factored AudioDestinationNode to now be a base class, with the existing default implementation (talking to audio hardware) being hoisted up into DefaultAudioDestinationNode.  There's also a new sub-class OfflineAudioDestinationNode where most of the interesting new offline stuff happens.

* I've currently kept the AudioContext implementation for both default (talking to audio hardware) and offline processing in the same AudioContext class.  An alternative would be to also subclass AudioContext in a similar way to AudioDestinationNode (as explained above).

* JSAudioContextCustom.cpp also needs similar changes to V8AudioContextCustom.cpp but I haven't done that yet.

* This has been minimally tested and works with a simple test case.  It's pretty remarkable to see how much faster than real-time the offline context can render.  I think the audio layout tests should mostly be able to run very quickly.

* Here's part of a simple test case I used which shows what this looks like in JavaScript:


function playNote(context, time) {
    var source = context.createBufferSource();

    source.buffer = hihatShort;
    source.connect(context.destination);

    source.noteOn(time);
}

// Gets called when resource loading has finished.
function startOfflineProcessing() {
    offlineContext = new webkitAudioContext(2, 2 * 44100, 44100);

    offlineContext.oncomplete = function(event) {
      var source = context.createBufferSource();
      source.buffer = event.renderedBuffer;
      source.connect(context.destination);
      source.noteOn(0);
    };

    playNote(offlineContext, 0.0);
    playNote(offlineContext, 0.5);
    playNote(offlineContext, 0.75);
    playNote(offlineContext, 1.25);
    playNote(offlineContext, 1.5);
    playNote(offlineContext, 1.6);
    playNote(offlineContext, 1.8);

    offlineContext.startRendering();    
}

function init() {    
    context = new webkitAudioContext();
    loadHihat("sounds/drum-samples/hihat-short.wav");
}

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list