[solved] "audio switching" with OpenSesame
Dear fellow Coders,
I'm new to OpenSesame and have a question for the more experienced coders. To provide a little background: We employ auditory localization tasks in our experiments. Typically, two (different) sounds are simultaneously presented from two (out of x) speakers. The specific speakers are defined on a trial-by-trial basis. Therefore, I'm looking for a program that can "send" the sound signal to different speakers.
We previously had a hardware solution for the issue: Specific speakers were defined in another software (LiveCode) and transmitted to a (custom made) audio switch device via the COM-port. The audio switch device then send the left/right channel of a stereo file to the specified speakers. I wonder if it is possible to circumvent the audio switch device (which is no longer available) and directly specify sound channels (e.g. via a sound card or an audio interface) with OpenSesame.
Any ideas? Thanks in advance for any suggestions. I'm mainly interested if OpenSesame is capable of such an operation.
Cheers,
Malte
Edit: The feature we are (desperately) looking for is similar to the "Sound Mixer" implemented e.g. in the Presentation environment.
Comments
Hi Malte,
If there is a Python package somewhere out there that can do this operation it will most likely also work from within OpenSesame. Unfortunately, I have no clue whether it exists, or anything specific about how to tackle the problem.
Sorry,
Eduard
Hi Eduard,
it's a good thing to hear that it is (generally) possible. I came across a rather convenient solution for the "present from multiple speakers"-part of the problem: Following this post, it can be easily done for mono/stereo files by adding more entries to the channel_map in PyAudio. The (slightly modified) code looks like this:
Is it possible to implement PyAudio in OpenSesame by manually editing the code of e.g., a sampler item? Or would that conflict with the ways sounds are played by OpenSesame?
If it is possible, can someone provide an example of how it can be done? I don't mind digging some more into libraries/modules but providing an example for the code in question would help me (as a novice) a lot.
Thanks again!
Malte
Sure, you can add arbitrary Python code using the inline_script item. If you search this forum for 'pyaudio', you'll find various examples of people using pyaudio this way.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
thanks for the quick reply! I will try to make the modified code from PyAudio work in OpenSesame. I will share any but (hopefully positive) outcome of it in the forum.
Thanks again!
Malte
Hello OpenSesameTeam,
I m trying to implement an inline script (separate item) to play a wav file using the script that I found here http://people.csail.mit.edu/hubert/pyaudio/.
I get an IO error in the following line:
wf = wave.open('drip.wav', 'rb')
(The drip.wav file is located on the same folder as my script.)
My o/p:
Error while executing inline script
phase: run
item: inline_script
line: 159
exception message:
exception type: IOError
Traceback:
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/libopensesame/inline_script.py", line 173, in run
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/libopensesame/python_workspace.py", line 111, in _exec
Inline_script, line 20, in
File "wave.pyc", line 509, in open
File "wave.pyc", line 160, in init
IOError: [Errno 2] No such file or directory: 'drip.wav'
Any ideas how to resolve this issue of IOError?
Thank you very much,
V
Hi V,
it would be help if you could provide the complete inline script that causes the error. At first glance, it seems that the file could not be retrieved. You might try to specify a path to "drip.wav".
Cheers,
Malte
Dear Malte,
thank you very much for your response, I resolved the issue. It is necessary to specify the absolute path of the file.
Take care!