Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.24k stars 963 forks source link

Grain Player Echo with Playback Rate #1259

Closed Grimlek closed 2 weeks ago

Grimlek commented 2 weeks ago

Describe the bug

Echo with Playback Rate when using the Grain Player.

Note: Browsers' Chrome Latest Version (haven't tested other browsers)

To Reproduce

<button id="playPauseBtn">Play</button>

<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://unpkg.com/tone"></script>
<script type="text/javascript">
    $(function() {
        let player = new Tone.GrainPlayer("myStereoWaveFile.wav").toDestination();

        player.playbackRate = 0.5;
        player.sync().start(0);

        $("#playPauseBtn").on("click", function() {
            let $target = $(this);

            if ($target.text() === "Play") {
                $target.text("Pause");
                Tone.getTransport().start();
            }
            else {
                $target.text("Play");
                Tone.getTransport().pause();
            }
        });
    });
</script>

Sample stereo wav file for testing

Expected behavior Playback rate increase or decrease without an echo with the ability to control the pitch individually.

What I've tried I tried playing around with the grain player settings for grainSize, overlap, and/or detune but nothing worked. I tested this with stereo and mono wav files, did not make a difference.

Additional Notes This could be ignorance on my part and just being new to Tone.js.

We are using Tone.js for a custom web audio player with various use cases and wavesurfer js for the spectrograph only. Playback rate and pitch is the last thing that we need to develop. Silence detection was fun, maybe something to include in tone js?