Solved

delphi: how to get input audio list ?

Posted on 2011-09-05
1
949 Views
Last Modified: 2012-05-12
Hello experts
How can I retrieve the list of installed input devices ? (input = microphone, not audio output)

regards
0
Comment
Question by:yarekGmail
[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
1 Comment
 
LVL 12

Accepted Solution

by:
Hypo earned 500 total points
ID: 36484702
There is a unit called MMSystems that contains most of the functionality you need... if you search through the windows sdk for functions that begin with waveIn, you will find the functions that are used with audio input devices on the system...

see the example below...

/Hypo
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    FWaveInDevices : array of TWaveInCaps;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure CheckIfError(AResult : MMRESULT);
var aText : String;
    aRes : Cardinal;
begin
  if AResult <> MMSYSERR_NOERROR then begin
    SetLength(aText, 255);
    aRes := waveInGetErrorText(AResult, @aText[1], 255);
    if aRes <> MMSYSERR_NOERROR then
      waveInGetErrorText(aRes, @aText[1], 255);
    aText := PChar(aText);
    raise Exception.Create(aText + ' - Error code: ' + IntToStr(AResult));
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FWaveInDevices := nil;
end;

procedure TForm1.Button1Click(Sender: TObject);
var i, aCount : integer;
begin
  aCount := waveInGetNumDevs;
  SetLength(FWaveInDevices, aCount);
  for i := 0 to aCount-1 do begin
    CheckIfError(waveInGetDevCaps(i, @FWaveInDevices[i], SizeOf(FWaveInDevices[i])));
    ListBox1.Items.Add(FWaveInDevices[i].szPname);
  end;
end;

end.

Open in new window

0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 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