Solved

delphi: how to get input audio list ?

Posted on 2011-09-05
1
884 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
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

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

Title # Comments Views Activity
Copy file in dll not working but working on exe ! 18 88
Delphi cmd execution 6 55
QRReport  TQrmemo vertical stretching 1 42
Dynamically Created Query 3 50
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

19 Experts available now in Live!

Get 1:1 Help Now