-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Description
Hi All,
I am using the following code to generate my data from an audio file.
window.AudioContext = window.AudioContext || window.webkitAudioContext;
const audioContext = new AudioContext();
const drawAudio = url => {
fetch(url)
.then(response => response.arrayBuffer())
.then(arrayBuffer => audioContext.decodeAudioData(arrayBuffer))
.then(audioBuffer => filterData(audioBuffer));
};
const filterData = audioBuffer => {
const rawData = audioBuffer.getChannelData(0);
console.log(rawData);
};
drawAudio('https://983yqbz442.s3.amazonaws.com/andyc.mp3');
I am trying to get the same data from a local file with the Node js library like this.
const fs = require('fs');
const AudioContext = require('web-audio-api').AudioContext;
const audioContext = new AudioContext;
let resp = fs.readFileSync('./samples/andyc.mp3');
audioContext.decodeAudioData(resp, buffer => {
console.log(buffer);
});
But I get 2 different results.
If you look at the web api it produces.
You can check the console.log here https://output.jsbin.com/haloneb/1
first 4 values of array
0: 0.0031128879636526108
1: 0.0052797021344304085
2: -0.000030517578125
3: 0.0016174810007214546
But the Node js one produces this first 4 values of array
0: 0
1: 0
2: 0
3: 0
Am i missing something?
revulvgina
Metadata
Metadata
Assignees
Labels
No labels