aubio / aubio

a library for audio and music analysis
https://aubio.org
GNU General Public License v3.0
3.31k stars 382 forks source link

pitch detection on 16 bit PCM #69

Closed giffy1 closed 8 years ago

giffy1 commented 8 years ago

The pitch detection sample worked perfectly fine on a .wav file. Now I want to detect pitch on 16-bit PCM audio sent from an Android phone. The data arrives in the Python script as an integer array, but aubio is expecting 32-bit floats. I can put it in the right format, i.e. np.float32(data), which stops the exception but gives me nonsense results. How should I approach this? I've looked for ways to convert the data into .wav format but nothing that doesn't involve file IO.

EDIT: Tried the solution at https://github.com/aubio/aubio/issues/36, but this didn't work.

giffy1 commented 8 years ago

I got it working - I was not windowing the data correctly.

piem commented 8 years ago

hi @giffy1

great to know you got it working. Some things to check:

For instance:

samples = (numpy.arange(100)/32768.).astype(aubio.float_type)

best, Paul