Go Back   Winamp & Shoutcast Forums > Winamp > Winamp Technical Support

Reply
Thread Tools Search this Thread Display Modes
Old 29th March 2001, 03:44   #1
pirata
Junior Member
 
Join Date: Sep 2000
Posts: 8
I want to be able to choose which device to use for output from the DirectSound plugin (out_ds.dll). This can be done manually by opening the configuration dialog, of course, but I want to do it from a DJ application I'm working on, so that if a user has two soundcards, then (s)he can choose one mix to go out through one sound card, and another mix through the other one.

I know so much about it that I can enumerate the devices and get their GUID's by a call like this in VB:

Dim dx As New DirectX7
Dim dse As DirectSoundEnum
Set dse = dx.GetDSEnum
For i = 1 To dse.GetCount
Debug.Print dse.GetDescription(i)
Debug.Print dse.GetGuid(i)
Next i

The first one (i=1) is the Primary sound driver, that is the default chosen in the Control panel as the preferred device. Its GUID is all zeros. With 2 soundcards there are two more devices in the list, each one corresponding to one soundcard.

Is it possible to set a specified device as the chosen one in the Winamp plugin from code in an external application? If so, how?

I have seen another possibility it the winamp.ini file. The last used output device upon closing Winamp is stored like this:

[Dsound output driver v2]
outdev=0000000000000000000000000000000000
(Primary)
or
outdev=C1920B3DFCABCE11A3B300AA004A9F0C16
(SB Live)
or
outdev=1AD76DBDEB3DD111B17100C04FC2000018
(VIA)

The first 16 characters are the first 16 characters from the GUID for the device, only in another order. The next 16 characters are the remaing 16 characters from the GUID, but this time in regular order. I can live with this, but there are 2 more characters at the end that I don't know what they are for. Are they a checksum or something else? In short, how can I figure out what to write to Winamp.ini when Winamp is closed? The 2 last characters, how to calculate or otherwise obtain them, is what interests me mosts.

Anybody's got an answer? If so, please post it right here and I'll be forever grateful.

Karl Nilsson



pirata is offline   Reply With Quote
Old 30th March 2001, 11:09   #2
martyx
Junior Member
 
martyx's Avatar
 
Join Date: Mar 2001
Location: Bristol
Posts: 10
Send a message via ICQ to martyx Send a message via AIM to martyx Send a message via Yahoo to martyx
Err

Well I know this seems a little BASIC (no pun intended) - but my PC runs a disco (2x soundcards & a mixer deck).

I open 2x Winamps and I use WAVEOut - I select one soundcard for one winamp, and t'other soundcard for 2nd winamp.

They both act seperate and I've had no problems running them like that under Windows 95/98/2000.

I supposed you could do the same with DirectSound ??
martyx is offline   Reply With Quote
Old 30th March 2001, 14:14   #3
pirata
Junior Member
 
Join Date: Sep 2000
Posts: 8
Quite so, but I want to do it via code from my frontend, and I think I figured out the second alternative. I'll try to explain it later, it's a bit complicated. Anyone knows about the first alternative?

Thanks anyway and keep up the spirit.



pirata is offline   Reply With Quote
Old 30th March 2001, 20:27   #4
pirata
Junior Member
 
Join Date: Sep 2000
Posts: 8
Here's the story:

If you choose to use Winamp's DirectSound output plugin then, upon closing, Winamp will store the following information in the Winamp.ini file:

This key and value will be stored in section [Winamp]:
outname=out_ds.dll

And in the section [Dsound output driver v2], under the key "outdev", a value indicating the chosen output device will be stored:

If you choose "Primary sound driver" in the DirectSound plugin configuration dialog (that is the default device chosen in Control Panel, Multimedia, Audio, Playback, Preferred device), then it will look like this:
outdev=0000000000000000000000000000000000

If you in the plugin have chosen a specific sound card, then it might look like this:
outdev=C1920B3DFCABCE11A3B300AA004A9F0C16

Now, if you look at the GUID for the same card (taken from the registry, or from a WINAPI function like DSEnumCallback, or VB DirectSoundEnum), you will find that in this case it looks like:
{3D0B92C1-ABFC-11CE-A3B3-00AA004A9F0C}

Compare it to the string above for the sound card, and you will notice similarities. The GUID has 5 groups separated by hyphens. Each pair of characters form a hexadecimal representation of a byte, with a value from 0 ("00") to 255 ("FF").

In the first group, start with the last pair (here, "C1"), then take the pair before that etc. Do the same with the second and then the third group. Then take the pairs, but in regular order from the 4th and 5th groups, and you will have built almost the whole string in the Winamp.ini value.

There is only one more pair that we need to know, and it seems that it is a checksum that you can get by summing the values of all the 16 pairs in the GUID, and performing a Mod 256 operation on the sum (the result is the remainder from dividing the sum by 256). It works for the few examples I have been able to test it on.

All you have to do now is to write this string to the Winamp.ini file, and then open one or more instances of Winamp, then write to Winamp.ini a string corresponding to another soundcard, and open yet one or more instances of Winamp, and, voilà, you can provide totally independent mixes on your two soundcards!

Simple. right? No, I don't think so. One can't help but wonder why the creators of such a wonderful piece of software like Winamp would choose such a complicated way of storing the value for the chosen device. Why not just store the GUID string as it is, with brackets and hyphens and all? These are secrets for us common people, but who knows, maybe some day it will be revealed to us.

Or better still, we might learn how to choose the output device from code directly to the plugin with immediate results! Is anyone interested in this anyway? (I am.)

Karl Nilsson
pirata is offline   Reply With Quote
Old 13th September 2001, 21:50   #5
akira
Junior Member
 
Join Date: Aug 2000
Posts: 4
Thank You ver much.

But i have some troubles.
I've tested it, as you wrote above, with different sound cards.
And it always worked with one exception.
It wont work with a Soundblaster-card.

So You are using the same card with the same GUID as me.
Following GUID: C1920B3DFCABCE11A3B300AA004A9F0C (Soundblaster)
But after the mod operation i come to 22 not 16 as winamp.
After the sumation of the 16 Bytes i come to a sum of 1813 but i think it should be 1807.

But at any other card the mod operation works why not at the soundblaster?

Why does your example with the Soundblaster works and you come to the correct sum of 16 but not me?

Can you help me?
akira is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Winamp > Winamp Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump