tags:

views:

62

answers:

1

Hi. I don't know the first thing about programming in regards to audio, so bear with me. Is there any way to determine which file (or files) is being played by my sound driver? Or a way to examine the current stack of audio files played by my sound driver?

I think that I basically want to sniff the data sent to the audio bus to determine where it's located on the hard drive. If possible I'd love to know how to do this with .NET.

+2  A: 

I don't think this is possible. The APIs that do playback in Windows (DirectSound, waveOut* etc.) essentially deal with audio data as arrays of sample values, not as files. A higher-level class like SoundPlayer opens a file, reads the data in the file into an array, and then passes the array to the playback methods, so the thing playing the audio doesn't know anything about the original file's location.

As a further example, my own program (a software synthesizer) generates audio purely in memory, with no file being involved at any point in the process, so there would be no way to determine the file's location (since there isn't one).

It's possible that a class devoted to playing files might expose an API that allows you to get this information about any file played using that class, but I've never seen anything like this (I know SoundPlayer doesn't do it for sure).

Larry Osterman is a user on this site, and is the engineer behind the Windows audio system, so he would know the answer to this question if anyone does, if you can get his attention. However, I would bet a kidney that this isn't possible.

MusiGenesis
I'm just one of the engineers behind the Windows audio system :). But MusiGenesis is 100% accurate. The "source" of audio is pretty meaningless at the level of the audio stack - for instance most game audio is generated from a series of pre-rendered sounds saved as game data and sliced and diced by the app before it even hits the audio engine.
Larry Osterman