I am trying to display audio at real time using, analoginput, this is the code:
function Cspe()
daq_object = analoginput('winsound');
chan = addchannel(daq_object,1);
num_samples=1000;
set(daq_object,'SamplesPerTrigger',inf,'SamplesAcquiredFcnCount',num_samples,...
'SamplesAcquiredFcn',{@up,num_samples});
if(strcmp(daq_object.running,'On'))
return;
else
start(daq_object);
end
end
function up(num_samples)
data=getdata(daq_object,num_samples);
a=[1:num_samples];
plot(a,data);
drawnow;
end
but it keeps on giving me errors saying Winsound is already in use. i am not so sure what the problem is?, i made sure that if the device is on/running, don't do anything.
I am not sure how to just add a comment (or if I am just not able to yet)so here is my 'answer':
I had a similar problem with a data acquisition board using windows 7. The way to usually get around this problem is making sure you run the program as an administrator.
In windows 7 to do this you simply right click on your shortcut and select 'Run as administrator' or change the advanced properties of the shortcut to run the program as an administrator.
If you are in windows XP, you may want to check to see if your user account has administrative privileges (i.e. check Control Panel > Users, or just try and write something to a system folder).
If these do not work, then another program is likely using the sound card, this has sometimes happened with certain audio suites for me, and was solved by exiting the programs (or uninstalling them, possibly).
I realize this is long after the question was posted, but maybe this will be useful to someone else!