| |
- Channel
- Sound
- StreamingSound
class Channel |
|
Represents one sound source currently playing |
|
Methods defined here:
- __init__(self, src, env)
- fadeout(self, time)
- Schedule a fadeout of this sound in given time
- get_position(self)
- Return current position of sound in samples
- get_volume(self)
- Return current volume of sound
- pause(self)
- Pause the sound temporarily
- set_position(self, p)
- Set current position of sound in samples
- set_volume(self, v, fadetime=0)
- Set the volume of the sound
Removes any previously set envelope information. Also
overrides any pending fadeins or fadeouts.
- stop(self)
- Stop the sound playing
- unpause(self)
- Unpause a previously paused sound
|
class Sound |
|
Represents a playable sound |
|
Methods defined here:
- __init__(self, filename=None, data=None)
- Create new sound from a WAV file, MP3 file, or explicit sample data
- get_length(self)
- Return the length of the sound in samples
To convert to seconds, divide by the samplerate and then divide
by 2 if in stereo.
- play(self, volume=1.0, offset=0, fadein=0, envelope=None, loops=0)
- Play the sound
Keyword arguments:
volume - volume to play sound at
offset - sample to start playback
fadein - number of samples to slowly fade in volume
envelope - a list of [offset, volume] pairs defining
a linear volume envelope
loops - how many times to play the sound (-1 is infinite)
- resample(self, scale)
- Resample a sound
scale = 1.0 means original sound
scale = 0.5 is half as long (up an octave)
scale = 2.0 is twice as long (down an octave)
- scale(self, vol)
- Scale a sound sample
vol is 0.0 to 1.0, amount to scale by
|
class StreamingSound |
|
Represents a playable sound stream |
|
Methods defined here:
- __init__(self, filename, checks=True)
- Create new streaming sound from a WAV file or an MP3 file
The new streaming sound must match the output samplerate
and stereo-ness. You can turn off these checks by setting
the keyword checks=False, but the sound will be distorted.
- get_length(self)
- Return the length of the sound stream in samples
Only available for MP3 streams, not WAV ones. To convert
result to seconds, divide by the samplerate and then divide by
2.
- play(self, volume=1.0, offset=0, fadein=0, envelope=None, loops=0)
- Play the sound stream
Keyword arguments:
volume - volume to play sound at
offset - sample to start playback
fadein - number of samples to slowly fade in volume
envelope - a list of [offset, volume] pairs defining
a linear volume envelope
loops - how many times to play the sound (-1 is infinite)
| |