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

Class PyAudio


Python interface to PortAudio. Provides methods to:

Use this class to open and close streams.


Method Summary
  __init__(self)
Initialize PortAudio.
  terminate(self)
Terminate PortAudio.

dict

_make_device_info_dictionary(self, index, device_info)
Internal method to create Device Info dictionary that mirrors PortAudio's PaDeviceInfo structure.

dict

_make_host_api_dictionary(self, index, host_api_struct)
Internal method to create Host API dictionary that mirrors PortAudio's PaHostApiInfo structure.
  _remove_stream(self, stream)
Internal method.
    Stream Management
  open(self, *args, **kwargs)
Open a new stream.
  close(self, stream)
Close a stream.
    Host API

int

get_host_api_count(self)
Return the number of PortAudio Host APIs.

dict

get_default_host_api_info(self)
Return a dictionary containing the default Host API parameters.

dict

get_host_api_info_by_type(self, host_api_type)
Return a dictionary containing the Host API parameters for the host API specified by the host_api_type.

dict

get_host_api_info_by_index(self, host_api_index)
Return a dictionary containing the Host API parameters for the host API specified by the host_api_index.

dict

get_device_info_by_host_api_device_index(self, host_api_index, host_api_device_index)
Return a dictionary containing the Device parameters for a given Host API's n'th device.
    Device API

int

get_device_count(self)
Return the number of PortAudio Host APIs.

bool

is_format_supported(self, rate, input_device, input_channels, input_format, output_device, output_channels, output_format)
Check to see if specified device configuration is supported.

dict

get_default_input_device_info(self)
Return the default input Device parameters as a dictionary.

dict

get_default_output_device_info(self)
Return the default output Device parameters as a dictionary.

dict

get_device_info_by_index(self, device_index)
Return the Device parameters for device specified in device_index as a dictionary.
    Stream Format Conversion

int

get_sample_size(self, format)
Returns the size (in bytes) for the specified sample format (a PaSampleFormat constant).

PaSampleFormat

get_format_from_width(self, width, unsigned)
Returns a PortAudio format constant for the specified width.

Method Details

open(self, *args, **kwargs)

Open a new stream. See constructor for Stream.__init__ for parameter details.

Returns:

Stream

close(self, stream)

Close a stream. Typically use Stream.close instead.

Parameters:
stream -

An instance of the Stream object.

Raises:
ValueError -

if stream does not exist.

get_host_api_count(self)

Return the number of PortAudio Host APIs.

Returns:

int

get_default_host_api_info(self)

Return a dictionary containing the default Host API parameters. The keys of the dictionary mirror the data fields of PortAudio's PaHostApiInfo structure.

Returns:

dict

Raises:
IOError -

if no default input device available

get_host_api_info_by_type(self, host_api_type)

Return a dictionary containing the Host API parameters for the host API specified by the host_api_type. The keys of the dictionary mirror the data fields of PortAudio's PaHostApiInfo structure.

Parameters:
host_api_type -

The desired Host API (PaHostApiTypeId constant).

Returns:

dict

Raises:
IOError -

for invalid host_api_type

get_host_api_info_by_index(self, host_api_index)

Return a dictionary containing the Host API parameters for the host API specified by the host_api_index. The keys of the dictionary mirror the data fields of PortAudio's PaHostApiInfo structure.

Parameters:
host_api_index -

The host api index.

Returns:

dict

Raises:
IOError -

for invalid host_api_index

get_device_info_by_host_api_device_index(self, host_api_index, host_api_device_index)

Return a dictionary containing the Device parameters for a given Host API's n'th device. The keys of the dictionary mirror the data fields of PortAudio's PaDeviceInfo structure.

Parameters:
host_api_index -

The Host API index number.

host_api_device_index -

The n 'th device of the host API.

Returns:

dict

Raises:
IOError -

for invalid indices

get_device_count(self)

Return the number of PortAudio Host APIs.

Returns:

int

is_format_supported(self, rate, input_device=None, input_channels=None, input_format=None, output_device=None, output_channels=None, output_format=None)

Check to see if specified device configuration is supported.

Parameters:
rate -

Specifies the desired rate (in Hz)

input_device -

The input device index. Specify None (default) for half-duplex output-only streams.

input_channels -

The desired number of input channels. Ignored if input_device is not specified (or None).

input_format -

PortAudio sample format constant defined in this module

output_device -

The output device index. Specify None (default) for half-duplex input-only streams.

output_channels -

The desired number of output channels. Ignored if input_device is not specified (or None).

output_format -

PortAudio sample format constant (PaSampleFormat).

Returns:

bool

Raises:
ValueError -

PortAudio error or invalid devices.

get_default_input_device_info(self)

Return the default input Device parameters as a dictionary. The keys of the dictionary mirror the data fields of PortAudio's PaDeviceInfo structure.

Returns:

dict

Raises:
IOError -

No default input device available.

get_default_output_device_info(self)

Return the default output Device parameters as a dictionary. The keys of the dictionary mirror the data fields of PortAudio's PaDeviceInfo structure.

Returns:

dict

Raises:
IOError -

No default output device available.

get_device_info_by_index(self, device_index)

Return the Device parameters for device specified in device_index as a dictionary. The keys of the dictionary mirror the data fields of PortAudio's PaDeviceInfo structure.

Parameters:
device_index -

The device index.

Returns:

dict

Raises:
IOError -

Invalid device_index.

get_sample_size(self, format)

Returns the size (in bytes) for the specified sample format (a PaSampleFormat constant).

Parameters:
format -

Sample format constant (PaSampleFormat).

Returns:

int

Raises:
ValueError -

Invalid specified format.

get_format_from_width(self, width, unsigned=True)

Returns a PortAudio format constant for the specified width.

Parameters:
width -

The desired sample width in bytes (1, 2, 3, or 4)

unsigned -

For 1 byte width, specifies signed or unsigned format.

Returns:

PaSampleFormat

Raises:
ValueError -

for invalid width

__init__(self)
(Constructor)

Initialize PortAudio.

terminate(self)

Terminate PortAudio.

Attention:

Be sure to call this method for every instance of this object to release PortAudio resources.

_make_device_info_dictionary(self, index, device_info)

Internal method to create Device Info dictionary that mirrors PortAudio's PaDeviceInfo structure.

Returns:

dict

_make_host_api_dictionary(self, index, host_api_struct)

Internal method to create Host API dictionary that mirrors PortAudio's PaHostApiInfo structure.

Returns:

dict

_remove_stream(self, stream)

Internal method. Removes a stream.

Parameters:
stream -

An instance of the Stream object.


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