Solved

Working with Multiple soundcard ..?

Posted on 2004-09-08
12
872 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

15 Experts available now in Live!

Get 1:1 Help Now