本文整理汇总了Python中pygame.mixer.Sound.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Sound.__init__方法的具体用法?Python Sound.__init__怎么用?Python Sound.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.mixer.Sound
的用法示例。
在下文中一共展示了Sound.__init__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pygame.mixer import Sound [as 别名]
# 或者: from pygame.mixer.Sound import __init__ [as 别名]
def __init__(self, note=None, frequency=440, volume=0.1):
# Notes must be in the format A[♯,♭,♮][octave number], if the octave is
# left out then it will be centered around C5.
# If note is a tuple then map the calls to parse_note, etc.
if note is not None:
if type(note) in [list, tuple]:
note = map(Note.parse_note, note)
frequency = [Note.notes[n] for n in note]
sound_buffer = Note.build_chord(frequency)
else:
note = Note.parse_note(note)
frequency = Note.notes[note]
sound_buffer = Note.build_samples(frequency)
self.note = note
self.frequency = frequency
Sound.__init__(self, buffer=sound_buffer)
self.set_volume(volume)
示例2: __init__
# 需要导入模块: from pygame.mixer import Sound [as 别名]
# 或者: from pygame.mixer.Sound import __init__ [as 别名]
def __init__(self, frequency, volume=.1):
self.frequency = frequency
Sound.__init__(self, self.build_samples())
self.set_volume(volume)
示例3: __init__
# 需要导入模块: from pygame.mixer import Sound [as 别名]
# 或者: from pygame.mixer.Sound import __init__ [as 别名]
def __init__(self, frequency, volume=.1):
self.frequency = 2*frequency # Eliminar el 2 si se usa sample rate de 44100
Sound.__init__(self, self.build_samples())
self.set_volume(volume)