1

I'm trying to play a wav file from a .NET Core console application (No, I'm not using the console beep. Weird requirements, I know.). I figured I could do that using OpenAL. I'm able to read the file in fine, but then when I try to play it, it fails on the first line:

int handle = AL.GenBuffer();

I get the exception: InvalidOperationException: Could not load openal32.dll. I'm using the OpenTK.NETCore NuGet package. Am I missing something?

tyjkenn
  • 709
  • 10
  • 25

2 Answers2

1

I figured it out. It turns out the OpenTK.NETCore package doesn't come with OpenAL, just the SDK. Instead, it looks for it already installed on the machine. I used the installer, and imagine I'll need to install it on every machine that uses my application

tyjkenn
  • 709
  • 10
  • 25
-1

Not using OpenAL, but an alternative solution to play wav files in a console application can be found here:

Playing sounds on Console - C#

After adding the sound file to your solution the suggested code in the link is:

using System.Reflection;
using System.IO;
using System.Resources;
using System.Media;
using System.Diagnostics;



namespace Yournamespace
{
public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
    }

    private void Form2_Load(object sender, EventArgs e)
    {
        Assembly assembly;
        Stream soundStream;
        SoundPlayer sp;
        assembly = Assembly.GetExecutingAssembly();
        sp = new SoundPlayer(assembly.GetManifestResourceStream
            ("Yournamespace.Dreamer.wav"));
        sp.Play();  
    } 
}
}
0liveradam8
  • 752
  • 4
  • 18