peterkhayes / pitchfinder

A compilation of pitch detection algorithms for Javascript.
436 stars 53 forks source link

Which format and size does the Float32Array has to have for good detecetion ? #45

Open hamza-eljaouhari opened 3 years ago

hamza-eljaouhari commented 3 years ago

Hello,

I have tried the package by sending captured streams of audio from the browser to a socket.io server trying to execute the algorithms to detect pitches and compare them with a table of musical frequencies.

I have tried all 3 of the algorithms but the result is always null.

const a = Pitchfinder.AMDF(); const b = Pitchfinder.YIN(); const c = Pitchfinder.DynamicWavelet(); console.log([a(float32Array), b(float32Array), c(float32Array)]);

I'm also streaming a Float32Array with the size of 1024.

All I receive is :

[null, null, null]

Thank you

peterkhayes commented 3 years ago

I wonder if your Float32Arrays are long enough to get a good pitch reading? 1024 samples is around 0.02 seconds.

RemyNtshaykolo commented 2 years ago

Hi I struggled also to make it work but here are my setting.

const options: Options = {
  sampleRate: 44100
  channels: 1
  bitsPerSample: 8
  audioSource: 6
  bufferSize: 1024
  wavFile: '',
};

const detectPitch = YIN({sampleRate: 44100});

I tried 32,16 bitsPerSample but the YIN was only returning null values with 8 bits it work perfectly fine