-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Record pecks during playback #110
Comments
Ostensibly pyoperant supports this, but implementation is going to be highly dependent on hardware. Currently, playback using the AudioOutput requires three methods.
after The short answer is to adjust the
Practically, however, you'll run into some problems. Audio playback is fairly CPU-heavy. Polling for pecks with comedi is VERY CPU heavy. In my experience, allowing early responses ended up causing the audio to drop while pyoperant was polling for responses. This is largely a problem with the limitations of the comedi drivers we are using and the polling mechanism. Better approachestake advantage of PyAudio's callback feature PyAudio supports PortAudio's callback which executes on each chunk of audio. This needs to be a short, fast function, however. See limitations here: use PyDAQmx instead of comedi NI hardware which supports NIDAQmx can be used to execute polling more efficiently, as the polling takes place on the hardware and sends a callback to the software when there is a state change on a port(s). The "right way" to do this seems to be:
|
We have been doing exactly what @neuromusic suggested with no real issues using PyAudio for playback and an Arduino for polling. I've nearly finished my implementation of a nidaq interface using pylibnidaqmx and I'll try to test the same use case when I do. |
Hey All! Good work on making pyoperant an easy to use tool! One suggestion re standard recording of events regardless of state machine Something like this is implemented in my behavior controller code for https://bitbucket.org/spikeCoder/kranky/src Best, Jeff On Tue, Mar 29, 2016 at 9:09 AM, siriuslee [email protected] wrote:
Jeff Knowles |
sweet. thanks @Jeffknowles this might be nice for some of the refactoring @siriuslee - are you using the 'callback' attribute I added to the pyaudio interface? or did you write your own portaudio/pyaudio callback? I'm considering getting rid of my callback "feature" in favor of letting users define the function that pyaudio wants. it seems less risky to force people to at least read the portaudio documentation so they know how it works (and the caveats/risks) see #111 for my proposed changes |
We didn't require any use of the callback function. Since pyaudio plays sound without blocking, we just kick off a poll of the pecking port for the duration of the sound. Then, if the poll exits before timing out, we call |
I would like to record pecks during playback of audio- and allow the audio to be killed early if the bird makes an early decision.
The text was updated successfully, but these errors were encountered: