audiomixer¶
Support for audio mixing
-
class
audiomixer.Mixer(voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000)¶ Mixes one or more audio samples together into one sample.
-
playing:Any¶ True when any voice is being output. (read-only)
-
sample_rate:Any¶ 32 bit value that dictates how quickly samples are played in Hertz (cycles per second).
-
voice:Any¶ A tuple of the mixer’s
audiomixer.MixerVoiceobject(s).>>> mixer.voice (<MixerVoice>,)
-
deinit(self)¶ Deinitialises the Mixer and releases any hardware resources for reuse.
-
__enter__(self)¶ No-op used by Context Managers.
-
__exit__(self)¶ Automatically deinitializes the hardware when exiting a context. See Lifetime and ContextManagers for more info.
-
play(self, sample: Any, *, voice: Any = 0, loop: Any = False)¶ Plays the sample once when loop=False and continuously when loop=True. Does not block. Use
playingto block.Sample must be an
audiocore.WaveFile,audiocore.RawSample, oraudiomixer.Mixer.The sample must match the Mixer’s encoding settings given in the constructor.
-
stop_voice(self, voice: Any = 0)¶ Stops playback of the sample on the given voice.
-
-
class
audiomixer.MixerVoice¶ Voice objects used with Mixer
Used to access and control samples with
audiomixer.Mixer.-
level:Any¶ The volume level of a voice, as a floating point number between 0 and 1.
-
playing:Any¶ True when this voice is being output. (read-only)
-
play(self, sample: Any, *, loop: Any = False)¶ Plays the sample once when
loop=False, and continuously whenloop=True. Does not block. Useplayingto block.Sample must be an
audiocore.WaveFile,audiomixer.Mixeroraudiocore.RawSample.The sample must match the
audiomixer.Mixer’s encoding settings given in the constructor.
-
stop(self)¶ Stops playback of the sample on this voice.
-