Skip to content

decodeAudioData throws decoded data as error #73

Open
@mxkrn

Description

@mxkrn

So I found some very strange error behaviour when using an async version of AudioContext.decodeAudioData. When using the function as designed with a regular callback, I can access and log the decoded data just fine, however I need to return this data so I want to store in a variable so I can use await. So I turned encapsulating the function in a Promise using promisify, here's my code:

async function readAudioFileAsync(fpath) {
    ctx = new AudioContext();
    decodeAudioDataAsync = util.promisify(ctx.decodeAudioData);
    arrayBuffer = await fsp.readFile(fpath);
    audio = await decodeAudioDataAsync(arrayBuffer)
        .then((audio) => {
		return audio;
	})
	.catch((err) => {throw err;});
    return audio;
}

When I call this, the error is thrown, but the error isn't actually an error, the entire decoded data is logged to the console as the error! I saved both the console.log output and the error log in text files and confirm that both are identical. After that, I also tried bluebird with the same result.

All-in-all this seems incredibly strange, anyone got any insight into what's happening here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions