模拟输入,从 matlab 开始

发布于 2024-11-25 19:39:57 字数 609 浏览 7 评论 0原文

我正在尝试使用模拟输入实时显示音频,这是代码:

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

但它不断给我错误,说 Winsound 已在使用中。我不太确定问题是什么?,我确保如果设备已打开/正在运行,则不要执行任何操作。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗弃M 2024-12-02 19:39:57

我不知道如何添加评论(或者如果我还不能),所以这是我的“答案”:

我在使用 Windows 7 的数据采集板中遇到了类似的问题。通常解决这个问题的方法问题是确保您以管理员身份运行该程序。

在 Windows 7 中,要执行此操作,您只需右键单击快捷方式并选择“以管理员身份运行”或更改快捷方式的高级属性以以管理员身份运行程序。

如果您使用的是 Windows XP,您可能需要检查您的用户帐户是否具有管理权限(即检查“控制面板”>“用户”,或者只是尝试向系统文件夹写入一些内容)。

如果这些不起作用,则另一个程序可能正在使用声卡,对于我来说,某些音频套件有时会发生这种情况,并通过退出程序(或可能卸载它们)来解决。

我意识到问题发布很久之后,但这也许对其他人有用!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文