Multichannel sound problem

I have problem to play multichannel surround sound.

I use 3 speakers with soundblaster x4 driver.
In python cmd, i can play multichannel sound file using sounddevice module
ex) import soundfile as sf
import sounddevice as sd
data,fs‘\left_footstep 2s.wav’,dtype=‘float32’),fs,device=3 )

But, An error occurs when playing a sound file with code in coder or builder (channel error)

Any solution for this?, experts please help

OS (e.g. Win10):
psychopy 23.1.2

Did you make any progress on this? I’m looking to do something similar, also with a soundblaster X4.


Hi there,

would you mind sharing the full code you ran together with the exact error message you received? Otherwise, there is a lot of guessing involved. As you stated, sounddevice can play multichannel sound. As stated in the docs, each column of the input array is treated as a channel and the assignment of data to output channels can be controlled with the mapping argument of You typically get a channel-related error message if the number of data channels does not match the output channels of the device.



Just to update - I got 8 channels working using Psychtoolbox with matlab and a Soundblaster X4 (usb connected) surround sound device. I build the wave signals into a data buffer in Matlab before ‘playing’ them.
NB I disabled surround sound in windows sound settings for this to work.
I’ve not tried it using audio files but I imagine that you could sue something like Audacity to create a multichannel sound file and use that.


the Python/PsychoPy solution is quite similar. Basically, the package sounddevice takes arrays with multiple columns as individual channels that can be directed to unique outputs. I attached a snipped below. In the example, mono sounds are imported first in .wav format:

import soundfile as sf
import sounddevice as sd
import numpy as np
from psychopy import core

# Set path to sound files:
file1 = "/path/to/sound/file/sound1.wav"
file2 = "/path/to/sound/file/sound2.wav"
# Read sound files:
data1, sr1 =, dtype='float32')
data2, sr2 =, dtype='float32')
# Combine data into array:
data12 = np.stack((data1, data2), axis=1)
# Play sounds (mapping determines the routing to outputs of the specified device):, samplerate=44100, device=2, mapping=[1, 2])
# Wait until sound is played:
core.wait(1, 1)

Devices and their channels can be shown with:


Hope that helps!