如何在Dev-C++中访问声音硬件?

发布于 2025-01-27 10:52:04 字数 2312 浏览 5 评论 0原文

我正在关注一个视频教程,该教程在 c ++ 中:

https://www.youtube.com/watch?v=tgamhuqnokm&amm& t = 1030s

我正在使用 dev-c ++ ,我在标题文件中遇到一个错误,“ i” “我不应该担心“

这条线是:

auto d = std::find(devices.begin(), devices.end(), sOutputDevice);

错误说:

>92 68  C:\Users\benna\Documents\Starting Over\wave_music\olcNoiseMaker.h   [Error] no matching function for call to 'find(std::vector<std::basic_string<wchar_t> >::iterator, std::vector<std::basic_string<wchar_t> >::iterator, std::wstring&)'

我在这里是个菜鸟,我真的不明白。

我的代码是一样的,我已经查看了链接器项目设置和其他 /strong>),没有任何改变。 (尤其是其他IDE,我什至无法让他们运行“ Hello World”。)

我只是以为我可以通过一些实验来学到一些东西,但我一无所获。我的软件是问题吗?

我认为访问我的声音硬件可能是一个问题。

我仍在学习,所以任何帮助都将不胜感激,谢谢!

标题文件在这里: https://github.com/github.com/Onelonecoder/onelonecoder/synth/synth/synth/synth/blob/master/master/olcnoisemememaker一下。 h

我的主要文件是:

using namespace std;

#include "olcNoiseMaker.h"

atomic<double> dFrequencyOutput = 0.0;


double MakeNoise(double dTime)
{
    return 0.5 * sin(440.0 * 2 * 3.14159 * dTime);
    //double dOutput 1.0* sin(dFrequencyOutput * 2.0 * 3.14159 * dTime);
    
    //return dOutput * 0.5;
    
    //if (dOutput > 0.0)
    //  return 0.2;
    //else
    //  return -0.2;
    
}

int main()
{
    wcout << "onelonecoder.com - Synthesizer Part 1" << endl;
    
    // Get all sound hardware
    vector<wstring> devices = olcNoiseMaker<short>::Enumerate();
    
    // Display findings
    for (auto d : devices) wcout << "Found Output Device:" << d << endl;
    
    // Create sound machine!!
    olcNoiseMaker<short> sound(devices[0], 44100, 1, 8, 512);
    
    // Link make noise function with sound machine
    sound.SetUserFunction(MakeNoise);
    
    
    while (1)
    {
        
    }
    
    return 0;
}

I was following a video tutorial for playing music in c++:

https://www.youtube.com/watch?v=tgamhuQnOkM&t=1030s

I am using Dev-C++ and I keep getting an error in the header file that "I'm not supposed to worry about"

The line is:

auto d = std::find(devices.begin(), devices.end(), sOutputDevice);

And the error says:

>92 68  C:\Users\benna\Documents\Starting Over\wave_music\olcNoiseMaker.h   [Error] no matching function for call to 'find(std::vector<std::basic_string<wchar_t> >::iterator, std::vector<std::basic_string<wchar_t> >::iterator, std::wstring&)'

I am a noob here and I really don't get it.

My code is the same, and I've looked at linkers, project settings and other IDEs (VS Code & Eclipse) and nothing changes. (Especially the other IDEs, I can't even get them to run "Hello World".)

I just thought I could learn something through a little experimentation but I am getting nowhere. Is it a problem with my software?

I think it may be a problem with accessing my sound hardware.

I am still learning so any help would be appreciated, thank you!

The header file is here:
https://github.com/OneLoneCoder/synth/blob/master/olcNoiseMaker.h

And my main file is this:

using namespace std;

#include "olcNoiseMaker.h"

atomic<double> dFrequencyOutput = 0.0;


double MakeNoise(double dTime)
{
    return 0.5 * sin(440.0 * 2 * 3.14159 * dTime);
    //double dOutput 1.0* sin(dFrequencyOutput * 2.0 * 3.14159 * dTime);
    
    //return dOutput * 0.5;
    
    //if (dOutput > 0.0)
    //  return 0.2;
    //else
    //  return -0.2;
    
}

int main()
{
    wcout << "onelonecoder.com - Synthesizer Part 1" << endl;
    
    // Get all sound hardware
    vector<wstring> devices = olcNoiseMaker<short>::Enumerate();
    
    // Display findings
    for (auto d : devices) wcout << "Found Output Device:" << d << endl;
    
    // Create sound machine!!
    olcNoiseMaker<short> sound(devices[0], 44100, 1, 8, 512);
    
    // Link make noise function with sound machine
    sound.SetUserFunction(MakeNoise);
    
    
    while (1)
    {
        
    }
    
    return 0;
}

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

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

发布评论

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

评论(1

毁虫ゝ 2025-02-03 10:52:04

这是链接标头文件中的错误。它应该包括&lt; algorithm&gt;,它是std :: find所需的,但没有。


我尚未检查其余的标头文件或您已发布的错误代码,但我还注意到

while (1)
{
    
}

没有IO,原子,波动或同步操作的无限循环在C ++中具有未定义的行为。您不能使用这样的循环无限地暂停程序或线程。


标头似乎在多个不同的环境中进行了很好的测试。例如,这个问题提到了类似的问题,可以在mingw下工作,并且有一个列表更改用户需要进行的更改。

This is a bug in the linked header file. It should include <algorithm> which is required for std::find, but doesn't.


I haven't checked the rest of the header file or your posted code for bugs, but I also noticed

while (1)
{
    
}

Infinite loops without IO, atomic, volatile or synchronization operations have undefined behavior in C++. You can't use such a loop to infinitely pause the program or thread.


The header seems to not be tested well in multiple different environments. For example this issue mentions similar problems to get it working under MinGW and has a list of changes that user needed to make.

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