user1087179
user1087179

Reputation: 25

Web Audio Api Record audio node

Can I somehow record and output to WAV with trackPosition, offset. it works fine when played in browser works fine I just wanna output is to WAV file.

for (var i = 0; i <= loop; ++i) {
    node = that.context.createBufferSource();
    that.nodes.push(node);
    node.buffer = clip.get('buffer');
    node.connect(gainNode);  

    // clip offset and duration times
    if (loop > 0) {
        if (i === 0) {           // first subclip
            offset = startTime;
            duration = duration - offset;
        } else if (i === loop) { // last subclip
            offset = 0;
            duration = endTime;
        } else {
            offset = 0;
            duration = clip.get('buffer').duration;
        }
    } else {    // loop === 0
        offset = startTime;
        if (inClipStart)
            duration = endTime - startTime;
        else
            duration = clip.clipLength();
    }

    // sets the clip's playback start time
    node.start(
        currentTime + trackPosition - cursor,
        offset,
        duration
    );



    trackPosition += duration;
}

Upvotes: 1

Views: 445

Answers (1)

Oskar Eriksson
Oskar Eriksson

Reputation: 2641

Check out https://github.com/mattdiamond/Recorderjs - it let's you record/save the output of your Web Audio app as a .wav, which sound like what you're looking for!

Upvotes: 0

Related Questions