简体   繁体   中英

What do data in pyaudio stream mean?

I use pyaudio library to read sound from audiocard. I use the following code

stream = pyaudio.PyAudio().open(format=pyaudio.paInt16, channels=2,
                                rate=44100, input=True,
                                frames_per_buffer=1024)

CHUNK = 1024
frames = []
for i in range(0, int(44100 / 1024 * seconds)):
    data = stream.read(CHUNK)
    frames.append(data)

I want to know what is one frame, what is one chunk and what is their format. It seems like there's no such info in the library description.

For anybody hopping in later:

A sample is a single float32 value that represents the value of the audio stream at each specific point in time, in a specific channel (left or right, if in the case of stereo).

A frame , is the set of all values for all channels that will play at a specific point in time.

Taken from : Mozilla webaudio description

Format: paInt16 is a format to store those sample data as a 16-bit integer value.

DATA: It is the number of frames specified by CHUNK value you are taking at one time from the stream. Think of stream as collection of frames.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM