Solved

Working with Multiple soundcard ..?

Posted on 2004-09-08
12
883 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 22

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 22

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
 

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 22

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 22

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now