本文整理汇总了Python中pygame.mixer.get_init方法的典型用法代码示例。如果您正苦于以下问题:Python mixer.get_init方法的具体用法?Python mixer.get_init怎么用?Python mixer.get_init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.mixer
的用法示例。
在下文中一共展示了mixer.get_init方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_init__returns_exact_values_used_for_init
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def test_get_init__returns_exact_values_used_for_init(self):
# fix in 1.9 - I think it's a SDL_mixer bug.
# TODO: When this bug is fixed, testing through every combination
# will be too slow so adjust as necessary, at the moment it
# breaks the loop after first failure
for init_conf in CONFIGS:
frequency, size, channels
if (frequency, size) == (22050, 16):
continue
mixer.init(frequency, size, channels)
mixer_conf = mixer.get_init()
self.assertEqual(init_conf, mixer_conf)
mixer.quit()
示例2: music_start
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def music_start(self):
if not mixer.get_init():
self._init_pygame()
if not mixer.music.get_busy():
if self.m_sMusicState == 'play':
self.m_iSongPos = 0
self._seek_track()
mixer.music.set_volume(self.m_iVolStep)
mixer.music.play(0, int(self.m_iSongPos))
logging.info("INFO: resuming music time at {%ss}" % self.m_iSongPos)
self._fade_in()
self.m_sMusicState = 'play'
示例3: stop_siren
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def stop_siren(self):
if mixer and mixer.get_init():
mixer.music.stop()
mixer.quit()
示例4: _set_volume
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def _set_volume(self):
"""Set the volume of the audio samples."""
if mixer.get_init():
mixer.music.set_volume(
self._volume.value() / self._volume.maximum()
)
示例5: _reset_audio_widget
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def _reset_audio_widget(self):
"""Reset the widget. Stop all playing samples."""
self._first_call = True
self._paused = False
if mixer.get_init():
if mixer.music.get_busy():
mixer.music.stop()
self._timer.stop()
mixer.quit()
self._audio_progress.reset()
self._enable_buttons(False, False, False)
示例6: sound_from_pos
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def sound_from_pos(sound, start_pos, samples_per_second = None, inplace = 1):
""" returns a sound which begins at the start_pos.
start_pos - in seconds from the begining.
samples_per_second -
"""
# see if we want to reuse the sound data or not.
if inplace:
a1 = pygame.sndarray.samples(sound)
else:
a1 = pygame.sndarray.array(sound)
# see if samples per second has been given. If not, query the mixer.
# eg. it might be set to 22050
if samples_per_second is None:
samples_per_second = pygame.mixer.get_init()[0]
# figure out the start position in terms of samples.
start_pos_in_samples = int(start_pos * samples_per_second)
# cut the begining off the sound at the start position.
a2 = a1[start_pos_in_samples:]
# make the Sound instance from the array.
sound2 = pygame.sndarray.make_sound(a2)
return sound2
示例7: test_init__keyword_args
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def test_init__keyword_args(self):
# note: this test used to loop over all CONFIGS, but it's very slow..
mixer.init(**CONFIG)
mixer_conf = mixer.get_init()
self.assertEqual(mixer_conf[0], CONFIG['frequency'])
# Not all "sizes" are supported on all systems, hence "abs".
self.assertEqual(abs(mixer_conf[1]), abs(CONFIG['size']))
self.assertEqual(mixer_conf[2], CONFIG['channels'])
示例8: test_pre_init__keyword_args
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def test_pre_init__keyword_args(self):
# note: this test used to loop over all CONFIGS, but it's very slow..
mixer.pre_init(**CONFIG)
mixer.init()
mixer_conf = mixer.get_init()
self.assertEqual(mixer_conf[0], CONFIG['frequency'])
# Not all "sizes" are supported on all systems, hence "abs".
self.assertEqual(abs(mixer_conf[1]), abs(CONFIG['size']))
self.assertEqual(mixer_conf[2], CONFIG['channels'])
示例9: test_pre_init__zero_values
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def test_pre_init__zero_values(self):
# Ensure that argument values of 0 are replaced with
# default values. No way to check buffer size though.
mixer.pre_init(44100, -8, 1) # Non default values
mixer.pre_init(0, 0, 0) # Should reset to default values
mixer.init()
self.assertEqual(mixer.get_init(), (22050, -16, 2))
示例10: test_init__zero_values
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def test_init__zero_values(self):
# Ensure that argument values of 0 are replaced with
# preset values. No way to check buffer size though.
mixer.pre_init(44100, 8, 1, allowedchanges=0) # None default values
mixer.init(0, 0, 0)
self.assertEqual(mixer.get_init(), (44100, 8, 1))
示例11: test_get_init__returns_None_if_mixer_not_initialized
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def test_get_init__returns_None_if_mixer_not_initialized(self):
self.assertIsNone(mixer.get_init())
示例12: setUp
# 需要导入模块: from pygame import mixer [as 别名]
# 或者: from pygame.mixer import get_init [as 别名]
def setUp(cls):
# This makes sure the mixer is always initialized before each test (in
# case a test calls pygame.mixer.quit()).
if mixer.get_init() is None:
mixer.init()