Page 1 of 1

Switching audio sources by name for all sound drivers

PostPosted: August 31st, 2005, 3:23 pm
by cozturk
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

PostPosted: August 31st, 2005, 11:07 pm
by Kambiz
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

PostPosted: September 1st, 2005, 8:45 am
by cozturk
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

PostPosted: September 1st, 2005, 9:28 am
by Kambiz
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

PostPosted: September 1st, 2005, 9:53 am
by cozturk
Thanks.
Image

PostPosted: November 25th, 2005, 7:42 am
by Edwin
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

PostPosted: December 2nd, 2005, 10:55 am
by Kambiz
Sorry Edwin,

I didn't have time yet to check out the case. When I did it, I would let you know.

PostPosted: December 4th, 2005, 9:11 pm
by Edwin
Ok Kambiz, no problem. :wink:

PostPosted: January 31st, 2006, 3:19 pm
by Kambiz
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?

PostPosted: March 28th, 2007, 1:59 am
by Kambiz
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.

PostPosted: May 18th, 2007, 2:06 pm
by Edwin
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

PostPosted: May 19th, 2007, 6:52 pm
by Kambiz
Edwin wrote:How did you fix the problem?


By locating the appropriate line using its name.

PostPosted: May 19th, 2007, 9:12 pm
by Edwin
You did a good job Kambiz :D
It is tested on windows 98SE, 2000 and XP.