Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Working with Multiple soundcard ..?

Posted on 2004-09-08
12
Medium Priority
?
943 Views
Last Modified: 2010-05-18
I'm using dephi, How can I select which sound card of my two installed, I want to use for playback. My program must be able to a different song on each of the two sound cards. The problem is that I don't know If/How you can do this with MCI.  

Please help me.

Thanks
-sirro
0
Comment
Question by:sirro
  • 5
  • 4
12 Comments
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 12004099
try this:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,mmsystem, StdCtrls, MPlayer;

type
  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    MediaPlayer1: TMediaPlayer;
    procedure FormCreate(Sender: TObject);
    procedure ComboBox1CloseUp(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  outcaps: TWaveOutCaps;
  parms: MCI_WAVE_SET_PARMS;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
i := waveOutGetNumDevs;
for i := 0 to i - 1 do
   begin
      waveOutGetDevCaps(i, @outcaps, SizeOf(outcaps));
      Combobox1.Items.Add(outcaps.szPname); //to add the card display names
   end;
   Combobox1.ItemIndex := 0;
   Combobox1closeup(self);
end;

procedure TForm1.ComboBox1CloseUp(Sender: TObject);
begin
    parms.wOutput := Combobox1.itemindex;
    mciSendCommand(MediaPlayer1.DeviceID, MCI_SET, MCI_WAVE_OUTPUT, Longint(@parms));
end;

end.

and for multiple take a look at this

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20679099.html
0
 

Author Comment

by:sirro
ID: 12013555

Hai Ferrucio, I've tried code you've been sent in my computer,
but unfortunately, in only works in wav file, when I'm trying mp3 file, the output sound always played by default soundcard. Is there any additioanl setting (registry perhaps..), that I've set first.


Thanks
-sirro
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 12013732
AFAIK it works also for MP3...do you have some mp3 player installed like winamp or something else?
BTW try going on file association settings (in explorer) and remove the mp3 association, then try it again....
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sirro
ID: 12014630

Of course I have Mp3 players program on my computer,
I also trying on vcd *.dat files, and like the previous, the sound is out to default soundcard setting
Fyi, the error code is  274 "The MCI device you are using does not support the specified command"
Is there any suggestion on that error

Thanks
Purno
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 12015080
Yeah i understand now...
Here we should need Slick812 :)
Well, look at this to play mp3's with MCI
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20506184
and combine it with the previous (i mean how to enumerate Audio devices)....
0
 

Author Comment

by:sirro
ID: 12051559
thanks, and I have tried your suggestion,
but one more, when I change the device form 1st into 2nd soundcard that error message raise :(
 274 "The MCI device you are using does not support the specified command"

any more suggestion ?
why its work on wave files but not works on mp3 or mpg files ??
is there any additional setting on my PC ??

Thanks
~sirro
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 12051975
If you use MCI_WAVE_SET_PARMS then the expected format for the device is a Wave format....

Have no time now to look in it (am at work now), but you'd use the first example to get the devices list, and then the second from the posted link to play mp3 but using the desired device (so using the device id retrieved by the first method)
0
 

Author Comment

by:sirro
ID: 12082088
I’m stuck ,
when I’m trying command to open files

MCIreturn := mciSendCommand(3, MCI_OPEN, MCI_WAIT OR  mci_open_element ,Integer(@mciopen));

The result of mciOpen.wDeviceID always 1 ( my default soundcard )
How can I make it to 2(my second soundcard)

And when I force the device to 2, Then I command to play file with

    dwReturn:=mciSendCommand(DeviceID, MCI_PLAY, MCI_NOTIFY,   Integer(@mciPlay));
the error return always 274

I have explored MSDN, I don’t know maybe because of my foolish I’m still confuse
Any solutions guys… ?


~sirro
0
 

Author Comment

by:sirro
ID: 12215626
Okay I'll increase the point to 200 for anyone who can help me solve my problem
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13432774
PAQed with points refunded (200)

modulo
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question