Open Bug 1655336 Opened 4 years ago Updated 1 year ago

AudioBufferSourceNode outputs silence when AudioBuffer.copyToChannel(content) is called after ABSN.buffer = buffer and before ABSN.start() is called

Categories

(Core :: Web Audio, defect, P3)

80 Branch
defect

Tracking

()

People

(Reporter: guest271314, Assigned: padenot)

References

(Blocks 1 open bug)

Details

(Keywords: parity-chrome)

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Linux i686; rv:80.0) Gecko/20100101 Firefox/80.0

Steps to reproduce:

Create N files of length 512 containing raw PCM s16le 2ch 44100Hz.

Upload files using <input type="file" multiple>

Convert file to Float32Array

Set Float#2Array to AudioBuffer using copyToChannel() or getChannelData(index).set()

start() AudioBufferSourceNode

Actual results:

No audio is output.

Expected results:

Audio should be output.

Chromium 86 outputs audio for copyToChannel() and getChannelData(index).set().

There is no guarantee the FileList from <input type="file"> will be sorted numerically. To eliminate the possibility of the files being set as Float32Arrays in reverse or arbitrary order tested sorting the FileList or converting FileList to Array then sorting which does not output audio either.

The audio does play using AudioWorkletProcessor.

The problem appears to be that

AudioBuffer.copytoChannel(Float32Array, 0)

is executed after

AudioBufferSourceNode.buffer = AudioBuffer

Per the specification should not the "acquire the contents of an AudioBuffer operation" algorithm take place only when start() is called, at which time copyToChannel() has already been called and start() has not previously been called?

  • When AudioBufferSourceNode.start is called, it acquires the contents of the node’s buffer. If the operation fails, nothing is played.
  • When the buffer of an AudioBufferSourceNode is set and AudioBufferSourceNode.start has been previously called, the setter acquires the content of the AudioBuffer. If the operation fails, nothing is played.

Specification issue https://github.com/WebAudio/web-audio-api/issues/2227

Just happened to come across this issue while creating a workaround for an issue with a different API. Am not sure if Nightly behaviour is correct or not per the specification because the specification is not clear from perspective here.

Per the Web Audio API specification should content from copyToChannel() be output with this code

        buffer.copyToChannel(result[0], 0, 0);
        buffer.copyToChannel(result[1], 1, 0);
        console.log(result[0].every((f, i) => f === buffer.getChannelData(0)[i]), result[1].every((f, i) => f === buffer.getChannelData(1)[i]));
        source.buffer = buffer;

and conversely not with this code

        source.buffer = buffer;
        buffer.copyToChannel(result[0], 0, 0);
        buffer.copyToChannel(result[1], 1, 0);
        console.log(result[0].every((f, i) => f === buffer.getChannelData(0)[i]), result[1].every((f, i) => f === buffer.getChannelData(1)[i]));

?

Summary: AudioBufferSourceNode does not output audio → AudioBufferSourceNode outputs silence when buffer.copyToChannel() is called after source.buffer = buffer and before start() is called
Summary: AudioBufferSourceNode outputs silence when buffer.copyToChannel() is called after source.buffer = buffer and before start() is called → AudioBufferSourceNode outputs silence when AudioBuffer.copyToChannel(content) is called after ABSN.buffer = buffer and before ABSN.start() is called

Hi reporter,

Thanks for the details, I will move this over to a component so developers can take a look over it. If is not the correct component please feel free to change it to an appropriate one.

Thanks for the report.

Clara

Component: Untriaged → Web Audio
Product: Firefox → Core
Severity: -- → S3
Keywords: parity-chrome
Priority: -- → P3
Assignee: nobody → padenot
Status: UNCONFIRMED → NEW
Ever confirmed: true

Just saw the "parity-chrome" keyword. FYI, Chrome hasn't implemented the section about acquiring the contents for an AudioBufferSourceNode.

Blocks: 1796782
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: