In my experiment, I try to play two sounds consecutively, one in one speaker (index:1) one in the other (index=2).
I recently updated and was happy to see that the option to choose the speaker for a sound to play was now available in the builder. I indicate the right speaker in the builder, but when i launch the experiment, both sounds are played in the system default speaker.
I tried to go back to the coder and manually change the index in deviceManager.addDevice. It completely ignores the index and plays always in the system default speaker.
Is this a bug? Is there a way to do it in this software. I feel that this is quite a basic feature but I have been at it for a while and start to desperate.
EDIT: Actually, boths Speakers are determined in Sound_2. When I change the Speaker for Sound_2, it changes the speaker for Sound_1 and Sound_2, when i change the speaker for Sound_1, nothing happens… Is there a way to solve this and use two soundcards?
Ok so I have seen a few people with the same issue and no answer from the forum so here what I did to solve this. First–> the speaker option in the Builder or the sound.PTB function does not work on my PC. It is completely ignored and is set to whatever random choice of main speaker it chooses at the beguinning.
What I did for double soundcard sound presentation is :
One sound from the buider chosing the soundcard1 and
for the second sound presenting it through a code snippet as follows
Before experiment
from psychtoolbox import audio
from soundfile import SoundFile
I did a similar thing to play out of two different speakers– instead of using the GUI, i initialize the speaker in a code snippet and play from that speaker,
For example, this is a code snippet during a part where I play an audio:
(I also index my audio devices by name in the beginning of the script so that i know which index = which speaker, and I can initialize based on index)
# Start audio after image
listening_t = globalClock.getTime(applyZero=True)
audio_start = listening_t + 1
# Make scanner speaker as device
deviceManager.addDevice(
deviceName='scanner',
deviceClass='psychopy.hardware.speaker.SpeakerDevice',
index=scanner_index
)
# Set 'audio' sound object, for scanner,
# which can be played later with dynamic filepaths
# from stimulus sheet
audio = sound.Sound(secs=-1, stereo=True, hamming=True,
speaker='scanner', name='audio'
)
# Play audio from Audio in stimulus sheet
print(Audio) # print the filepath
audio.setSound(Audio, hamming=True)
audio.setVolume(scanner_volume, log=False)
audio.seek(0)