Record sound

From Rosetta Code
Revision as of 01:35, 30 December 2010 by 201.67.232.39 (talk) (Created page with "{{task}} Record sound (mono 16-bit PCM) into an integer array. =={{header|Python}}== <lang python>import pyaudio chunk = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = 4410...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Record sound
You are encouraged to solve this task according to the task description, using any language you may know.

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

Python

<lang python>import pyaudio

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

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>