Can samplesAcquired( ) in Looper be used to output a sound?

74 views
Skip to first unread message

Adam Taylor

unread,
Dec 19, 2017, 11:19:29 AM12/19/17
to WaveSurfer
The question below was raised in a GitHub issue earlier today, by GitHub user TuMengyu95. I'm moving it over here because I think this is a more appropriate place for it.

-----
function samplesAcquired (self, looper, eventName, analogData, digitalData)
v = analogData ( : , 1);
if any (v<0)
looper.setDigitalOutputStateIfUntimedQuicklyAndDirtily (1)
queueOutputData ( self.session, self.data) %queue sound data for output to speakers
startBackground ( self.session ) %output sound duration is 100 ms
else
looper.setDigitalOutputStateIfUntimedQuicklyAndDirtily (0)
end
end

I was able to use
queueOutputData ( self.session, self.data)
startBackground ( self.session )
to output sound with the dataAvailable ( ) function.

With Looper, queueOutputData or startBackground seemed to not have been executed. Anyone knows why?
Is it because the samplesAcquired( ) is called a few ms and cannot output a sound of 100 ms?
Is there a way to deliver a sound stimulus of 100 ms with Looper? The frequency I need to output a sound is at most 4 Hz.

Thanks in advance for your suggestions!
-----

Adam


Adam Taylor

unread,
Dec 19, 2017, 11:29:45 AM12/19/17
to WaveSurfer
TuMengyu95,

I'm not 100% sure why this doesn't work, but the looper and refiller both run in Matlab instances that are running with the -nojvm option, so that might have something to do with it.  If you start WaveSurfer with with --debug option, you will be able to see the Matlab windows for these processes, and you may see error messages that indicate something about the nature of the problem.

If you're not doing any other kind of stimulation, you might consider setting up a stimulus that contains the audio waveform you want to output, and set up the stimulus map to output it via an AO channel.  Then set up the stimulation to be externally triggered on a PFI line (in the Triggering panel).  Then, in samplesAcquired(), set a DO line high and then low immediately.  Then connect that DO line to whichever PFI line is set up to trigger the audio waveform.  Then connect the AO line to a self-amplified speaker.  This should do what you want.

Hope this helps,
Adam

Reply all
Reply to author
Forward
0 new messages