I hope someone can suggest some possible reasons for this behaviour.
I recently wrote some code for outputting 10-channel wav files using a Behringer UMC1820 audio interface. That works perfectly. I now want to output an 8-channel (7.1) wav file to a Startech ICUSBAUDIO7D USB sound card, so I have modified my code appropriately, basically just changing the name of the device and changing 10 channels to 8. Now when I run it I get the errors:
PTB-ERROR: Desired audio parameters for device 9 seem to be unsupported by audio device: Invalid sample rate
PTB-ERROR: Seems the requested audio sample rate 44100.000000 Hz is not supported by this combo of hardware and sound driver.
I can play the file using Foobar2000 without any problem, so there’s nothing wrong with the device or the file. A driver issue maybe?? Code snippet below.
Using:
Psych Toolbox version 3.0.19
Octave version 7.3.0
Windows 10
% Initialise, 1 forces low latency
InitializePsychSound(1);
% Get list of audio devices which support Windows WASAPI
devices = PsychPortAudio('GetDevices', 13);
nDevices = numel(devices);
% Look for Startech sound device
foundIndex = [];
for index = 1:nDevices
found = strfind (devices(index).DeviceName, 'USB Sound Device');
if ( found & ( devices(index).NrOutputChannels == 8 ) );
fprintf('Found 8-channel USB sound device\n\n');
foundIndex = index;
break;
end
end
if isempty(foundIndex)
error ("Can't find the Startech sound device!");
end;
% Extract the device number of the Startech sound card from devices
StartechDevice = devices(foundIndex).DeviceIndex;
% Open the sound device for 8-channel output at the sample rate used in the file
audioHandle=PsychPortAudio('Open',StartechDevice, [],[], freq, 8);
% Initialise playback
PsychPortAudio('FillBuffer',audioHandle,wavedata');
h = waitbar (0, 'Ready to play, press any key to start');
KbWait;
PsychPortAudio('Start',audioHandle,1,0,0);
audioHandle=PsychPortAudio('Open',StartechDevice, [],[], freq, 8);
opens the audio card in default latency mode 1, as that reqlatencyclass
parameter was []
omitted, which on Windows-WASAPI sound system means to play nice with other audio apps and share the soundcard with them. Currently, as of PTB 3.0.19.10, that means you need to select a frequency that is == the system selected frequency, which is apparently not 44100 Hz, but probably 48000 Hz. Somewhere is system sound settings that could probably be changed. I may have an idea how to fix this limitation for some future PTB release…
You could use a reqlatencyclass high enough to force exclusive use of the sound card instead, which probably will allow forcing a 44100 Hz sampling rate, ie.
audioHandle=PsychPortAudio('Open',StartechDevice, [], 2, freq, 8);
might do the trick, to the detriment of any other running sound apps on that card.
1 Like
Thanks Mario. I’ll look into your suggestions and report back if we manage to find the solution.
Here’s a download link to a potentially improved PsychPortAudio.mex for Octave on Windows, applying a hopefully trivial improvement for this use case. Try if swapping this file in also solves the original problem:
https://github.com/kleinerm/Psychtoolbox-3/raw/master/Psychtoolbox/PsychBasic/Octave8WindowsFiles64/PsychPortAudio.mex
It was staring me in the face!
On the control panel for the sound card…
Using the new PsychPortAudio.mex file breaks the code again. I get this error:
PTB-ERROR: Desired audio parameters for device 9 seem to be unsupported by audio device: Incompatible host API specific stream info
PTB-ERROR: This could be, e.g., due to an unsupported combination of timing, sample rate, audio channel count/allocation, or sample format.
Error in function Open: Usage error
Failed to open PortAudio audio device due to unsupported combination of audio parameters. Prevalidation failure.
error: PsychPortAudio: Usage:
pahandle = PsychPortAudio(‘Open’ [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][, selectchannels][, specialFlags=0]);
error: called from
Sound_Test_Startech_01 at line 46 column 12