When two sounds are played in succession a bug can occur. For me, I get errors like this:
File "lex.py", line 218, in run
stamp = stim.present(clk=t.clk)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyepl/sound.py", line 134, in present
timestamp = a.play(self, t=clk, doDelay=doDelay)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyepl/sound.py", line 592, in play
soundClip.snd[0:firstbytes],
TypeError: 'NoneType' object is unsubscriptable
The source of the problem is at sound.AudioTrack.play, lines 585-587:
if self.playing:
# stop the playing sound 5ms prior to the new time
timing.timedCall(t-5, self.playStop, False)
When the call to play the next item happens prior to the offset of the prior sound, a timed call to self.playStop is issued. This inadvertently nukes "soundClip," which is the next sound to be played, making soundClip.snd = None, causing the fatal error on line 592. This happens even if there is a suitable delay included in the scheduled start for the next item, that is, when next_start_time > prior_stamp_time + prior_sound_duration.
A workaround for this is to (A) include a delay between sounds (ISI) and (B) invoke timing.timedCall, in some capacity, to pause execution until the prior sound has stopped of its own doing, ex:
stim_ISI = 100
stim_jitter = 10
kludge_delta = 15
...
t.clk.delay(stim_ISI, jitter = stim_jitter, resolveTimingError = True)
timing.timedCall(t.clk.get()-kludge_delta, t.clk.get)
Crucially, stim_ISI > 0 and kludge_delta < stim_ISI
Alternately, something like updateScreen can be used to stall execution.
Further, the specific problem appears to be that line 587 of play:
invokes, line 670 of playStop:
Which very much seems to the culprit since line 587 (above) is executed after line 566: