Inertia's picture

OpenAL Device Choices

I've recently bought a Creative Labs Soundblaster X-Fi Platinum Fatal1ty Champion Series (TM)(C)(R) card (hope I did not forget any buzzwords) and getting the impression that it finally works as it should, but AudioContext is giving me some troubles porting the old Alut code. (I want to confirm that OpenTK's X-Ram class works as advertised by me :P)

The card did not ship with a driver CD, I've installed latest drivers and oalinst right from creative labs website.

My impression is that AudioContext uses the wrong tokens to select it's device, here's c&p from some AlcGetString queries.

Mind the "Detected by OpenTK" is simply what AudioContext.AvailableDevices returns. Also I have nothing connected to the SPDIF Out, so it's correctly recognizing Speakers to use for output.

Using Creative Labs driver (result identical for x32 and x64):

Quote:

Detected by OpenTK:
Generic Software
Returned by AlcGetString.DefaultDeviceSpecifier:
Generic Software
Returned by AlcGetString.DefaultAllDevicesSpecifier:
Generic Software on Speakers (Creative SB X-Fi)
Returned by AlcGetStringList.DeviceSpecifier:
Generic Software
Returned by AlcGetStringList.AllDevicesSpecifier:
Generic Software on Speakers (Creative SB X-Fi)
Generic Software on SPDIF Out (Creative SB X-Fi)

using OpenAL Soft drivers (copied to app dir, result identical for x32 and x64)

Quote:

Detected by OpenTK:
DirectSound Software
Wave File Writer
Returned by AlcGetString.DefaultDeviceSpecifier:
DirectSound Software
Returned by AlcGetString.DefaultAllDevicesSpecifier:
DirectSound Software on Speakers (Creative SB X-Fi)
Returned by AlcGetStringList.DeviceSpecifier:
DirectSound Software
Wave File Writer
Returned by AlcGetStringList.AllDevicesSpecifier:
DirectSound Software on Speakers (Creative SB X-Fi)
DirectSound Software on SPDIF Out (Creative SB X-Fi)
Wave File Writer

------------------------------------------------

However when I run the EfxEnumerateWin32.exe from the OpenAL SDK I get these device choices:

Quote:

Enumerate EFX Application

Select OpenAL Device:
1. SB X-Fi Audio [E800](DEFAULT)
2. Generic Software

Running EfxEnumerateWin64.exe gives:

Quote:

Enumerate EFX Application

Select OpenAL Device:
1. Generic Software(DEFAULT)

---------------------------------------------

