当前位置: 首页>>代码示例>>Python>>正文


Python mixer.get_init方法代码示例

本文整理汇总了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() 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:19,代码来源:mixer_test.py

示例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' 
开发者ID:krahsdevil,项目名称:Retropie-CRT-Edition,代码行数:14,代码来源:bgm.py

示例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() 
开发者ID:bggardner,项目名称:simplisafe-rf,代码行数:6,代码来源:basestation.py

示例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()
            ) 
开发者ID:AresValley,项目名称:Artemis,代码行数:8,代码来源:audio_player.py

示例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) 
开发者ID:AresValley,项目名称:Artemis,代码行数:13,代码来源:audio_player.py

示例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 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:29,代码来源:sound_array_demos.py

示例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']) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:11,代码来源:mixer_test.py

示例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']) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:13,代码来源:mixer_test.py

示例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)) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:9,代码来源:mixer_test.py

示例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)) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:8,代码来源:mixer_test.py

示例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()) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:4,代码来源:mixer_test.py

示例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() 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:7,代码来源:mixer_test.py


注:本文中的pygame.mixer.get_init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。