Module pyaudio :: Class Stream
[show private | hide private]
[frames | no frames]

Class Stream


PortAudio Stream Wrapper. Use PyAudio.open to make a new Stream.


Method Summary
    Opening and Closing
  __init__(self, PA_manager, rate, channels, format, input, output, input_device_index, output_device_index, frames_per_buffer, start)
Initialize a stream; this should be called by PyAudio.open.
  close(self)
Close the stream
    Stream Info

float

get_input_latency(self)
Return the input latency.

float

get_output_latency(self)
Return the input latency.

float

get_time(self)
Return stream time.

float

get_cpu_load(self)
Return the CPU load.
    Stream Management
  start_stream(self)
Start the stream.
  stop_stream(self)
Stop the stream.

bool

is_active(self)
Returns whether the stream is active.

bool

is_stopped(self)
Returns whether the stream is stopped.
    Input Output

None

write(self, frames, num_frames, exception_on_underflow)
Write samples to the stream.

str

read(self, num_frames)
Read samples from the stream.

int

get_read_available(self)
Return the number of frames that can be read without waiting.

int

get_write_available(self)
Return the number of frames that can be written without waiting.

Method Details

__init__(self, PA_manager, rate, channels, format, input=False, output=False, input_device_index=None, output_device_index=None, frames_per_buffer=1024, start=True)
(Constructor)

Initialize a stream; this should be called by PyAudio.open. A stream can either be input, output, or both.

Parameters:
PA_manager -

A reference to the managing PyAudio instance

rate -

Sampling rate

channels -

Number of channels

format -

Sampling size and format. See PaSampleFormat.

input -

Specifies whether this is an input stream. Defaults to False.

output -

Specifies whether this is an output stream. Defaults to False.

input_device_index -

Index of Input Device to use. Unspecified (or None) uses default device. Ignored if input is False.

output_device_index -

Index of Output Device to use. Unspecified (or None) uses the default device. Ignored if output is False.

frames_per_buffer -

Specifies the number of frames per buffer.

start -

Start the stream running immediately. Defaults to True. In general, there is no reason to set this to false.

Raises:
ValueError -

Neither input nor output are set True.

close(self)

Close the stream

get_input_latency(self)

Return the input latency.

Returns:

float

get_output_latency(self)

Return the input latency.

Returns:

float

get_time(self)

Return stream time.

Returns:

float

get_cpu_load(self)

Return the CPU load.

(Note: this is always 0.0 for the blocking API.)

Returns:

float

start_stream(self)

Start the stream.

stop_stream(self)

Stop the stream. Once the stream is stopped, one may not call write or read. However, one may call start_stream to resume the stream.

is_active(self)

Returns whether the stream is active.

Returns:

bool

is_stopped(self)

Returns whether the stream is stopped.

Returns:

bool

write(self, frames, num_frames=None, exception_on_underflow=False)

Write samples to the stream.

Parameters:
frames -

The frames of data.

num_frames -

The number of frames to write. Defaults to None, in which this value will be automatically computed.

exception_on_underflow -

Specifies whether an exception should be thrown (or silently ignored) on buffer underflow. Defaults to False for improved performance, especially on slower platforms.

Returns:

None

Raises:
IOError -

if the stream is not an output stream or if the write operation was unsuccessful.

read(self, num_frames)

Read samples from the stream.

Parameters:
num_frames -

The number of frames to read.

Returns:

str

Raises:
IOError -

if stream is not an input stream or if the read operation was unsuccessful.

get_read_available(self)

Return the number of frames that can be read without waiting.

Returns:

int

get_write_available(self)

Return the number of frames that can be written without waiting.

Returns:

int


Generated by Epydoc 2.1 on Thu May 25 13:09:00 2006 http://epydoc.sf.net