Running openal-info.exe (with OpenAL Soft in it's dir) returns

Available playback devices:
    DirectSound Software on Speakers (Creative SB X-Fi)
    DirectSound Software on SPDIF Out (Creative SB X-Fi)
    Wave File Writer
Available capture devices:
    WaveIn on Line-In 2/Mic 2 (Creative SB X-
    WaveIn on Digital-In (Creative SB X-Fi)
    WaveIn on S/PDIF-In (Creative SB X-Fi)
    WaveIn on Auxiliary (Creative SB X-Fi)
    WaveIn on Microphone (Creative SB X-Fi)
    WaveIn on Auxiliary 2 (Creative SB X-Fi)
    WaveIn on Line-In (Creative SB X-Fi)
Default device: DirectSound Software
Default capture device: WaveIn on Line-In 2/Mic 2 (Creative SB X-
ALC version: 1.1
ALC extensions:
    ALC_ENUMERATE_ALL_EXT, ALC_ENUMERATION_EXT, ALC_EXT_CAPTURE, ALC_EXT_EFX
OpenAL vendor string: OpenAL Community
OpenAL renderer string: OpenAL Soft
OpenAL version string: 1.1 ALSOFT 1.8.466
OpenAL extensions:
    AL_EXTX_buffer_sub_data, AL_EXT_EXPONENT_DISTANCE, AL_EXT_FLOAT32,
    AL_EXT_IMA4, AL_EXT_LINEAR_DISTANCE, AL_EXT_MCFORMATS, AL_EXT_OFFSET,
    AL_EXTX_source_distance_model, AL_LOKI_quadriphonic
EFX version: 1.0
Max auxiliary sends: 2
Available filters:
    Low-pass
Available effects:
    EAX Reverb
    Reverb
    Echo

Running openal-info.exe without OpenAL Soft returns:

Available playback devices:
    SB X-Fi Audio [E800]
    Generic Software on Speakers (Creative SB X-Fi)
    Generic Software on SPDIF Out (Creative SB X-Fi)
Available capture devices:
    Line-In 2/Mic 2 (Creative SB X-
    Digital-In (Creative SB X-Fi)
    S/PDIF-In (Creative SB X-Fi)
    Auxiliary (Creative SB X-Fi)
    Microphone (Creative SB X-Fi)
    Auxiliary 2 (Creative SB X-Fi)
    Line-In (Creative SB X-Fi)
Default device: SB X-Fi Audio [E800]
Default capture device: Line-In 2/Mic 2 (Creative SB X-
ALC version: 1.1
ALC extensions:
    None
OpenAL vendor string: Creative Labs Inc.
OpenAL renderer string: SB X-Fi Audio [E800]
OpenAL version string: OpenAL version 1.1
OpenAL extensions:
    EAX
EAX1.0
EAX2.0
EAX3.0
EAX4.0
EAX5.0
 
EFX version: 1.0
Max auxiliary sends: 2
Available filters:
    Low-pass
Available effects:
    EAX Reverb
    Reverb
    Chorus
    Distortion
    Echo
    Flanger
    Frequency Shifter
    Vocal Morpher
    Pitch Shifter
    Ring Modulator
    Autowah
    Compressor
    Equalizer

openal-info is most likely an x86 app (came with the OpenAL Soft x86 driver), could it be that my x64 driver is simply broken?

I kinda miss the "Generic Hardware" device, which is probably the "SB X-Fi Audio [E800]". (mind the device name is identical to "OpenAL renderer string: SB X-Fi Audio [E800]" returned by openal-info)

Either way I think AudioContext should use AlcGetString.DefaultAllDevicesSpecifier to select the default device. With both drivers it selects the most appropriate device.

Edit: Could it be that the problem is related to either a) the disabled onboard sound or b) the graphic card's HDMI out? Another solution might be http://icculus.org/alextreg/wiki/ALC_ENUMERATE_ALL_EXT currently AudioContext uses ALC_ENUMERATE_EXT only.


Comments

Comment viewing options

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

AudioCapture it is.

[enumeration]
I've created a branch like you suggested, stripped off all GL/CL/Input/Platform stuff so it builds fast ;) I forgot to add in the description that it's based on 0.9.9 though, but I believe this is not a problem since not much happend to OpenTK.Audio in previous releases.

Don't bother read it yet though, it's quite a mess. Just wanted to back it up before moving the device detection into the new class. I'll take your advice and move the static stuff into AudioDeviceEnumerator class.

[error checking]
Agreed, it is absolutely necessary to throw for errors at device initialization. But during "normal" program operation no AL or Alc Error should occur (or potential exceptions requiring try/catch), it's the programmers responsibility to query device capabilities at initialization time and chose an appropriate codepath that will execute error-free (just like for GL).

Btw. is it ok if I use AudioDeviceException for AudioCapture too? Or rather create new ones?

[DeviceUnplugged]
This would be quite interesting to have, I will take a look where exactly the alc error occurs when unplugging the mic (once it works). Since the user will regularly use the AvailableSamples property and the GetSamples method (and I think that's where Alc errors related to unplugged devices will occur) it should be doable to use an event. Detecting when a device is plugged in again will be trickier but should be doable aswell.

[hardware]
It's an PCI card, all PCIe slots are covered by the graphics card and no card would possibly fit in there without a saw, hammer and alot of brute force. The compatibility problems appear to be related to the mainboard's chipset (according to creative labs forums), but the drivers also have alot more tweaking options than the onboard sound ones, so I'm positive it will work perfectly after some patient experimentation.
Mind the card has more input/output connectors than I can count (it has a 5.25" front panel too), it may be as simple as disabling some input/output channels for everything to work as intended.

the Fiddler's picture

[error checking]
I think AudioDeviceException would work fine for 'InvalidDevice' types of errors.

[DeviceUnplugged]
My only hesitation is whether it's possible to make this 100% reliable, i.e. always trigger the event when a device is unplugged/plugged. It will be great if this is possible but if not, I think it's better to avoid this.

[hardware]
I can't say I'm surprised about motherboard incompatibilities. Apart from my old, trusty SB16, I've never seen a Creative card that hasn't had *some* kinds of incompatibilities. Fortunately, they generally work fine once you get them to work. :)

On the other hand, I never cease to wonder why 1x PCIe slots always lie at positions covered by video cards. My only free PCIe slot lies somewhere between the CPU, the motherboard and the GPU cooler (the only saving grace is the lack of cooling fans!)

Edit: you can subscribe to the commit feed at http://cia.vc/stats/project/opentk/.rss, if you wish to be notified of updates automatically.

Inertia's picture

What's the purpose of bool openal_supported? Merely track whether the dll is present? or should it also include whether device detection failed/succeeded?

[AudioDeviceException]
I'm only using it for errors related to OpenDevice-alike functions.

[hardware]
Only the more-recent X-Fi Titanium has PCIe, I've got the older X-Fi Platinum series. The sound quality is truely an upgrade compared to onboard sound. In Doom3, I found myself running back a couple of rooms that were already cleared, because I heard a zombie that I had overlooked in the dark. That were about 30-40m distance with walls inbetween, but I knew exactly where to find it. When realizing that I was like: O.o
Reverb and Headphones certainly make a difference.

Motherboard designs are probably like that to fit as many slots as possible on as little space as possible. I do agree that it might be the better design not to squeeze all PCIe slots next to each other since graphic card's cooling starts to get ridiculously huge. I've no idea how I'd fit some SLI/Crossfire in there.

[RSS]
I've bookmarked the url, but I rather do a few clicks to get information than getting it when I don't want&|care . The very first thing I disable after installing vista is the sidebar.

[MacOS/Linux]
I take it the only way to test whether the changes I made run on other platforms are me installing the OS? I'm afraid of Unices.

the Fiddler's picture

'Openal_supported' merely tracks the presence of the dll. There is a chance that OpenAL may be supported (or 'supported' as far as drivers go) without the enumeration extension. In that case, I think the device lists should return only a single device (named e.g. 'Default' or 'Unknown') without any enumeration taking place (always use alcOpenDevice(null)).

No reason to ban OpenAL 1.0 outright.

[MacOS/Linux]
VirtualBox 3.0 (beta) + Ubuntu 9.04 = win. You get OpenGL 2.0, audio, network and everything else you might need (plus you'll get to love the terminal :p).

Hint: install necessary applications first.

sudo apt-get install build-essential libopenal1 monodevelop monodelevop-debugger-mdb monodevelop-versioncontrol gnome-do

and then install the 'guest additions' of VirtualBox (for 3d and copy&paste support):

cd /media/cdrom
sudo ./VirtualBoxLinuxAdditions-x86.exe

Finally fetch opentk:

cd Desktop
svn co https://opentk.svn.sourceforge.net/svnroot/opentk/branches/openal-next openal-next
cd openal-next/Build
mono Build.exe vs
monodevelop OpenTK.sln &

(In case you wonder, I do this procedure once or twice a day. It keeps me in shape :p)

Inertia's picture

When using the word "afraid" I did not mean "scared". Rather "concerned" that Linux has the same effect on me like a shot of heroine for an ex-junkie who has lived happily with methadon before. ;)

Thanks for the crashcourse, I will at least confirm that the changes work as intended on Linux. But I won't buy MacOS - which I don't need - just to go through the horrors of driver installation a 3rd time.

VS 2010 is also a good way to stay in shape, since they somehow broke IntelliSense (compared to VC# 2005 EE). Often you need to type letters first before intellisense will accept confirmation of the choice by the enter key, but using the mouse you can select and confirm at all times. With VC# 2005 the only times I use the mouse is with forms or moving c&p, so VS2010 does actually slow me down :|

Inertia's picture

Can you please run this test application and c&p the output in here?

I have not worked any further on the AudioCapture class so far, but rather wrote this diagnostic that should help identify any OpenAL related problems much easier. It's missing capture-related tests atm, but I'll write those while working further on AudioCapture.

Idk whether it should be polished and become part of OpenTK.Audio, or simply add it to the example launcher. Either is fine with me, but we really need something like this in the distribution.

Edit: OFCOURSE I forgot to add the dll-config file. :)

AttachmentSize
AL Diag v1.rar49.88 KB
the Fiddler's picture

Ok, ran this on Ubuntu 9.04 amd64 (OpenAL Soft 1.4).

Two things seem to fail:

AL lib: alSource.c:2291: alcDestroyContext(): 200 Source(s) NOT deleted
AL lib: alsa.c:564: set access failed: Invalid argument
 
Unhandled Exception: OpenTK.Audio.AudioDeviceException: The handle returned by Alc.CaptureOpenDevice is null. Alc Error: NoError
Device Name: ALSA Capture on default
Frequency: 16000
Buffer format: Mono16
Buffer Size: 32000
  at OpenTK.Audio.AudioCapture..ctor (System.String devicename, UInt32 frequency, ALFormat bufferformat, Int32 buffersize) [0x00000] 
  at OpenTK.Audio.AudioCapture..ctor (System.String devicename, Int32 frequency, ALFormat bufferformat, Int32 buffersize) [0x00000] 
  at Audio_info.Program.Main (System.String[] args) [0x00000]

(Use wordpad to open the file)

AttachmentSize
audio-info.txt3.37 KB
Inertia's picture

I've got the same problem with AL.DeleteSources() with the OpenAL Soft x86, it works flawless with creative lab's driver tho. Will meditate over this.

"AL lib: alsa.c:564: set access failed: Invalid argument"
I take it alsa is the linux equivalent to directsound for windows?

Do you have a microphone plugged in?

the Fiddler's picture

Yep, alsa is something like directsound and no, I forgot to plug my microphone.

Inertia's picture

Regarding capture, all the test does atm is open and close the device. It does not throw the exception on my PC, the mic is connected but it doesn't work in any application (and yes, it's neither muted nor at min. volume).

You didn't comment whether you'd like this to become part of the example launcher, I guess you want a cutie fluffy WinForms UI for it? Tell me, I can take it.