Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
Superpowered loop or loopBetween not working as expected

I've modified the JS timestretch example to loop, but am not getting any audio out with loop() or loopBetween(). player.play() plays the whole file. I can force it by polling getPositionMs and setPosition in the process loop, but that's a hack. What should I be doing? Thanks.

class MyProcessor extends SuperpoweredWebAudio.AudioWorkletProcessor {
    // runs after the constructor
    onReady() {
        this.player = new this.Superpowered.AdvancedAudioPlayer(this.samplerate, 2, 2, 0, 0.501, 2, false);
        SuperpoweredTrackLoader.downloadAndDecode('../123456.mp3', this);
    }

    onMessageFromMainScope(message) {
        if (message.SuperpoweredLoaded) {
            this.player.openMemory(this.Superpowered.arrayBufferToWASM(message.SuperpoweredLoaded.buffer), false, false);
            this.player.loopBetween (   
                1000.0, //double    startMs,
                3000.0, // double   endMs,
                true, // bool   jumpToStartMs,
                255, //unsigned char    pointID,
                false); //bool  synchronisedStart

            this.player.play();
            this.sendMessageToMainScope({ loaded: true });
        }

        if (typeof message.rate !== 'undefined') this.player.playbackRate = message.rate / 10000.0;
        if (typeof message.pitchShift !== 'undefined') this.player.pitchShiftCents = parseInt(message.pitchShift) * 100;
    }

    processAudio(inputBuffer, outputBuffer, buffersize, parameters) {
        if (!this.player.processStereo(outputBuffer.pointer, false, buffersize, 1)) {
            for (let n = 0; n < buffersize * 2; n++) outputBuffer.array[n] = 0;
        };
        if (this.player.getPositionMs() > 3000) {
            this.player.setPosition(1000.0, false, false);

        }
    }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!