Could anyone has any idea how i could access both channels of sound card at the same time .
Thank you
access both channels of sound card at at the same time
set(ao,'SamplesOutputFcnCount',0.9*datasize);
%%Create ANALOGOUTPUT device and add 1 channel to it (mono)
ao=analogoutput('winsound',0);addchannel(ao,1);%%Configure Analog Output
set(ao, 'BufferingMode', 'Auto')set(ao,'TriggerType','Immediate');%Define output samples per second as necessary
set(ao,'SampleRate',fs);%%configure callback to quuee another chunk of data
% set(ao,'SamplesOutputFcn',{'qmoredata',data});
% set(ao,'SamplesOutputFcnCount',bufsize);
% Use a TimerFcn to queue the next chunk of data
set(ao,'TimerFcn',{'qmoredataForTimerFcn',data});% Set the Timer to fire when 90% of the buffer has been output
set(ao,'TimerPeriod',(bufsize/ao.SampleRate)*0.9);%run the machine
putdata(ao,data);start(ao)% Examine how much data is in the queue.
for ii=1:100 ao.SamplesAvailable pause(1)endstop(ao)% Delete ANALOGOUTPUT object when you are done
delete(ao)clear ao
function qmoredataForTimerFcn(obj,event,data) % We would like to make sure we are not going to over run the buffer
% If we do, the PUDATA function become a blocking function
% That is, we will no longer have access to the command line
% Use any ONE of the next two IF statements.
% This one guarantees that we will never get more than twice the amount
% of data we have to queue.
% if (obj.SamplesAvailable + length(data)) >= length(data)*2
% This one will continue to add to the queue until adding more would
% cause PUTDATA to block.
if (obj.SamplesAvailable + length(data)) >= obj.MaxSamplesQueued return end % Else, It is safe to put the data.
putdata(obj,data); % Restart the object only if it is not already running.
if strcmp(obj.Running, 'Off') start(obj) end end
Best Answer