Can someone confirm that Psychportaudio works in slave mode - and what is the exact expected type/form of the selectchannels argument? The syntax is supposed to be similar to psychtoolbox in Matlab but haven’t been able to make it run in slave mode like this (works fine in simple playback mode=1, but not in master/slave mode=1+8):
from psychtoolbox import PsychPortAudio as ppa
pamaster = ppa(‘Open’, device_index, mode, reqlatencyclass, reqSampleRate, num_master_channels)
paslave = ppa(‘OpenSlave’, pamaster, mode_slave, num_slave_channels, selectchannels)
ppa(‘FillBuffer’, paslave, buffer)
ppa(‘Start’, pamaster, 0, 0, 1)
ppa(‘Start’, paslave)
Hi,
Yes, it does. The Python wrapper explicitly supports OpenSlave.The selectchannels is a 1-based integer vector where each element specifies which master device channel the corresponding slave channel connects to.
Hope this helps.
Thanks! For playback, it looks like selectchannels for the slave should be 1-row matrix. I still can’t make the slave play correctly though (on a Mac). It starts briefly and then stops immediately. Here’s a minimal example for that (my device 5 is a multi-channel sound card) - what might be wrong? from psychtoolbox import PsychPortAudio as ppa
import numpy as np
device_index = [5]
num_master_channels = 4
num_slave_channels = 2
select_slave_channels = np.array([[2.0, 3.0]], dtype=np.float64)
mode = 1+8
mode_slave = 1
reqlatencyclass = 3
reqSampleRate = 44100
pamaster = ppa(‘Open’, device_index, mode, reqlatencyclass, reqSampleRate, num_master_channels)
paslave = ppa(‘OpenSlave’, pamaster, mode_slave, num_slave_channels, select_slave_channels)
t = np.linspace(0, dur, int(reqSampleRate * 5.0), endpoint=False)
tone = 0.5 * np.sin(2 * np.pi * 400 * t)
buffer = np.zeros((tone.size, num_slave_channels), dtype=np.float32) # mac, transpose otherwise
buffer[:, 0] = tone
ppa(‘FillBuffer’, paslave, buffer)
ppa(‘Start’, pamaster, 0, 0, 1)
ppa(‘Start’, paslave, 1)