解决方案 »

  1.   

    我还尝试过把wav文件放在debug下,也尝试过导入到项目里面,但都不行。
    附上源码
    在Visual Studio里面创建Windows应用程序,把相关的DLL复制到bin\debug下,在添加相关引用,再在输入以下内容:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Tao.OpenAl;
    using System.IO;namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();            //String path = @".\Sounds\soundeffect1.wav";
                String path = "soundeffect1.wav";
                Alut.alutInit();
                int buffer = -1;
                Al.alGenBuffers(1, out buffer);            int errorCode = Al.alGetError();
                System.Diagnostics.Debug.Assert(errorCode == Al.AL_NO_ERROR);            int format;
                float frequency;
                int size;
    //报错的地方
                System.Diagnostics.Debug.Assert(File.Exists(path));
                IntPtr data = Alut.alutLoadMemoryFromFile(path, out format, out size, out frequency);
                System.Diagnostics.Debug.Assert(data != IntPtr.Zero);
                // Load wav data into the generated buffer.
                Al.alBufferData(buffer, format, data, size, (int)frequency);
            }
        }
    }
      

  2.   

    你是不是在学习《精通C#游戏编程》?我和你遇到了一样的问题,建议你去看一下这个吧:解决OpenAL里调用Alut.alutLoadMemoryFromFile出错http://bbs.csdn.net/topics/390679635