pySonic

Stream virtual class

Streams and decodes audio data for playback by a source. Derives from the virtual Sound class.

Methods

AddSyncPoint(int, string)

Add a new synchronization point with the given name to the stream at the given sample number.

RemoveSyncPoint(string)

Remove the synchronization point with the given name from the stream.

Properties

int Frequency (read)

The default frequency (sampling rate) of the audio data.

int Volume (read)

The default volume of the audio data. Values range from 0 to 255.

int Priority (read)

The default priority of the audio data indicating how easily it can be preempted when channels are limited. Values range between 0 and 255.

int LoopMode (read)

The default loop mode of the audio data. The value is one of the pySonic.Constants.FSOUND_LOOP_* flags.

int NumSamples (read)

The length of the audio data in samples (not bytes).

int NumSyncPoints (read)

The number of synchronization points in the stream.

float Duration (read)

The length of the sample in seconds when played at its default frequency.

FileStream class

Streams audio data from disk for playback. Derives from Stream.

Methods

FileStream(string filename, *args)

Creates a stream of audio data from the given file on disk. The pySonic.Constants.FSOUND_NORMAL flag is specified for the audio data by default. Any extra arguments will override the default flag with the specified pySonic.Constants.FSOUND_* flags.

MemoryStream class

Stream audio data already in memory for playback. Derives from Stream.

Methods

MemoryStream(buffer buff, int channels, int bits, int frequency, *args)

Creates a stream from the audio data specified in buffer. The number of channels (1 or 2), bits per sample (8 or 16), and frequency must be specified. Any extra arguments will be treated as pySonic.Constants.FSOUND_* flags.

The MemorySample object holds a reference to the buffer you pass to it. The audio data is streamed directly from this buffer. Changing the length of the buffer during playback could have disastrous results.

WebStream class

Streams audio data from a file on the Web. Derives from Stream.

Methods

WebStream(string url, *args)

Creates a stream of audio data from the given URL on the Web. The pySonic.Constants.FSOUND_NORMAL and pySonic.Constants.FSOUND_NET_STREAM flags are specified for the audio data by default. Any extra arguments will override the default pySonic.Constants.FSOUND_NORMAL flag with the specified pySonic.Constants.FSOUND_* flags. The pySonic.FSOUND_NET_STREAM flag is always set.

The URL must start with http://. The file specified by the URL must end with .mp3 or .ogg. These are both FMOD limitations.

Future version of pySonic will always set the pySonic.Constants.FSOUND_NET_STREAM flag, even if other flags are given to the constructor.

Properties

tuple(int, int, int, int) Status (read)

The status of the Web stream. The first value is one of the pySonic.Constants.FSOUND_STREAM_NET_* flags representing the ready status of the stream. The second value is the size of the local buffer used by the stream. The third value is the desired bitrate of the stream. The fourth value is a combination of the pySonic.Constants.FSOUND_PROTOCOL_* and pySonic.Constants.FSOUND_FORMAT_* flags indicating the transport protocol for the audio data and the format of the audio data.