Record sound

From Rosetta Code
Revision as of 01:41, 30 December 2010 by rosettacode>Mwn3d (Taking down to draft)
Record sound is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Record sound (mono 16-bit PCM) into an integer array.

Python

<lang python>import pyaudio

chunk = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = 44100

p = pyaudio.PyAudio()

stream = p.open(format = FORMAT,

               channels = CHANNELS,
               rate = RATE,
               input = True,
               frames_per_buffer = chunk)

data = stream.read(chunk) print [ord(i) for i in data]</lang>