Switching audio sources by name for all sound drivers

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

Switching audio sources by name for all sound drivers

Postby cozturk » August 31st, 2005, 3:23 pm

I found microphone muting source and tested 2 different sound drivers for 2 PC. I know the input ids different for mic. Muting works! it's OK. Kambiz says:
You have to use DeviceID property of the component to select the proper device on one of the mixers. Unfortunately, there's no straight way to find DeviceID's of a mixer. However, using the similarity between name of the Mixer and name of the Device you can find the right Device.
I think, smilar ways can be used for all sound cards. But I couldn't achieved yet.
Any friend to make this!! How can I use AudioMixer to select audio "line"
Device ID ok. But line or mic selecting automatically by app. not OK.
microphone muting source:
http://www.swissdelphicenter.ch/en/showcode.php?id=1204
cozturk
Moderator
Moderator
 
Posts: 63
Joined: June 30th, 2005, 5:39 am
Location: Istanbul - Turkiye

Postby Kambiz » August 31st, 2005, 11:07 pm

Hi,

My comments was regarding choosing a mixer. Now, you are talking about a mixer line.

Using TAudioMixer, Microphone Muting needs just a few lines of code.

Code: Select all
procedure TForm1.MuteMicrophineClick(Sender: TObject);
var
  LineID: Integer;
begin
  for LineID := 0 to AudioMixer.LineCount - 1 do
    if AudioMixer.Lines[LineID].ComponentType = cmSrcMicrophone then
    begin
      AudioMixer.Lines[LineID].Mute := MuteMicrophine.Checked;
      Break;
    end;
end;

Please read the documentation of the component for different values of ComponentType property.

Cheers
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby cozturk » September 1st, 2005, 8:45 am

Thank you very much. Mute ok. but selecting mic. not. Here is my code to select mic:
Code: Select all
var
  LineID: Integer;
begin
    for LineID := 0 to AudioMixer.LineCount - 1 do
    if (AudioMixer.Lines[LineID].ComponentType = cmSrcMicrophone)
      and (CheckBox1.Checked)  then   
    AudioMixer.Lines[LineID].SelectedLine;
end;

Of course mixer's destination ID set as "1" (recording mixer). But selecting mic. not ok.
Image
cozturk
Moderator
Moderator
 
Posts: 63
Joined: June 30th, 2005, 5:39 am
Location: Istanbul - Turkiye

Postby Kambiz » September 1st, 2005, 9:28 am

SelectedLine is a property, not a method.

SelectedLine: Integer;
For a destination audio line (Master), indicates which source audio line is selected for recording.

When you find the proper LineID, you should use the following code to select the line:

Code: Select all
AudioMixer.Master.SelectedLine := LineID;

By the way, dont' forget to set AudioMixer.DestinationID property to 1. This assignment activates the recording controls.

Cheers
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby cozturk » September 1st, 2005, 9:53 am

Thanks.
Image
cozturk
Moderator
Moderator
 
Posts: 63
Joined: June 30th, 2005, 5:39 am
Location: Istanbul - Turkiye

Postby Edwin » November 25th, 2005, 7:42 am

Hi Kambiz,

Thanks for the info.
Something strange happens if the SelectedLine is written or read.
If I debug the projects and put a breakpoint in TAudioMixerLine.GetSelectedLine (unit WaveMixer line 409) then I sea that ValIndex gives the correct ID of the selected line.
But
fControls[mcSelect].cMultipleItems - DWORD(ValIndex) - 1
will be returned. So I get a wrong result.
I do this on a window 2000 computer. If we run the program on XP, the the result is good.
I had a look in MSDN, but found nothing about Window version dependancy?
Maybe the
Result := fControls[mcSelect].cMultipleItems - DWORD(ValIndex) - 1;
gives problems, sinse signed and unsigned values are used?
A made a workaround in my own source code:

if FWorkAround then
cbxSelect.Checked :=
FMixerLine.Mixer.LineCount-1 - FMixerLine.Mixer.Master.SelectedLine =
FMixerLine.ID
else
cbxSelect.Checked :=
FMixerLine.Mixer.Master.SelectedLine = FMixerLine.ID;

