Page 1 of 1

Setting Mixer input level

PostPosted: March 30th, 2007, 7:01 pm
by ejla
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;

PostPosted: March 30th, 2007, 10:15 pm
by Kambiz
When destination of a TAudioMixer object is recording controls, Volume acts as input level. See Mixer Control demo a the sample.

PostPosted: March 31st, 2007, 12:01 am
by ejla
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

PostPosted: March 31st, 2007, 9:21 pm
by Kambiz
It's quite simple, set AudioMixer.DestinationID to 1 and set Volume of your desired line. It will change the input level.

PostPosted: August 2nd, 2007, 10:35 am
by domi.papin
Hello,

Just to mention that with my config. I get the wavein microline on DestionationId = 2

PostPosted: August 6th, 2007, 1:42 pm
by domi.papin
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;

PostPosted: August 6th, 2007, 4:43 pm
by Kambiz
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;

PostPosted: August 8th, 2007, 9:51 am
by domi.papin
thanks for the tip Kambiz and keep up your good work :)

Selecting a Microphone

PostPosted: August 21st, 2008, 9:38 am
by Davife
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.

PostPosted: August 21st, 2008, 12:03 pm
by Kambiz
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.

PostPosted: August 21st, 2008, 5:17 pm
by Davife
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?

New input

PostPosted: August 22nd, 2008, 6:27 am
by Davife
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

PostPosted: August 22nd, 2008, 1:10 pm
by Kambiz
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.

PostPosted: August 22nd, 2008, 10:36 pm
by Davife
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