Permalink
Browse files

BF: removed some debug timing code from sounddevice

  • Loading branch information...
peircej committed Jun 13, 2017
1 parent 87fc3a5 commit e5ae2fc2eb692ad25909bf9a29eafcda708ed3de
Showing with 14 additions and 15 deletions.
  1. +14 −15 psychopy/sound/backend_sounddevice.py
@@ -140,7 +140,7 @@ def __init__(self, sampleRate, channels, blockSize,
self.sounds = [] # list of dicts for sounds currently playing
self.takeTimeStamp = False
self.frameN = 1
self.frameTimes = range(5) # DEBUGGING: store the last 5 callbacks
# self.frameTimes = range(5) # DEBUGGING: store the last 5 callbacks
if not travisCI: # travis-CI testing does not have a sound device
self._sdStream = sd.OutputStream(samplerate=sampleRate,
blocksize=self.blockSize,
@@ -189,23 +189,22 @@ def callback(self, toSpk, blockSize, timepoint, status):
self.sounds.remove(thisSound)
thisSound._EOS()
# check if that took a long time
t1 = time.time()
if (t1-t0) > 0.001:
logging.info("buffer_callback took {:.3f}ms that frame"
.format((t1-t0)*1000))
self.frameTimes.pop(0)
if hasattr(self, 'lastFrameTime'):
self.frameTimes.append(time.time()-self.lastFrameTime)
self.lastFrameTime = time.time()
if self.takeTimeStamp:
logging.info("Callback durations: {}".format(self.frameTimes))
logging.info("blocksize = {}".format(blockSize))
self.takeTimeStamp = False
# t1 = time.time()
# if (t1-t0) > 0.001:
# logging.debug("buffer_callback took {:.3f}ms that frame"
# .format((t1-t0)*1000))
# self.frameTimes.pop(0)
# if hasattr(self, 'lastFrameTime'):
# self.frameTimes.append(time.time()-self.lastFrameTime)
# self.lastFrameTime = time.time()
# if self.takeTimeStamp:
# logging.debug("Callback durations: {}".format(self.frameTimes))
# self.takeTimeStamp = False
def add(self, sound):
t0 = time.time()
# t0 = time.time()
self.sounds.append(sound)
logging.info("took {} ms to add".format((time.time()-t0)*1000))
# logging.debug("took {} ms to add".format((time.time()-t0)*1000))
def remove(self, sound):
if sound in self.sounds:

0 comments on commit e5ae2fc

Please sign in to comment.