Thanks Mario - that is really interesting to know what my mac was probably doing behind the scenes in terms of resampling. I have remade my stimuli at 48k and they are playing just fine - thanks for the tip.
I had another question I was wondering if you might help me with, its another problem I am getting on this Windows computer and wasn’t getting on my mac:
I want to play two sounds, the first one, a one second pause, and then the other one.
I had thought it might be a good idea to load both sounds into separate buffers ahead of time (earlier in the code) and then play them separately when it came to it. This worked ok on mac, but when I try to initialise the second audio buffer on my PC with the following code:
PsychPortAudio(‘Close’);
% % Audio
InitializePsychSound(1); %inidializes sound driver…the 1 pushes for low latency
% Initialise two sound buffers for the two sounds
pahandle1 = PsychPortAudio(‘Open’, , , 2, Fs, num_chans, 0); % for the first played sound
pahandle2 = PsychPortAudio(‘Open’, , , 2, Fs, num_chans, 0); % for the second played sound
I get the following output/ error:
PsychPortAudio(‘Close’);
% % Audio
InitializePsychSound(1); %inidializes sound driver…the 1 pushes for low latency
% Initialise two sound buffers for the two sounds
pahandle1 = PsychPortAudio(‘Open’, , , 2, Fs, num_chans, 0); % for the first played sound
pahandle2 = PsychPortAudio(‘Open’, , , 2, Fs, num_chans, 0); % for the second played sound
PTB-INFO: Using modified PortAudio V19.7.0-devel, revision unknown
PTB-INFO: Using modified PortAudio V19.7.0-devel, revision unknown
PTB-INFO: New audio device -1 with handle 0 opened as PortAudio stream:
PTB-INFO: For 6 channels Playback: Audio subsystem is Windows WASAPI, Audio device name is Speakers (USB Sound Device )
PTB-INFO: Real samplerate 48000.000000 Hz. Input latency 0.000000 msecs, Output latency 10.000000 msecs.
PTB-ERROR: Failed to open audio device -1. PortAudio reports this error: Invalid device
PTB-ERROR: Desired audio parameters likely unsupported by audio device.
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
Error in function Open: Usage error
Failed to open PortAudio audio device due to unsupported combination of audio parameters.
Error using PsychPortAudio
Usage:
pahandle = PsychPortAudio(‘Open’ [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][,
selectchannels][, specialFlags=0]);
Seems like it was happy to open the first one but not the second, which worked on my mac.
I tried changing the device numbers to different values, but couldn’t find anything that worked.
I wondered if I needed the actual device number (I presume -1 is just ‘default’ sound)? So I looked at the output from:
devices = PsychPortAudio(‘GetDevices’);
And I got this, but was then not sure what to do with it (sorry about lack of table formatting):
0 |
2 |
‘MME’ |
‘Microsoft Sound Mapper - Input’ |
2 |
0 |
0.0900000000000000 |
0.180000000000000 |
0.0900000000000000 |
0.180000000000000 |
44100 |
1 |
2 |
‘MME’ |
'Microphone (USB Sound Device ’ |
2 |
0 |
0.0900000000000000 |
0.180000000000000 |
0.0900000000000000 |
0.180000000000000 |
44100 |
2 |
2 |
‘MME’ |
‘Line (USB Sound Device )’ |
2 |
0 |
0.0900000000000000 |
0.180000000000000 |
0.0900000000000000 |
0.180000000000000 |
44100 |
3 |
2 |
‘MME’ |
‘Stereo Mix (Realtek High Defini’ |
2 |
0 |
0.0900000000000000 |
0.180000000000000 |
0.0900000000000000 |
0.180000000000000 |
44100 |
4 |
2 |
‘MME’ |
‘SPDIF Interface (USB Sound Devi’ |
2 |
0 |
0.0900000000000000 |
0.180000000000000 |
0.0900000000000000 |
0.180000000000000 |
44100 |
5 |
2 |
‘MME’ |
‘Microsoft Sound Mapper - Output’ |
0 |
2 |
0.0900000000000000 |
0.180000000000000 |
0.0900000000000000 |
0.180000000000000 |
44100 |
6 |
2 |
‘MME’ |
'Speakers (USB Sound Device ’ |
0 |
8 |
0.0900000000000000 |
0.180000000000000 |
0.0900000000000000 |
0.180000000000000 |
44100 |
7 |
2 |
‘MME’ |
'Speakers / Headphones (Realtek ’ |
0 |
2 |
0.0900000000000000 |
0.180000000000000 |
0.0900000000000000 |
0.180000000000000 |
44100 |
8 |
13 |
‘Windows WASAPI’ |
‘Speakers (USB Sound Device )’ |
0 |
6 |
0 |
0 |
0.00300000000000000 |
0.0100000000000000 |
48000 |
9 |
13 |
‘Windows WASAPI’ |
‘Speakers / Headphones (Realtek High Definition Audio)’ |
0 |
2 |
0 |
0 |
0.00300000000000000 |
0.0100000000000000 |
48000 |
10 |
13 |
‘Windows WASAPI’ |
‘Line (USB Sound Device )’ |
2 |
0 |
0.00300000000000000 |
0.0100000000000000 |
0 |
0 |
44100 |
11 |
13 |
‘Windows WASAPI’ |
‘Stereo Mix (Realtek High Definition Audio)’ |
2 |
0 |
0.00300000000000000 |
0.0100000000000000 |
0 |
0 |
48000 |
12 |
13 |
‘Windows WASAPI’ |
‘Microphone (USB Sound Device )’ |
2 |
0 |
0.00300000000000000 |
0.0100000000000000 |
0 |
0 |
48000 |
13 |
13 |
‘Windows WASAPI’ |
‘SPDIF Interface (USB Sound Device )’ |
2 |
0 |
0.00300000000000000 |
0.0100000000000000 |
0 |
0 |
48000 |
14 |
11 |
‘Windows WDM-KS’ |
‘Speakers (USB Sound Device)’ |
0 |
8 |
0.0100000000000000 |
0.0853333333333333 |
0.0100000000000000 |
0.0853333333333333 |
44100 |
15 |
11 |
‘Windows WDM-KS’ |
‘Microphone (USB Sound Device)’ |
2 |
0 |
0.0100000000000000 |
0.0853333333333333 |
0.0100000000000000 |
0.0853333333333333 |
44100 |
16 |
11 |
‘Windows WDM-KS’ |
‘Line In (Realtek HD Audio Line input)’ |
2 |
0 |
0.0100000000000000 |
0.0400000000000000 |
0.0100000000000000 |
0.0400000000000000 |
44100 |
17 |
11 |
‘Windows WDM-KS’ |
‘Speakers (Realtek HD Audio output)’ |
0 |
2 |
0.0100000000000000 |
0.0400000000000000 |
0.0100000000000000 |
0.0400000000000000 |
44100 |
18 |
11 |
‘Windows WDM-KS’ |
‘Stereo Mix (Realtek HD Audio Stereo input)’ |
2 |
0 |
0.0100000000000000 |
0.0400000000000000 |
0.0100000000000000 |
0.0400000000000000 |
48000 |
19 |
11 |
‘Windows WDM-KS’ |
‘Microphone (Realtek HD Audio Mic input)’ |
2 |
0 |
0.0100000000000000 |
0.0400000000000000 |
0.0100000000000000 |
0.0400000000000000 |
44100 |
Any help would be very much appreciated (again!)
Thank you!
HDJ