Solved

Working with Multiple soundcard ..?

Posted on 2004-09-08
12
896 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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
 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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