Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

My contribution #2

@julodnik

Description

@julodnik

Hello,

thanks for your work. I wanted to contribute something back.
Instead of slice, which is very slow for big arrays, use following code to make seeking much faster:

` this.bufferOffset = startBufferAtIndex;

    // not sure if this is the right place //$$
    this.t = new RateTransposer(true);
    this.s = new Stretch(true);
    this.samples = new Float32Array(this.scriptBufferSize * 2);
    this.s.tempo = this.slowDownPlaybackRate;
    this.sourcez = {
        extract: function (target, numFrames, position) {
            if (my.l.length == 0) {
                // reset
                my.l = my.buffer.getChannelData(0);
                if (my.buffer.numberOfChannels == 2) {
                    my.r = my.buffer.getChannelData(1);
                } else {
                    my.r = my.l;
                }
            }
            for (var i = 0; i < numFrames; i++) {
                target[i * 2] = my.l[i + position + my.bufferOffset];
                target[i * 2 + 1] = my.r[i + position + my.bufferOffset];
            }
            return Math.min(numFrames, my.l.length - position);
        }
    };
    this.f = new SimpleFilter(this.sourcez, this.s); // need to be var f?

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions