Setting Mixer input level

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

Setting Mixer input level

Postby ejla » March 30th, 2007, 7:01 pm

The code below set Mic level on Playback mode, but how to set Mic-line input level on Recording???

Thanks,
Erkki

Code: Select all
procedure TForm1.tcbMicChange(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].Volume := tcbMic.Position; //TrackBar
      Break;
    end;
  AudioMixer.DestinationID := 1;
  AudioMixer.Master.SelectedLine := LineID;
end;
ejla
Active Member
Active Member
 
Posts: 10
Joined: March 24th, 2007, 1:07 am
Location: Sweden

Postby Kambiz » March 30th, 2007, 10:15 pm

When destination of a TAudioMixer object is recording controls, Volume acts as input level. See Mixer Control demo a the sample.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby ejla » March 31st, 2007, 12:01 am

Kambiz wrote:When destination of a TAudioMixer object is recording controls, Volume acts as input level. See Mixer Control demo a the sample.


Sorry, the code is very complex and I can't figure out how to do!
I have done hard experience, but only AV like best result :-(

Can you give me more detailed advise, please!

Erkki
ejla
Active Member
Active Member
 
Posts: 10
Joined: March 24th, 2007, 1:07 am
Location: Sweden

Postby Kambiz » March 31st, 2007, 9:21 pm

It's quite simple, set AudioMixer.DestinationID to 1 and set Volume of your desired line. It will change the input level.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby domi.papin » August 2nd, 2007, 10:35 am

Hello,

Just to mention that with my config. I get the wavein microline on DestionationId = 2
domi.papin
Member
Member
 
Posts: 3
Joined: August 2nd, 2007, 10:23 am

Postby domi.papin » August 6th, 2007, 1:42 pm

Here is a sample code to retrieve a microphone input line (if any) and select it

Code: Select all
function TMachin.SelectMicro( var aLine: TAudioMixerLine) : boolean ;
var
  I, J, L : integer ;
begin
  aLine := nil ;
  Result := False ;

  for I := 0 to mMixer.MixerCount - 1 do
  begin
    mMixer.MixerID := I ;
    for J := 0 to mMixer.DestinationCount - 1 do
    begin
        mMixer.DestinationID := J ;
        if ( mMixer.Master.ComponentType = cmDstWaveIn ) then
        begin
            for L := 0 to mMixer.LineCount - 1 do
            begin
                if mMixer.Lines[L].ComponentType <> cmSrcMicroPhone then
                  continue ;
                aLine := mMixer.Lines[ L ] ;
                if ( mcSelect in mMixer.Master.AvailableControls ) then
                  mMixer.Master.SelectedLine := L ;
                Result := True ;
                exit ;
            end ;
        end;
    end ;
  end;
end;
domi.papin
Member
Member
 
Posts: 3
Joined: August 2nd, 2007, 10:23 am

Postby Kambiz » August 6th, 2007, 4:43 pm

Thank you very much.

Just there was a missing stuff in selecting the line, that I fixed in your code.

Code: Select all
function TMachin.SelectMicro( var aLine: TAudioMixerLine) : boolean ;
var
  I, J, L : integer ;
begin
  aLine := nil ;
  Result := False ;

  for I := 0 to mMixer.MixerCount - 1 do
  begin
    mMixer.MixerID := I ;
    for J := 0 to mMixer.DestinationCount - 1 do
    begin
        mMixer.DestinationID := J ;
        if ( mMixer.Master.ComponentType = cmDstWaveIn ) then
        begin
            for L := 0 to mMixer.LineCount - 1 do
            begin
                if mMixer.Lines[L].ComponentType <> cmSrcMicroPhone then
                  continue ;
                aLine := mMixer.Lines[ L ] ;
                if ( [mcSelect, mcMix] * mMixer.Master.AvailableControls ) <> [] then
                  mMixer.Master.SelectedLine := L ;
                Result := True ;
                exit ;
            end ;
        end;
    end ;
  end;
end;
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby domi.papin » August 8th, 2007, 9:51 am

thanks for the tip Kambiz and keep up your good work :)
domi.papin
Member
Member
 
Posts: 3
Joined: August 2nd, 2007, 10:23 am

Selecting a Microphone

Postby Davife » August 21st, 2008, 9:38 am

I attempted to use your modified code sent in originally by domi.papin to identify the selected microphone.

However after scrolling through mMixer.LineCount and finding cmSrcMicroPhone for both a LineIn/LineOut and a USB mixer neither had mcSelect in the set of AvailableControls.

Not clear why because physically the USB microphone is the active device. What I want to do is to be able to select between available microphones. How do I do that?

Thanks.
Davife
Member
Member
 
Posts: 4
Joined: August 21st, 2008, 9:23 am

Postby Kambiz » August 21st, 2008, 12:03 pm

I [b]guess[b] when a mixer has only one input line, its master line has no mcSelect or mcMix control because the input line is already selected.

According to this assumption, the new SelectMicro function should be in this way:

Code: Select all
function SelectMicro(Mixer: TAudioMixer; var Line: TAudioMixerLine) : boolean;
var
  M, D, L: Integer;
begin
  Line := nil ;
  Result := False ;
  for M := 0 to Mixer.MixerCount - 1 do
  begin
    Mixer.MixerID := M;
    for D := 0 to Mixer.DestinationCount - 1 do
    begin
      Mixer.DestinationID := D;
      if (Mixer.Master.ComponentType = cmDstWaveIn) then
      begin
        for L := 0 to Mixer.LineCount - 1 do
        begin
          if Mixer.Lines[L].ComponentType = cmSrcMicroPhone then
          begin
            Line := Mixer.Lines[L];
            if ([mcSelect, mcMix] * Mixer.Master.AvailableControls) <> [] then
              Mixer.Master.SelectedLine := L
            else if Mixer.LineCount > 1 then
              Continue;
            Result := True;
            Exit;
          end;
        end;
      end;
    end;
  end;
end;


Please let me know if it works as expected.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby Davife » August 21st, 2008, 5:17 pm

Thanks for the quick response.

There are 2 destinations: LineIn/LineOut and USB Microphone

- LineIn/LineOut destination has 4 lines. Line3 is cmSrcMicrophone and [mcSelect, mcMix] is not in AvailableControls
-USB Microphone destination has 1 line. It is componenttype cmSrcMicrophone. It also doesn't have [mcSelect, mcMix] is not in AvailableControls.

Any ideas?
Davife
Member
Member
 
Posts: 4
Joined: August 21st, 2008, 9:23 am

New input

Postby Davife » August 22nd, 2008, 6:27 am

Kambiz,
I have a new input and an associated question. The computer in question runs Windows XP Media Center Edition. In this version of XP, unlike all others in the office, if you go to Sound and Audio devices and explore you find that the OS does have select checkboxes for the Recording Devices, it only allows you to select the Default, hence no 'mcSelect'.

So with TAudioMixer is there a way to set the default Device?

Thanks.

David
Davife
Member
Member
 
Posts: 4
Joined: August 21st, 2008, 9:23 am

Postby Kambiz » August 22nd, 2008, 1:10 pm

No, TAudioMixer has nothing to set default audio device.

I guess if you choose USB Microphone destination line, you can do recording without need to set SelectedLine, because there is only one line.

You may wonder to know that on Vista things are worst. I have a USB microphone and the first time that I attached it on Vista, it was working. Later I changed the USB port, and guess what, Vista no more recognizes the microphone even on the old USB port.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby Davife » August 22nd, 2008, 10:36 pm

Kambiz,
Thanks for the feedback even if the news could have been better. I'll be looking into it. I'll let you know if I find out anything of value.

David
Davife
Member
Member
 
Posts: 4
Joined: August 21st, 2008, 9:23 am


Return to DELPHI AREA Products

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron