本文整理汇总了Python中Base.panhelper方法的典型用法代码示例。如果您正苦于以下问题:Python Base.panhelper方法的具体用法?Python Base.panhelper怎么用?Python Base.panhelper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base
的用法示例。
在下文中一共展示了Base.panhelper方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: core
# 需要导入模块: import Base [as 别名]
# 或者: from Base import panhelper [as 别名]
def core(self, repeats=1, w=None, data=None):
self.timestamps['core'] = prectime()
sleep_msec = 1.0
self.timestamps['before'] = []
self.timestamps['after'] = []
preplay_done = False
subs = [slice(None),slice(None)]
nsamp = Base.samples(data)
start = 0
while repeats != 0:
start %= nsamp
while start < nsamp:
while True:
if not self.keepgoing or self.timedout(): self.keepgoing=False; break
towrite = self.stream.get_write_available()
nleft = (float(nsamp) - float(start)) / float(self.speed)
if towrite >= nleft: break
if towrite >= self.buffersize: break
sleep(sleep_msec/1000.0)
if not self.keepgoing: break
speed = float(self.speed)
if speed == 1.0:
start = int(round(start))
stop = start + towrite
if repeats == 1: stop = min(nsamp, stop)
subs[across_samples] = slice(start,stop)
dd = data[subs]
else:
start = float(start)
stop = start + float(speed) * float(towrite)
if repeats == 1: stop = min(float(nsamp), stop)
xi = numpy.linspace(start=start, stop=stop, endpoint=False, num=towrite)
xi %= float(nsamp)
dd = Base.interpsamples(data, xi)
vols = float(self.vol) * Base.panhelper(self.pan, nchan=dd, norm=self.norm)
dd = dd * vols # *= won't work for broadcasting here
raw = w.dat2str(data=dd)
if not preplay_done and self.preplay != None and self.preplay['func'] != None:
self.preplay['func'](*self.preplay['pargs'], **self.preplay['kwargs'])
preplay_done = True
if len(self.timestamps['before']) < 100: self.timestamps['before'].append(prectime())
self.stream.write(raw)
if len(self.timestamps['after']) < 100: self.timestamps['after'].append(prectime())
start = stop
if not self.keepgoing: break
repeats -= 1
if self.postplay != None and self.postplay['func'] != None:
self.postplay['func'](*self.postplay['pargs'], **self.postplay['kwargs'])
self.__playing = False
towrite = self.stream.get_write_available()
bytes_per_frame = self.interface.get_sample_size(self.format) * self.stream._channels
if towrite > 0: self.stream.write('\0' * towrite * bytes_per_frame)
while self.stream.get_write_available() < self.stream._frames_per_buffer: sleep(0.001)
sleep(float(self.stream._frames_per_buffer) / float(self.stream._rate) + self.stream.get_output_latency())