Changing code to work with new Data Acquisition Toolbox

10 ビュー (過去 30 日間)
Lisa Masipa
Lisa Masipa 2020 年 10 月 23 日
コメント済み: Lisa Masipa 2020 年 10 月 23 日
I have been trying to change this code to work with the current version of the DAQ Toolbox but am unable to do it correctly. If anyone is able to help please make some suggestions.
ai = analoginput('winsound'); % create AI object
addchannel(ai,1); % single channel (mono)
Fs = setverify(ai,'samplerate',44100); % sample rate (Hz)
N = 2^ceil(log2(Tmax*Fs)); % buffer size (samples)
ao = analogoutput('winsound'); % create AO object
addchannel(ao,1); % single channel (mono)
ao.SampleRate=Fs; % output Fs same as input

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 10 月 23 日
winsound drivers are not supported anymore. However with new enough releases, DirectSound is supported
  3 件のコメント
Walter Roberson
Walter Roberson 2020 年 10 月 23 日
ai = daq("directsound");
ai.Rate = 44100;
chi = addinput(ai,"Audio1",1,"Audio");
ao = daq("directsound");
ai.Rate = 44100;
cho = addoutput(ao,"Audio1",1,"Audio");
At the moment I am not certain if you can create two different sessions to directsound. You might need to instead use a single daq and addinput and addoutput to the one daq -- but if so then you might need to use the operations to read and write simultaneously.
This assumes that you have Good Reason to have used winsound and want the closest equivalent directsound . But if you do not have Good Reason and just wanted to do audio input and output on a Windows machine, then I would recommend that you switch away from using DAQ into using Audio System Toolbox
Lisa Masipa
Lisa Masipa 2020 年 10 月 23 日
I'll give this a try thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMultichannel Audio Input and Output についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by