Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
frameType: 'signal',
sourceSampleRate: sampleRate,
});
suite.add(`lfo:rms\t\tframeSize: ${frameSize}\t`, {
fn: function() {
for (let i = 0; i < numFrames; i++) {
const start = i * frameSize;
const end = start + frameSize;
const frame = buffer.subarray(start, end);
const res = rms.inputSignal(frame);
}
},
});
Meyda.bufferSize = frameSize;
Meyda.sampleRate = sampleRate;
// #todo - windowing function should be 'rect' to skip windowing...
// https://github.com/meyda/meyda/blob/master/src/utilities.js#L27
suite.add(`meyda:rms\tframeSize: ${frameSize}\t`, {
fn: function() {
for (let i = 0; i < numFrames; i++) {
const start = i * frameSize;
const end = start + frameSize;
const frame = buffer.subarray(start, end);
const res = Meyda.extract('rms', frame);
}
},
});
suite.on('cycle', function(event) {
frameType: 'signal',
sourceSampleRate: sampleRate,
});
suite.add(`lfo:mfcc\tframeSize: ${frameSize}\t`, {
fn: function() {
for (let i = 0; i < numFrames; i++) {
const start = i * frameSize;
const end = start + frameSize;
const frame = buffer.subarray(start, end);
const res = mfcc.inputSignal(frame);
}
},
});
Meyda.bufferSize = frameSize;
Meyda.sampleRate = sampleRate;
suite.add(`meyda:mfcc\tframeSize: ${frameSize}\t`, {
fn: function() {
for (let i = 0; i < numFrames; i++) {
const start = i * frameSize;
const end = start + frameSize;
const frame = buffer.subarray(start, end);
const res = Meyda.extract('mfcc', frame);
}
},
});
suite.on('cycle', function(event) {
log.push(String(event.target));
});
export const extractFeatures = (signal, sampleRate) => {
const frames = signalToFrames(signal, sampleRate, {});
Meyda.bufferSize = 512;
const mfcc = frames
.map(frame => Meyda.extract('mfcc', frame));
Meyda.bufferSize = 2048;
const f0 = frames
.map(frame => Meyda.extract('amplitudeSpectrum', frame))
.map(binsPerFrame => getF0(binsPerFrame, sampleRate, humanVoiceRange));
return {mfcc: vAvg(mfcc), f0: avg(f0)};
};
frameType: 'signal',
sourceSampleRate: sampleRate,
});
suite.add(`lfo:fft\t\tframeSize: ${frameSize}\t`, {
fn: function() {
for (let i = 0; i < numFrames; i++) {
const start = i * frameSize;
const end = start + frameSize;
const frame = buffer.subarray(start, end);
const res = fft.inputSignal(frame);
}
},
});
Meyda.bufferSize = frameSize;
Meyda.sampleRate = sampleRate;
suite.add(`meyda:fft\tframeSize: ${frameSize}\t`, {
fn: function() {
for (let i = 0; i < numFrames; i++) {
const start = i * frameSize;
const end = start + frameSize;
const frame = buffer.subarray(start, end);
const res = Meyda.extract('amplitudeSpectrum', frame);
}
},
});
suite.on('cycle', function(event) {
log.push(String(event.target));
});
analyser.getAudioFeatures = () => {
analyser.getByteFrequencyData(freqDataArray);
analyser.getFloatTimeDomainData(timeDataFloatArray);
const frequencyData = Array.from(freqDataArray);
Meyda.fftSize = fftSize;
Meyda.bufferSize = fftSize;
const {mfcc, spectralCentroid, rms, loudness} = Meyda.extract([
'mfcc',
'spectralCentroid',
'rms',
'loudness',
],
timeDataFloatArray
);
return {frequencyData, rms, mfcc, spectralCentroid, loudness: loudness.total};
};
return analyser;