pySonic

Source class

Plays sample or stream audio data. A source will maintain some of its settings (e.g. position in 3D space, reverberation params) across playback of different sources and streams. Some of the source settings will be overridden (i.e. frequency, volume, loop mode) when a new sample or stream is assigned to the source.

Methods

Source()

Create a new Source object.

function GetEndStreamCallback()

Return the currently registered callback function.

function GetMetadataStreamCallback()

Return the currently registered callback function.

function GetSyncStreamCallback()

Return the currently registered callback function.

bool IsPaused()

Return if the source is currently paused or not.

bool IsPlaying()

Return if the source is currently in the midst of playing a sound or not. A source that is paused is still considered playing.

Pause()

Pause a currently playing sound.

Play()

Play a currently stopped sound from the beginning. Resume a paused sound.

SetEndStreamCallback(function func)

Registers a function to be called when this source finishes playing a stream. The callback function must follow this prototype:

OnEndStream(Source)

where the object passed to the function is the source that was playing the stream.

SetMetadataStreamCallback(function func)

Registers a function to be called when this source receives metadata while playing an Internet stream. The callback function must follow this prototype:

OnMetadataStream(Source, string, string)

where the first parameter is the source that was playing the stream, the second is the name of the metadatum, and third is the value of the metadatum.

SetSyncStreamCallback(function func)

Registers a function to be called when this source encounters a synchronization point while playing a stream. The callback function must follow this prototype:

OnSyncStream(Source, string)

where the first parameter is the source that was playing the stream and the second is the name of the sync point encountered.

Stop()

Stop a currently playing or paused sound.

Properties

int Amplitude (read)

The amplitude of the playing sound based on its volume, its 3D position, and the master volume. Values range between 0 and 255.

tuple(int, int) CurrentLevels (read)

The left and right levels of the playing sound. Only registers for sounds mixed in software. Values range between 0 and 255.

int CurrentSample (read/write)

The current position in samples of the playing sound.

float CurrentTime (read/write)

The current position in seconds of the playing sound. Only works with streams. Playing samples always return zero.

int Frequency (read/write)

The frequency used to playback the current sound. This value is overridden the next time a new sound is assigned to this source.

int LoopMode (read/write)

The loop mode used to playback the current sound. The value can be set to any of the pySonic.Constants.FSOUND_LOOP_* flags. This value is overridden the next time a new sound is assigned to this source.

tuple(float, float, float) Position (read/write)

The position of the source in 3D space. Only affects 3D sounds.

int Priority (read/write)

The priority of the source indicating how easily it can be preempted when channels are limited. Values range between 0 and 255. A value of 256 is reserved for sources playing streams.

bool Reserved (read/write)

The flag indicating if a source reserves a channel and cannot be pre-empted by another source.

ChannelReverb Reverb (read)

The Reverb object that controls the EAX reverberation settings for this source. See the ChannelReverb class for more details.

Sound Sound (read/write)

The Sound object assigned to this source for playback. See the Sound class for details on creating or loading sounds.

bool Surround (read/write)

The flag indicating whether or not the source will use a hack to make sound playback sound fuller or spacier on two speaker systems.

tuple(float, float, float) Velocity (read/write)

The velocity of the source in 3D space. Only works with mono sounds.

int Volume (read/write)

The volume used to playback the current sound. Values range from 0 to 255. This value is overridden the next time a new sound is assigned to this source.