本文整理汇总了Python中Base.channels方法的典型用法代码示例。如果您正苦于以下问题:Python Base.channels方法的具体用法?Python Base.channels怎么用?Python Base.channels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base
的用法示例。
在下文中一共展示了Base.channels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: play
# 需要导入模块: import Base [as 别名]
# 或者: from Base import channels [as 别名]
def play(self, repeats=1, bg=True, w=None, data=None, timeout=None, vol=None, pan=None):
"""
plays a wav object w, which defaults to the currently loaded instance p.wav
Set repeats=-1 to loop forever. Set bg=False to play synchronously.
p.play(w=w2) sets p.wav = w2 and then plays it (which may involve closing and
re-opening the stream if the bit depth, sampling rate or number of channels
differs between w2 and the old p.wav).
p.play(data=d) uses the raw data in numpy.array d instead of the default w.y,
playing it at the sampling frequency and bit depth dictated by w.
"""###
if self.playing: return
self.timestamps['play'] = prectime()
self.open(w)
w = self.wav
if w == None: return
if data == None: data = w.y
if Base.channels(data) != Base.channels(w): raise ValueError, 'data array and wav object have mismatched numbers of channels'
self.timeout=timeout
self.kwargs = {'w':w, 'data':data, 'repeats':repeats}
if vol != None: self.vol = vol
if pan != None: self.pan = pan
self.__playing = True
self.go(bg=bg)