Reputation: 408
I am working with audio and trying to visualize audio data. I have no issue with doing it in the browser thanks to the Web Audio API. There is AnalyserNode.getByteFrequencyData
on the Web Audio API that returns an array of values that range from 0-255, how can I produce the same values in node.js?
I have loaded an .mp3
audio file and got the channelData.
var load = require('audio-loader')
load(fileName).then(
function(buf) {
const channelData = buf.getChannelData(0);
}
)
How can I get the same AnalyserNode.getByteFrequencyData
values from audioBuffer
and channelData
in node.js?
Upvotes: 0
Views: 441
Reputation: 9066
There is no exact equivalent for getByteFrequencyData()
on Node.js but I think using Meyda should get you reasonably close.
They have a guide on their homepage which shows the usage with Node.js: https://meyda.js.org/guides/offline-node
You could use the PowerSpectrum
feature extractor to get similar data as with getByteFrequencyData()
.
const Meyda = require('meyda');
Meyda.extract('powerSpectrum', channelData);
Upvotes: 1