pySonic

Sample virtual class

Holds decoded audio data entirely in memory for playback by a source. Derives from the virtual Sound class.

Methods

string GetBytes(int offset, int length)

Return the raw bytes in the audio starting at the sample at offset and continuing to the sample at offset plus length.

Properties

int Channels (read)

The number of channels in the sound, 1 for mono and 2 for stereo.

float Duration (read)

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

int Frequency (read)

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

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 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 SampleSize (read)

The number of bits in a single sample of the sound, 8 or 16.

int Volume (read)

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

FileSample class

Loads audio data from disk for playback. Derives from Sample.

Methods

FileSample(string filename, *args)

Creates a sample by loading 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 given pySonic.Constants.FSOUND_* flags.

MemorySample class

Uses audio data already in memory for playback. Derives from Sample.

Methods

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

Creates a sample 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.

You can safely delete the buffer after creating an instance of this class. The audio data is copied into a separate buffer by FMOD.

EmptySample class

Creates an empty buffer for audio recording in memory. Derives from Sample.

Methods

EmptySample(int samples, int channels, int bits, int frequency, *args)

Creates an empty buffer of the size given by samples. 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.