Output capture and Primary Buffer access in DirectSound

5df481d295e48ade00f20ab64c9e883f
0
spiral 101 Mar 01, 2007 at 21:56

I have created an application that mixes a number of different audio files (which I load into secondary buffers). What I really want to do is access that mixed data and be able to write it to a file. However it seems impossible to be able to read data from or set the format of the primary buffer in Direct sound.

Do any of you have experience with this?

As an alternative, I am thinking it could be possible to use some sort of loop back driver to capture the soundcard’s output into a new Capture buffer. From there it would be pretty simple to write the file.

I would really appreciate any advice!

4 Replies

Please log in or register to post a reply.

B91eae75cd6245bd8074bd0c3f1cc495
0
Nils_Pipenbrinck 101 Mar 01, 2007 at 22:41

It is impossible if you’re just an application. As an application you just create and start the buffers that need to be mixed. How and when the buffers are mixed (in software, hardware or even analog) is up to the driver of the soundcard. You can’t capture the mixed result. Some soundcard drivers allow to route back the wave output to the record-in though.

However, I remember a proxy soundcard driver that tells the system he is just able to playback a singe sound stream. This tells DirectSound that it has to do all the dirty work (e.g. mixing). The driver had the feature to route that either to another soundards primary buffer or a wav-file. I don’t remember how that driver was callled, but it’s widely used by those folks who try to rip music from DRM secured sources. I’m sure if you really search for it you’ll find it.

Another solution to your problem would be to write a sample mixer yourself (hint: if you haven’t already done so, you’ll learn a lot!). Depending on your skill that might take something between 2 days and a month. It’s not that difficult and if you dig a bit into resampling you’ll learn a lot about signal theory, what’s involved when it comes to quality ect. Most drivers just do it the dirty way (the ms sample mixer is no exception here). The quality boost you can get from a proper implementation that doesn’t need to work in realtime is incredible.

So, sorry - no quick solution to your problem, but some hints and ideas…

5df481d295e48ade00f20ab64c9e883f
0
spiral 101 Mar 02, 2007 at 03:33

Hm well that is not good news. The main reason I am using Direct Sound is because of its 3D effect processing. I think that probably puts a homemade mixer over the top.

I will primarily be using this on one system so I wonder if it’s possible to reference the output stream through a specific soundcard driver. I will look into other proxy drivers also.

Thanks for the help.

B91eae75cd6245bd8074bd0c3f1cc495
0
Nils_Pipenbrinck 101 Mar 02, 2007 at 11:04

You could also just go the analog way and connect a little loopback cable to your wave-out back into the line-in. If your soundcard has sp-dif digital inputs and outputs you won’t even lose any quality that way.

5dca1202b2963aa5a60b847137c1439e
0
Fabien_Perrot 101 Jun 08, 2007 at 12:16

Hi,

i’m having the same problem.
I thought of a solution : select the default recording device as the main mixer of the sound card. We can do that through the volume settings panel of windows. But there is no way to programmatically set the recording device, explained here :

http://forums.microsoft.com/msdn/showpost.aspx?postid=876415&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=1
But if it’s only for your app, in local, this may help you.

I’m thinking to try another way, that is the DirectShow Editing Services, an API included in DirectShow, used to mount videos and sounds in a timeline.
This don’t support sound 3D effect of course ! But it may allow to “simply” mix different sounds to a wav file.