The FWorkAround boolean is true for windows 2000 and fals for XP.
Kind regards,
Edwin
User avatar
Edwin
Active Member
Active Member
 
Posts: 18
Joined: November 18th, 2005, 11:57 pm
Location: Breda, NL

Postby Kambiz » December 2nd, 2005, 10:55 am

Sorry Edwin,

I didn't have time yet to check out the case. When I did it, I would let you know.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Edwin » December 4th, 2005, 9:11 pm

Ok Kambiz, no problem. :wink:
User avatar
Edwin
Active Member
Active Member
 
Posts: 18
Joined: November 18th, 2005, 11:57 pm
Location: Breda, NL

Postby Kambiz » January 31st, 2006, 3:19 pm

Edwin wrote:Hi Kambiz,

Thanks for the info.
Something strange happens if the SelectedLine is written or read.
If I debug the projects and put a breakpoint in TAudioMixerLine.GetSelectedLine (unit WaveMixer line 409) then I sea that ValIndex gives the correct ID of the selected line.
But
fControls[mcSelect].cMultipleItems - DWORD(ValIndex) - 1
will be returned. So I get a wrong result.
I do this on a window 2000 computer. If we run the program on XP, the the result is good.
I had a look in MSDN, but found nothing about Window version dependancy?
Maybe the
Result := fControls[mcSelect].cMultipleItems - DWORD(ValIndex) - 1;
gives problems, sinse signed and unsigned values are used?
A made a workaround in my own source code:

if FWorkAround then
cbxSelect.Checked :=
FMixerLine.Mixer.LineCount-1 - FMixerLine.Mixer.Master.SelectedLine =
FMixerLine.ID
else
cbxSelect.Checked :=
FMixerLine.Mixer.Master.SelectedLine = FMixerLine.ID;

The FWorkAround boolean is true for windows 2000 and fals for XP.
Kind regards,
Edwin


I couldn't find anything too. :(
Did you check the issue on Windows 95, 98, and ME?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Kambiz » March 28th, 2007, 1:59 am

Edwin wrote:Hi Kambiz,

Thanks for the info.
Something strange happens if the SelectedLine is written or read.
If I debug the projects and put a breakpoint in TAudioMixerLine.GetSelectedLine (unit WaveMixer line 409) then I sea that ValIndex gives the correct ID of the selected line.
But
fControls[mcSelect].cMultipleItems - DWORD(ValIndex) - 1
will be returned. So I get a wrong result.
I do this on a window 2000 computer. If we run the program on XP, the the result is good.
I had a look in MSDN, but found nothing about Window version dependancy?
Maybe the
Result := fControls[mcSelect].cMultipleItems - DWORD(ValIndex) - 1;
gives problems, sinse signed and unsigned values are used?
A made a workaround in my own source code:

if FWorkAround then
cbxSelect.Checked :=
FMixerLine.Mixer.LineCount-1 - FMixerLine.Mixer.Master.SelectedLine =
FMixerLine.ID
else
cbxSelect.Checked :=
FMixerLine.Mixer.Master.SelectedLine = FMixerLine.ID;

The FWorkAround boolean is true for windows 2000 and fals for XP.
Kind regards,
Edwin


Finally the mentioned problem fixed on version 1.80 of the wave audio package.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Edwin » May 18th, 2007, 2:06 pm

Hi Kambiz,

I just downloaded the new version and compiled my project without the work around. It will be tested by different users.
How did you fix the problem?
Thanx a lot,

Edwin
User avatar
Edwin
Active Member
Active Member
 
Posts: 18
Joined: November 18th, 2005, 11:57 pm
Location: Breda, NL

Postby Kambiz » May 19th, 2007, 6:52 pm

Edwin wrote:How did you fix the problem?


By locating the appropriate line using its name.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Edwin » May 19th, 2007, 9:12 pm

You did a good job Kambiz :D
It is tested on windows 98SE, 2000 and XP.
User avatar
Edwin
Active Member
Active Member
 
Posts: 18
Joined: November 18th, 2005, 11:57 pm
Location: Breda, NL


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 0 guests

cron