Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is paInt16 in pyaudio module?

While taking input from the microphone in Python I saw

FORMAT = pyaudio.paInt16

I want to know what it means

like image 803
Curran-C Avatar asked Nov 01 '25 03:11

Curran-C


1 Answers

Sound is stored in binary, as is everything related to computers. In order to know where an integer starts and ends, there are different methods used. PyAudio (and I believe most encodings, too) uses a fixed size of bits.

paInt16 is basically a signed 16-bit binary string. 15 bits for the number, and one for the sign, leaving your range options to be (-32768, 32767) if I'm not completely mistaken. 2^15, anyway.

Take a look at this C explanation on data types, as while not strictly Python, it's related to your question: https://www.tutorialspoint.com/cprogramming/c_data_types.htm

like image 148
mazunki Avatar answered Nov 02 '25 23:11

mazunki