C ++中的声音(波形) [英] Sounds (wavs) in C++

查看:85
本文介绍了C ++中的声音(波形)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2010 for C ++
我需要使用SoundPlayer为我的C ++程序播放音效.声音效果称为Help.wav.这是一个资源文件.该文件位于资源文件中名为"sounds"的文件夹中.

我已经输入了:

I am using Visual Studio 2010 for C++
I need to play a soundeffect for my C++ program with SoundPlayer. The sound effect is called Help.wav. It is a RESOURCE FILE. The file is in a folder called ''sounds'' within the resource files.

I have already typed:

using namespace System::Media;
SoundPlayer^ player = gcnew SoundPlayer();
player->SoundLocation =;
player->Load();
player->Play();



我在查找"player-> SoundLocation =;"的输入时遇到麻烦线.
任何帮助将不胜感激.



I am having trouble finding out what to type for the "player->SoundLocation =;" Line.
Any help would be appreciated.

推荐答案

请参阅:
http://msdn.microsoft.com/en-us/library/system.media. soundplayer.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. media.soundplayer.soundlocation.aspx [ ^ ].

第一篇文章包含更高级的代码示例,您需要了解才能使用此类编写任何内容.



抱歉,我没有注意您的麻烦:这是一种资源. (并且请不要在我因缺少信息而指责您的情况下忽略我的评论;对不起.)资源并非完全是文件,但是您可以将资源用作流.在这种情况下,您根本不需要使用位置.您需要使用其他构造函数:
http://msdn.microsoft.com/en-us/library/ms143770.aspx [ ^ ].

对于构造函数参数,可以使用资源流.请参阅有关如何获取资源流的讨论:
> http://stackoverflow.com/questions/1388052/resource-from-assembly-as-流 [ ^ ].

—SA
Please see:
http://msdn.microsoft.com/en-us/library/system.media.soundplayer.aspx[^],
http://msdn.microsoft.com/en-us/library/system.media.soundplayer.soundlocation.aspx[^].

First article contains more advanced code sample you need to understand to write anything with this class.



Sorry, I did not pay attention for your complication: this is a resource. (And please disregard my comment where I blamed you for missing information; I apologize.) Resource is not exactly a file, but you can use the resource as stream. In this case, you don''t need to use location at all. You need to use a different constructor:
http://msdn.microsoft.com/en-us/library/ms143770.aspx[^].

For a constructor parameter, you can use a resource stream. Please see this discussion on how to obtain a resource stream:
http://stackoverflow.com/questions/1388052/resource-from-assembly-as-a-stream[^].

—SA


这篇关于C ++中的声音(波形)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