Skip to contentSkip to conversation

Output to Input routing

DISCUSSION Vadim Lebedev 2 participants 4 messages Jul 31, 2007 – Aug 2, 2007

lore
Share & tools
lore
#0 lore raw

Hello,

I remember reading AC97 specs that there si possibility to configure it in such a way, that when doing stereo capture, left input channel will get actual MIC input and right input channel will get the copy of speaker output. This setting is ideal for echo cancellation algorithm.
To my grand dismay i'm unable to find a doc of ALSA mixer API so i'm unsucessuful writing code to put mixer in such mode.
Can some kind soul please contibuite a code snippet....

Thanks
Vadim

#1 lore raw

At Tue, 31 Jul 2007 14:33:04 +0000 (UTC),

Quoted 10 lines · Vadim Lebedev

Hello,

I remember reading AC97 specs that there si possibility to configure it in such a way, that when doing stereo capture, left input channel will get actual MIC input and right input channel will get the copy of speaker output. This setting is ideal for echo cancellation algorithm.
To my grand dismay i'm unable to find a doc of ALSA mixer API so i'm unsucessuful writing code to put mixer in such mode.
Can some kind soul please contibuite a code snippet....

Choose "Mix" as the capture source will give you the loopback input for the specific channel. You can change it via amixer, for example,

	% amixer cset iface=MIXER,name='Capture Source' 0,5
	numid=66,iface=MIXER,name='Capture Source'
	  ; type=ENUMERATED,access=rw------,values=2,items=8
	  ; Item #0 'Mic'
	  ; Item #1 'CD'
	  ; Item #2 'Video'
	  ; Item #3 'Aux'
	  ; Item #4 'Line'
	  ; Item #5 'Mix'
	  ; Item #6 'Mix Mono'
	  ; Item #7 'Phone'
	  : values=0,5

Takashi

#2 lore raw

Takashi Iwai <tiwai <at> suse.de> writes:
....

Quoted 3 lines
Quoted 1 line

This setting is ideal for echo cancellation algorithm.

% amixer cset iface=MIXER,name='Capture Source' 0,5

.....
Hi Takashi,
Tjis is very helpful, thanks a lot....
I wonder howvere if somoedy can post the same thing said in C?

Thanks
Vadim

#3 lore raw

At Thu, 2 Aug 2007 17:21:21 +0000 (UTC),

Quoted 10 lines · Vadim Lebedev

Takashi Iwai <tiwai <at> suse.de> writes:
....

Quoted 3 lines
Quoted 1 line

This setting is ideal for echo cancellation algorithm.

% amixer cset iface=MIXER,name='Capture Source' 0,5

.....
Hi Takashi,
Tjis is very helpful, thanks a lot....
I wonder howvere if somoedy can post the same thing said in C?

A shorter version is:

	system("amixer cset iface=MIXER,name='Capture Source' 0,5");

A longer version is something like:

	snd_ctl_t *handle;
	snd_ctl_elem_value_t *val;
	
	err = snd_ctl_open(&handle, "hw", 0);
	if (err < 0)
		return err;

	snd_ctl_elem_value_alloca(&val);
	snd_ctl_elem_value_set_interface(val, SND_CTL_ELEM_IFACE_MIXER);
	snd_ctl_elem_value_set_name(val, "Capture Source");
	snd_ctl_elem_value_set_enumerated(val, 0, 0);
	snd_ctl_elem_value_set_enumerated(val, 1, 5);
	err = snd_ctl_elem_write(handle, val);
	if (err < 0) {
		snd_ctl_close(handle);
		return err;
	}
	snd_ctl_close(handle);
	return 0;

Takashi