Solved

Working with Multiple soundcard ..?

Posted on 2004-09-08
12
917 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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