I am using Python 2.7.12 on Ubuntu 16.04 LTS while I am trying (learning) about the pyaudio module. I have to mention which type of format I should require for recording the audio from a microphone. I would like to know difference between
papaInt32,paInt16,paInt24,paFloat32,paInt8,paUInt8
and when to use each format. I am trying (learning) pyaudio from Python pyaudio.PyAudio Examples.
PortAudio supports audio input and output in a variety of sample formats: 8, 16, 24 and 32 bit integer formats and 32 bit floating point, irrespective of the formats supported by the native audio API.
A type used to specify one or more sample formats. Each value indicates a possible format for sound data passed to and from the stream callback, Pa_ReadStream and Pa_WriteStream.
Reference
The standard formats paFloat32, paInt16, paInt32, paInt24, paInt8 and aUInt8 are usually implemented by all implementations.
The floating point representation (paFloat32) uses +1.0 and -1.0 as the maximum and minimum respectively.
paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
The paNonInterleaved flag indicates that audio data is passed as an array of pointers to separate buffers, one buffer for each channel. Usually, when this flag is not used, audio data is passed as a single buffer with all channels interleaved.
Reference
If you are using Float32, then code should be fine. If you are using paInt32 (or 24/16/8), then you need to make sure to cast back to an int (or a short, char, etc) after you do the multiplication
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With