startBackground function doesn't work all the time (for sound reproduction)
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!