# About PsychPortAudio open

**URL:** <https://psychtoolbox.discourse.group/t/about-psychportaudio-open/4548>\
**Category:** Programming Help\
**Tags:** windows\
**Created:** [July 19, 2022, 12:48pm UTC](https://psychtoolbox.discourse.group/t/about-psychportaudio-open/4548 "2022-07-19T12:48:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LyliyaGAO](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@LyliyaGAO](https://psychtoolbox.discourse.group/u/LyliyaGAO)\
**Post date:** [July 19, 2022, 12:48pm UTC](https://psychtoolbox.discourse.group/t/about-psychportaudio-open/4548/1 "2022-07-19T12:48:11Z")

</div>

Hi all.  
I am currently working with windows and Matlab2021b.

I want to use mode 3 for simultaneous capture and playback of sound.

This is my code:  
pahandle = PsychPortAudio(‘Open’, [20,19], 3, 0, 48000, [8, 8]);  
I want to use device 20 and 19 for playback and capture.

 ![屏幕截图 2022-07-19 204042](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/e21dc869729422ec97c12bfc2ed5e3b94b3390ba.png)

And this is the error:  
Error in function Open: Wrong size argument supplied  
Discrepancy between a specified and supplied argument:  
Specified Argument Description:  
direction: Input  
position: 1  
presence:  
formats allowed:  
double  
minimum M: 1  
maximum M: 1  
minimum N: 1  
maximum N: 1  
minimum P: 1  
maximum P: 1  
Provided Argument Description:  
direction: Input  
position: 1  
presence: present  
format: double  
number of dimensions: 2  
M: 1  
N: 2  
P: 1

I think the problem is with “deviceid”,but I don’t know how to correct it.Could you tell me what is the right syntax?Thank you very much!

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [July 20, 2022, 4:04pm UTC](https://psychtoolbox.discourse.group/t/about-psychportaudio-open/4548/2 "2022-07-20T16:04:08Z")

</div>

Yes, ‘deviceid’ - if specified - must be one device index in the current PsychPortAudio implementation, so unless the same deviceid number refers to a device that can both playback and capture, you can’t use full-duplex on one PsychPortAudio handle, but you’d need to ‘Open’ two separate devices, one only for capture, one only for playback. Cfe. DelayedSoundFeedbackDemo.m.

In your case, given the device list, you can’t do full-duplex as no deviceId has both non-zero NrInputChannels and non-zero NrOutputChannels.

Also, as you are trying to choose a WDM-KS device, I have to warn you that the underlying libportaudio library dll for MS-Windows does not implement any audio timestamping at all for WDM-KS, only for MME (which has very high latency and inaccurate timestamps) or WASAPI. Any `PsychPortAudio('Start', ...` call with a non-zero start time would hang, other time-based scheduling functions or stop functions or timestamp related/dependent functions would hang. Iow. Use of WDM-KS is only good for very few basic use cases atm.

-mario
