recroding sound reqlatencyclass setting

Hello,

I have been trying to record audio using PsychPortAudio. But unless I set reqlatencyclass to 0, the recorded sound is empty. Or rather, the recorded sound is the expected length but nothing can be heard (when played back via PTB or saved and played outside of matlab). I am worried about saying "do not care about latency at all" in my experiment though! So I would like to find a workaround. Alternatively could you tell me when this setting is going to introduce latency? At the point when the recording begins? Or there is no way to know?


My set-up is the following:
Windows 7 (run on a Dell Optiplex 7020)
Realtek high Definition Audio

Matlab R2015a

PTB 3.0.12

Microphone audiotechnica AT2005 USB, plugged through a mixing board XENYX 802


Here is the snippet of code I've been using:

numchan = 1;
freq = 44100;

reqlatencyclass = 0;


InitializePsychSound;

pahandle = PsychPortAudio('Open', [], 2, reqlatencyclass, freq, numchan);
PsychPortAudio('GetAudioData', pahandle, 10);

disp('Start speaking')
PsychPortAudio('Start', pahandle, 0, 0, 1);
WaitSecs(3);
PsychPortAudio('Stop', pahandle);

audiodata = PsychPortAudio('GetAudioData', pahandle);
PsychPortAudio('Close', pahandle);



I would appreciate any help!

Thank you,

Svetlana


XXXIn PSYCHTOOLBOX@yahoogroups.com, <lufglvdhtllbq3hr2ioy4ggi4xlroht2suz5glqa@...> wrote :

Hello,

I have been trying to record audio using PsychPortAudio. But unless I set reqlatencyclass to 0, the recorded sound is empty. Or rather, the recorded sound is the expected length but nothing can be heard (when played back via PTB or saved and played outside of matlab). I am worried about saying "do not care about latency at all" in my experiment though! So I would like to find a workaround. Alternatively could you tell me when this setting is going to introduce latency? At the point when the recording begins? Or there is no way to know?

-> class 0 would probably use the Windows MME sound system for recording, whereas non-zero would choose DirectSound if you don't have a proper ASIO sound card in your machine. MME has gigantic latencies in the multi-hundred msecs range, whereas DirectSound only has big latencies in the dozens of msecs range if it works reliably at all. There are not guarantees wrt. timing, but essentially start of recording is uncertain to dozens or hundreds of msecs, timestamps are uncertain the same way, and sound will be received with the same size of delay wrt. to the real event. You should get a professional ASIO sound card if you care about timing at all. Or ASIO4ALL as a free fake ASIO, which is not the real thing, and nothing is guaranteed, and no support is provided if you run into trouble, but it is often less worse than what Windows builtin drivers have to offer.

The cheapest way to get very reliable and precise sound capture with most sound cards, even cheap builtin ones, is to simply use Linux instead of Windows.

-mario

My set-up is the following:
Windows 7 (run on a Dell Optiplex 7020)
Realtek high Definition Audio

Matlab R2015a

PTB 3.0.12

Microphone audiotechnica AT2005 USB, plugged through a mixing board XENYX 802


Here is the snippet of code I've been using:

numchan = 1;
freq = 44100;

reqlatencyclass = 0;


InitializePsychSound;

pahandle = PsychPortAudio('Open', [], 2, reqlatencyclass, freq, numchan);
PsychPortAudio('GetAudioData', pahandle, 10);

disp('Start speaking')
PsychPortAudio('Start', pahandle, 0, 0, 1);
WaitSecs(3);
PsychPortAudio('Stop', pahandle);

audiodata = PsychPortAudio('GetAudioData', pahandle);
PsychPortAudio('Close', pahandle);



I would appreciate any help!

Thank you,

Svetlana


<spinet1@...> wrote :

Hi Mario,

 

Thank you for your answer! I am considering switching to Linux but I am not the only one using that computer for experiments so the decision is not fully mine.


-> You can also install Linux on a second harddisc drive, or even on an external USB disc drive, so if other people want to stick to Windows, that isn't a problem.


I have ASIO4all installed already.

 

I have done some further testing. When I try to open specifically the ASIO device and use it for recording, the recorded data matrix is empty (whatever the reqlatencyclass setting I use).

 

pahandle = PsychPortAudio('Open', 8, 2, 3, 44100, 1);

 

>> PTB-INFO: Using specially modified PortAudio engine, based on offical version: PortAudio V19-devel WITH-DIM

PTB-INFO: New audio device with handle 0 opened as PortAudio stream:

PTB-INFO: For 1 channels Capture: Audio subsystem is ASIO, Audio device name is ASIO4ALL v2

PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 10.068027 msecs, Output latency 10.068027 msecs.

 

 

The default device used for reqlatencyclass = 0 is indeed MNE, Microsoft Sound Mapper - Input. If I open specifically this one, it does record something for any reqlatencyclass, and I can get the input latency down to 116ms for reqlatencyclass

>=1.


-> Note that if you don't use a native ASIO card on Windows, none of the timing information is guaranteed to be correct. Just because it says 116 msecs doesn't mean it is even close to that. 



pahandle = PsychPortAudio('Open', 0, 2, 3, 44100, 1);

 

>> PTB-INFO: Using specially modified PortAudio engine, based on offical version: PortAudio V19-devel WITH-DIM

PTB-INFO: New audio device with handle 0 opened as PortAudio stream:

PTB-INFO: For 1 channels Capture: Audio subsystem is MME, Audio device name is Microsoft Sound Mapper - Input

PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 116.099773 msecs, Output latency 0.000000 msecs.

 

 

 

However, the ASIO device works perfectly well for playback.

 

pahandle = PsychPortAudio('Open', 8, 1, 0, 44100, 1);

 

>> PTB-INFO: Using specially modified PortAudio engine, based on offical version: PortAudio V19-devel WITH-DIM

PTB-INFO: New audio device with handle 0 opened as PortAudio stream:

PTB-INFO: For 1 channels Playback: Audio subsystem is ASIO, Audio device name is ASIO4ALL v2

PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 39.818594 msecs, Output latency 39.818594 msecs.

 

 

Is there any reason the ASIO device would not be able to access the microphone to record?


-> Apparently yes ;-). But you'd have to ask the makers of ASIO4ALL about that and any advice related to it. It's not the "real thing" just an emulation, it is not guaranteed to work well with any specific sound card or device driver. In general sound capture with properly configured real ASIO cards works as well as it can on Windows.


If I use MNE, is the sound recording going to be distorded or is it just going to impact the start of recording?


-> I don't know. Does it sound distorted?

 

I will try to convince my colleagues to at least get an ASIO sound card if I can't convince them to switch to Linux. ;-)

 

-> Those are the only two good options. Everything else is up to luck.


Good luck,

-mario


Thanks for your help,

Svetlana

So, we're getting an ASIO sound card! Christmas in August!!

Is ASIO-enabled the only criteria I should care about? Would you have more specific recommendations? I can't find any on the PTB website or forum.

Thanks,
Svetlana