Mitch's picture

Unable to load 'alut.dll' error

I downloaded OpenTK and wrote a simple piece of software to play audio files using the OpenTK.Audio namespace.

All compiled but didn't run, turned out I was missing the alut.dll. I put that next to my .exe and all works great.

BUT if I take it to any other machine it doesn't work. The debugger tells me "Unable to load 'alut.dll' " and this is coming from the OpenTK.Audio.Alut.Init() method.

BUT alut.dll is right there next to my .exe.

On main developement machine I have obviously installed OpenTK. But on other machines I have my .exe, OpenTK.dll and alut.dll all sitting next to each other.

What should I do?

Thanks for any help,
Mitch.

[Moderator edit: changed title to something more descriptive.]


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Ok, you'll need to provide some more info: which operating system, which .Net version, 32-bit or 64-bit?

Also, OpenTK provides the AudioContext class, which replicates Alut.Init (just create an AudioContext instead). This will be easier to use, because you won't have to distribute alut.dll along with your program.

Mitch's picture

Hi,

thanks for your reply, sorry about delay in my replying - weekend and all.

Are there any examples of how I should use the AudioContext class. I can't get it working - all compiles and runs but no sounds happening.

My code so far is really tiny so it may help to see it:

I have a Class with the following three small methods:

In constructor I just have:

Alut.Init();

And then I have two methods, AddSound and PlaySound as follows (m_soundBuffers is a member of the class declared as List m_soundBuffers = new List();)

public void AddSound(string szFilePathName)
{
int nSoundIndex = m_soundBuffers.Count;

m_soundBuffers.Add(new int[1]);

m_soundBuffers[nSoundIndex] = AL.GenBuffers(1);

m_soundBuffers[nSoundIndex][0] = (int)Alut.CreateBufferFromFile(szFilePathName);

if (AL.GetError() != ALError.NoError)
{
MessageBox.Show("Unable to add sound " + szFilePathName);
}
}

public void PlaySound(int nSound)
{
int[] source = new int[1];
source = AL.GenSources(1);

AL.Source(source[0], ALSourcei.Buffer, m_soundBuffers[nSound][0]);

AL.SourcePlay(source[0]);
}

All works fine. Now I need to replace with AudioContext instead of using Alut.Init() and Alut.CreateBufferFromFile but how?

I tried having a member varibale of type AudioContext, and in the constuctor I had m_audioContext = new AudioContext() etc. And in the AL namespace I can't find a method for replacing Alut.CreateBufferFromFile

Thanks for any help,
Mitch.

the Fiddler's picture

OpenTK.Utilities provides an AudioReader class that replaces Alut.CreateBufferFromFile. There is an example using this class under Source/Examples/OpenAL/ (or you can view the code online here).

It's true that the documentation on OpenTK.Audio is a little lacking right now.

Mitch's picture

Thanks so much for your help.

I've got it working now. The code is really simple to use, very clear.

Basically on SourceForge I had downloaded the .zip version of the file, not the .7z

The former contained version 0.9.4 which had no OpenTK.Utilities. (I downloaded the former three days ago, maybe they are both the same now, I didn't check).

The only new feature now is that when I play some wav files I get a click at the end where I used not to (using alut.dll).
(e.g. C:\Windows\Media\Ding.wav).

Is this a known problem or could I be doing something wrong?

Is there a way to get the number of samples in an AudioReader object?

Right now I call:

AL.BufferData(m_soundBuffers[nSoundIndex], sound.ReadSamples(ReadToEnd());

whereas, in the case of Ding.wav if I call:

AL.BufferData(m_soundBuffers[nSoundIndex], sound.ReadSamples(80000));

I avoid the click at the end.

Thanks for any advice,
Mitch.

the Fiddler's picture

The clicking issue sounds like a bug - please open a bug report so it doesn't get lost.

By the way, the zip and 7z packages are identical (but for size). I was afraid for a moment that I made a mistake while creating the release, but both contain OpenTK.Utilities as they should (note that OpenTK.Utilities is unchanged between 0.9.4 and 0.9.5).

Mitch's picture

Ok I will.

I also found that there are some .wav files that won't play at all.

My code plays most fine but for instance:

C:\Windows\Media\Start.wav causes a NotSupportedException "Could not find a decoder for the specified sound stream.".

Finally, and this is most definately my ignorance, I am unable to run my app on machines other than my developement machine.

Initially it complained that OpenAL32.dll was not present, so I put this next to me .exe and then I get an AudioDeviceException:

"Audio device "default" does not exist or is tied up by another application" - this is occuring in my new AudioContext() call, at OpenTK.Audio.AudioContext.CreateContext(.....

I am obviously being really stupid about something obvious here.

Sorry for all the posts, thanks for all the help,
Mitch.

the Fiddler's picture

Did you download OpenAL from Creative's website? If so, you cannot just copy the openal32.dll, you have to use the installer on the other machines.

The other solution is to compile and distribute OpenAL Soft (its openal32.dll does not need an installer).

Mitch's picture

Okay,

Thanks.

installation of OpenAL solves it.

Having truble building OpenAL Soft's dll (using CMake and Visual Studio 2008) don't suppose you know of a direct download link to the OpenAL Soft windows dll? Or some good instructions for building it on windows?

Thanks,
Mitch.

martinsm's picture

Just follow instructions on OpenAL soft home page. Run cmake -G "Visual Studio 9 2008" .. , and then build solution. Make sure you have dsound.h/lib files available, because it is required for backend under Windows.

objarni's picture

It would be a great resource for the OpenTK community if there would be somewhere to find the binaries for the OpenAL soft library.

Not everyone feels the urge to d/l VC++ and compile stuff. And think of the wasted cpu cycles for such a procedure! If there are N developers wanting to use OpenAL, there are N times as many compilations performed compared to having precompiled binaries. :)

Just a thought. Any volunteers?