播放 .wav 文件 [英] playing a .wav file

查看:53
本文介绍了播放 .wav 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio 2010 express,我正在尝试编写一个简单的程序,该程序将重复波形文件 5 次(我正在运行 Windows xp sp3).

这是我得到的:

#include "stdafx.h"#include #include 使用命名空间标准;int主(){int a = 5;而(a >= 1){cout<<"这是一个 wav 文件";PlaySound(L"SomeAudioFile-01.wav", NULL, SND_FILENAME);- 一种;}返回0;}

问题是我在构建它时不断收到此错误消息:

<前>1>------ Build开始:项目:这是一个F**king国家,配置:发布Win32 - ----1> mycode.cpp1>..\..\..\..\..\Shaul's documents\Visual Studio 2010\Projects\MyProject\Release\SomeAudioFile-01.wav:致命错误 LNK1136:文件无效或损坏========== 构建:0 成功,1 失败,0 最新,0 跳过 ==========

该文件非常好,在 Visual Studio 之外播放没有任何问题.

非常感谢您的帮助.

解决方案

不是将 WAV 文件添加到项目文件中,而是将其添加到资源中并使用 SND_RESOURCE而不是 SND_FILENAME.

I'm using visual studio 2010 express and I'm trying to write a simple program that will repeat a wave file 5 times(I'm running a windows xp sp3).

This is as far as I got:

#include "stdafx.h"
#include <windows.h>
#include <iostream>

using namespace std;   
int main ()
{
    int a = 5;
        while(a >= 1){
            cout << "It's a wav file";
            PlaySound(L"SomeAudioFile-01.wav", NULL, SND_FILENAME);
            --a;
        }
    return 0;
 }

The problem is I keep getting this error message when I'm building it:

1>------ Build started: Project: It's a F**king Country, Configuration: Release Win32 --    ----
1>  mycode.cpp
1>..\..\..\..\..\Shaul's documents\Visual Studio 2010\Projects\MyProject\Release\SomeAudioFile-01.wav : fatal error LNK1136: invalid or corrupt file
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The file is perfectly fine and plays with no problems whatsoever outside visual studio.

Help would be truly appreciated.

解决方案

Instead of adding the WAV file to the project files, add it to the resources and use SND_RESOURCE instead of SND_FILENAME.

这篇关于播放 .wav 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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