XAudio2 - Pretty poor huh?

Started by
4 comments, last by howie_007 10 years, 8 months ago

Hi guys,

During my time at university I created an application using DirectX 10.

I needed audio support for the following:

1. Background music

2. Ambient repeating samples

3. Effect samples (play once)

I followed all the Microsoft examples in order to achieve this and it runs on a separate thread to the application real-time logic.

1. The background music doesn't impact on performance (great!)

2. If I use anything thats not in xwma format the voices only play for around 30 seconds. The application thinks its still playing sound, no errors are returned or logged by the XAudio2 debug dll.

3. Playing lots of short samples (Play once) sequentially results in a similar behaviour, the sound just cuts out.

I have tried this using the release and debug versions of the dll, and the behaviour is the same. I also appear to have no memory leaks.

Originally I thought it was because I was using a submix voice, so I removed it from the chain and send directly to the master voice.

Is XAudio2 just a poor library?

Any suggestions as to a replacement?

Advertisement

I haven't started on audio for my current project yet, but i have a feeling its not going to be fun.

when i started my project in jan 2012, Microsoft. as usual was "between versions" for directx. Xaudio2 was the new API at that time as i recall.

The last project i did be fore this one was based on directsound from directx 8.0b. the only thing i had to do was write a 50 channel real time mixer, and write a few simple wrapper routines for play, loop, is_playing, and stop. the directsound API was pretty straighforward by then.

i've heard that xaudio2 is not so hot, although i have get to get into it.

one thing, have you made sure you're not exceeding the max number of samples xaudio2 can mix at once?

this is what forced me to write a 50 channel mixer for directsound. it could only mix something like 16 channels. and i'd have more than 16 samples at once sometimes, resulting in "stepping": the oldest sample is stopped prematurely, and a newly staring sample takes its channel over. so some samples get cut off, and don't play to completion.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

I have yet to see a decent xaudio2 tutorial. If you find one please let me know. I'd love to see a simple wrapper for it. init(), createsound(pSound, format, pData), playsound(pSound, position, loop), stopsound(pSound). don't need anything else... :)


"DirectX is like a belt fed machine gun, where every texture change is like hand loading in a new belt of ammo. worse, every mesh (vb) is a new belt of ammo, and a texture is like breaking the gun down, and setting it up again elsewhere, then loading it, then spraying triangles again. so you want to setup the gun once, string all your belts together, load it once, then just spray."

Norm Barrows

Do you have a DX9 tutorial I can read on this? :D I got too many draw calls and texture changes, I need to start looking into batching.



Norman Barrows, on 27 Jul 2013 - 12:56 PM, said:

"DirectX is like a belt fed machine gun, where every texture change is like hand loading in a new belt of ammo. worse, every mesh (vb) is a new belt of ammo, and a texture is like breaking the gun down, and setting it up again elsewhere, then loading it, then spraying triangles again. so you want to setup the gun once, string all your belts together, load it once, then just spray."

Norm Barrows
Do you have a DX9 tutorial I can read on this? I got too many draw calls and texture changes, I need to start looking into batching.

the closest thing i have is what i call "Norm's directx tips", a text file with a collection of answers to common and uncommon problems in directx. things i've had to research in the past. it has a fair amount of useful stuff, but is in very rough shape.

i personally have had great success with drawing scenes in order based on texture. 9000+ draw calls with no instancing, no LOD, fixed function DX9. see the CAVEMAN screenshots in my gallery for examples.

directx is very fast at some things and slow at others. so you want to do the slow stuff (like changing textures) as little as possible.

when starting on the graphics engine for CAVEMAN, i came up with what i call a drawlist. the game throws meshes and textures at the drawlist in any old order, and it figures everything out (basically sorts on texture) and draws it in optimal order. it tracks current texture, mesh, cull state , and alpha test state while drawing, and only changes them as needed.

for terrain, a "chunk" is the drawlist for a 300x300 area, already sorted into a list of textures, and for each texture, a list of the meshes that use it and their transforms.

individual ground quads are grouped by texture into a single 300x300 static ground mesh for each texture. this is as close as i get to batching. ground quads were originally dawn one at a time with a dynamic vb and ib.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php


Is XAudio2 just a poor library?
No. It's good and probably the best around (for free use). You're doing something very wrong. FYI, I only use Vorbis, and I never had a problem like you describe.

Previously "Krohm"

I use XAct. I find it very easy to use and has many powerful features. I'll post some code if anyone is interested.

This topic is closed to new replies.

Advertisement