On 20 June 2010 23:52, Joe Veldhuis <electrob...@gmail.com> wrote: > Hello all. I'm writing a program that needs to capture audio from a > soundcard and run FFTs to determine peak frequency for further processing. > The soundcard's native capture format is 16-bit little-endian signed integer > samples (values 0-65535), and of course the FFT function requires > floating-point values (-1.0 - +1.0). > > So, what is the most efficient way to do the necessary conversion? I'm > using the pyalsaaudio module to access the soundcard, if it matters. > > -Joe Veldhuis >
Not sure it's the best way but the most obvious to me would be divide by 32767.5 (ie half 65535) and minus 1 puts you into the right range: >>> 65535/32767.5-1 1.0
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor