startBackground function doesn't work all the time (for sound reproduction)
2 views (last 30 days)
Show older comments
I'm trying to play a sound through an external audio card, by using the script below. I am having trouble because sometimes it works, but most of the times it doesn't work and there is no sound. I checked each step and everything seems fine. There isn't any error message.
Is there something wrong? Conversely, if I use startForeground, the sound is playing, but I can't use it because I need to work on the Command Window during sound reproduction.
d = daq.getDevices; %to know the ID of the sound card
s = daq.createSession('directSound');
ID =d(1,4).ID; %selection of sound card's ID
addAudioOutputChannel(s,ID,1:2); %the sound has 2 channels
sound = audioread('sound_2channels.wav'); %sound file
queueOutputData(s,sound);
s
startBackground(s)
0 Comments
Answers (0)
See Also
Categories
Find more on Audio I/O and Waveform Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!