Hi Andrew,
Yes, it’s basically as simple as manipulating the channel map. I don’t have a good working script I can send you at the moment but I copy and pasted the important bits from a much larger experiment script I am using that you’ll need in your code to execute this successfully. For the example below the audio will play a file called 'sound1.wav' from the first (of your 4) channel and be silent in the rest:
###
import sys
sys.path.append('/Library/python/2.7/site-packages/')
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7’) #this three lines are critical to get Psychopy to recognize pyaudio
import pyaudio #import pyAudio
import wave #to play .wav files
from psychopy import core, sound #might be useful
PyAudio = pyaudio.PyAudio
cm=(0, -1, -1, -1) #the channel map for the audio output. You probably want to set this to some variable you call from an excel file in your experiment loop.
wf = wave.open(sound1.wav) #sets the sound you want to play from file. You probably want to set this to some variable you call from an excel file in your experiment loop too so you can select different sounds on a trial-by-tiral basis.
p = PyAudio() #just re-initializes pyAudio
stream_info = pyaudio.PaMacCoreStreamInfo(
flags=pyaudio.PaMacCoreStreamInfo.paMacCorePlayNice,
channel_map=(cm)
stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
channels=wf.getnchannels(),
rate=wf.getframerate(),
output=True,
output_host_api_specific_stream_info=stream_info,
stream_callback=callback)
#then you can call the sound during your experiment to start playing by using:
stream.start_stream()
#and to stop using:
stream.stop_stream()
#and incase you want to close it out so it doesn’t clog other events:
stream.close()
###
Hope this helps.
Oh, also for a working example just to get a feel for how this works, you can add these three lines to the beginning the script I posted earlier in this thread and it should work if you follow my instructions in that thread.
import sys
sys.path.append('/Library/python/2.7/site-packages/')
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7’) #this three lines are critical to get Psychopy to recognize pyaudio
Sorry for the stream of consciousness response. Let me know if anything is unclear and maybe I can elaborate a bit when I have a bit more time.
Best,
Chris