question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Web Audio - AudioBuffer playbackRate setValueAtTime

See original GitHub issue

Looks like the native audio is missing the playbackRate AudioParam property on the AudioBuffer source. It is used internally by THREE.Audio for starting playback and also setting the playback rate.

Here’s a repro: node . https://seemly-decimal.glitch.me/ I did override the play method in THREE.Audio as a work around and removed the playbackRate line and it worked just fine which means this could just be an empty stub if we dont want implement playback rate right now.

THREE.Audio.prototype.play = function () {
    if ( this.isPlaying === true ) {
        console.warn( 'THREE.Audio: Audio is already playing.' );
        return;
    }
    if ( this.hasPlaybackControl === false ) {
        console.warn( 'THREE.Audio: this Audio has no playback control.' );
        return;
    }
    var source = this.context.createBufferSource();
    source.buffer = this.buffer;
    source.loop = this.loop;
    source.onended = this.onEnded.bind( this );

    //- commented out this line source.playbackRate.setValueAtTime( this.playbackRate, this.startTime );

    this.startTime = this.context.currentTime;
    source.start( this.startTime, this.offset );
    this.isPlaying = true;
    this.source = source;
    return this.connect();
}

More Info: https://github.com/mrdoob/three.js/blob/master/src/audio/Audio.js#L101

https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/playbackRate

TypeError: Cannot read property 'setValueAtTime' of undefined
    at PositionalAudio.play (https://aframe.io/releases/0.8.0/aframe.js:43857:24)
    at https://aframe.io/releases/0.8.0/aframe.js:70936:15
    at Array.forEach (<anonymous>)
    at NewComponent.playSound (https://aframe.io/releases/0.8.0/aframe.js:70934:24)
    at NewComponent.bound [as playSound] (https://aframe.io/releases/0.8.0/aframe.js:79999:17)
    at https://aframe.io/releases/0.8.0/aframe.js:70825:57
    at https://aframe.io/releases/0.8.0/aframe.js:43443:6
    at process.nextTick (C:\workspace\TheExpanse1\exokit\src\core.js:1920:17)
    at process._tickCallback (internal/process/next_tick.js:61:11)

On a separate positive note, the current audio is broken in aframe and three.js in that is is quite choppy or distorted or something, however this only affects the main stream browsers as the audio is perfectly smooth in exokit! Yay!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
avaercommented, Dec 29, 2018

Apparently LabSound supports this; it’s just not bound from the Exokit side.

0reactions
avaercommented, May 4, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

AudioBufferSourceNode.playbackRate - Web APIs | MDN
The playbackRate property of the AudioBufferSourceNode interface Is a k-rate AudioParam that defines the speed at which the audio asset will ...
Read more >
2. Perfect Timing and Latency - Web Audio API [Book] - O'Reilly
By having this AudioBuffer around, you have a clean separation between buffer and player, and can easily play back multiple versions of the...
Read more >
Web Audio API - W3C
An AnalyserNode interface, an AudioNode for use with music visualizers, or other visualization applications. An AudioBuffer interface, for ...
Read more >
LayoutTests/webaudio - experimental/chromium/blink - Git at Google
webaudio. tree: fc53f311eb32b6524194b7e6ffb29d0d14f66cd5 [path history] [tgz]. codec-tests/ · resources/ · audiobuffer-copy-channel-expected.txt ...
Read more >
How do you schedule a fade-out using setTargetAtTime
playbackRate -fadeDurationInSeconds, fadeDurationInSeconds); source.start(when, offset, duration);. scheduled-tasks · web-audio-api · pitch.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found