LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-29-2018, 11:03 AM   #1
DeusDingo
LQ Newbie
 
Registered: Jun 2018
Posts: 11

Rep: Reputation: Disabled
ALSA: 2 input channels, only one is recording


So here is my pickle. I am very new to linux and to make matters worse i am working on an embedded system and not a PC. i have been searching for this topic but almost everything i find shows just 1 recording device.

we have a codec/sound card that has 2 input channels and 2 output channels and i need all of them at the same time. when i run my code to capture the audio samples i am only getting 1 channel and not the other. when i do arecord it is the same result.

my first series of questions are: Does ALSA only do 1 input at a time by default? if so is there a way to change that? if not does it mix the 2 inputs when doing an arecord or do i have to specify which channel i want?

my other thought about my issue is that it isn't being routed properly and it is taking the samples off an input that is not connected to anything. the thing is i can't figure out, in the OS, which port it thinks it is connected to. i think that is too deep into the hardware for linux to have an idea about that.

thanks for any help you can give
 
Old 08-30-2018, 08:24 AM   #2
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Hi DeusDingo,

For live recording in linux, jack (or jack2) is usually installed as an audio server, interacting with alsa (and pulseaudio if that is also installed), usually along with a whole other suite of tools. I have never heard of anyone doing multichannel recording without jack, at the very least.

Could you provide a bit of extra info on your setup ? For example:
  • Hardware: computer make and model / CPU class and version / amount of RAM / sound card (internal, external - which make and model) ... anything else

  • Software: version of linux you are using, desktop environment, sound recording and / or editing software ....
.. we can start there and move on.

Cheers !

Last edited by Rickkkk; 08-30-2018 at 08:29 AM.
 
Old 08-30-2018, 09:11 AM   #3
DeusDingo
LQ Newbie
 
Registered: Jun 2018
Posts: 11

Original Poster
Rep: Reputation: Disabled
hi rickkkk thanks for replying

so as i mentioned i am on an embedded system so this is going to be a little hard for me to get help, i am aware of that. it is running on a TI AM4378 ARM A9, it has 2 Gb of ram, the sound is coming out of a TI AIC3106 codec which is 2 channels (2 in, 2 out).

My linux version is 4.9.69 ubuntu

the special software is an application being developed.

so here is more information:

when i do "amixer" i get:
...
Simple mixer control 'Left PGA Mixer Line1L',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
...

which, if "Mono: Playback" means the samples are being collected is right

and

...
Simple mixer control 'Right PGA Mixer Line1L',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [off]
Simple mixer control 'Right PGA Mixer Line1R',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control 'Right PGA Mixer Line2R',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [off]
...

which looks like it is pulling from Line1R, which is wrong

even though in my DTS file i have:

simple-audio-card,widgets =
"Speaker", "POTS Line Out",
"Speaker", "Handset Speaker",
"Line", "POTS Line In",
"Microphone", "Handset Mic";
simple-audio-card,routing =
"POTS Line Out", "MONO_LOUT",
"Handset Speaker", "LLOUT",
"LINE2R", "POTS Line In",
"LINE1L", "Handset Mic",
"Handset Mic", "Mic Bias";

it would appear to me it is pulling the samples in from the wrong port
 
Old 08-30-2018, 10:22 AM   #4
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Hi again Deus,

Sorry - I had missed your original mention of an embedded system. I am unlikely to be able to offer much assistance, given my almost total unfamiliarity with such systems.

Your objective seems to be able to go quite low-level in your attempt to use the embedded audio device's native capabilities in a non-standard way (or at least relatively) for multichannel recording under linux. Perhaps other members here have tackled the issue before and will pipe in.

One place you might be able to get some help is on the linux musician's forum:

http://linuxmusicians.com

Cheers - let us know how you make out !
 
Old 08-30-2018, 10:38 AM   #5
DeusDingo
LQ Newbie
 
Registered: Jun 2018
Posts: 11

Original Poster
Rep: Reputation: Disabled
i know i have little chance of getting help in such a specialized environment. i have posts around to different forums to try and get an answer. i appreciate you looking though

so when i do:
amixer set 'Right PGA Mixer Line1R' off

amixer set 'Right PGA Mixer Line2R' on

and then do an arecord, i get the audio i was looking for. so it is routing the audio incorrectly

hopefully somebody can help me with this: in code (c) is there a way to do the input switching like above? i have been using snd_mixer_* commands but i am not sure how to use something like that to achieve what i want. or am i stuck using "system" calls?
 
Old 08-30-2018, 04:38 PM   #6
DeusDingo
LQ Newbie
 
Registered: Jun 2018
Posts: 11

Original Poster
Rep: Reputation: Disabled
i think i finally figured it out (after much searching:

/****************************************************************************************
* found @ https://alsa.opensrc.org/HowTo_access_a_mixer_control
*/
void SetInputToLine2R(void)
{

const char *card = "default";
const char *selem_name_line1r = "Right PGA Mixer Line1R Switch";
const char *selem_name_line2r = "Right PGA Mixer Line2R Switch";
int err;

snd_hctl_t *hctl;
err = snd_hctl_open(&hctl, card, 0);
err = snd_hctl_load(hctl);

snd_ctl_elem_id_t *id;
snd_ctl_elem_id_alloca(&id);
snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);
//snd_ctl_elem_id_set_id(id, 1);

snd_ctl_elem_id_set_name(id, selem_name_line1r);
snd_hctl_elem_t *elem = snd_hctl_find_elem(hctl, id);

if(elem != 0)
{
snd_ctl_elem_value_t *control;
snd_ctl_elem_value_alloca(&control);
snd_ctl_elem_value_set_id(control, id);

snd_ctl_elem_value_set_integer(control, 0, 0);
err = snd_hctl_elem_write(elem, control);

//turn on line2r
snd_ctl_elem_id_set_name(id, selem_name_line2r);
elem = snd_hctl_find_elem(hctl, id);

if(elem != 0)
{
snd_ctl_elem_value_set_integer(control, 0, 1);
err = snd_hctl_elem_write(elem, control);
}
}
snd_hctl_close(hctl);

}
 
Old 08-31-2018, 12:32 AM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
^ i'd have gone the shell script way, but if C works better for you, i guess that's better.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ALSA and PulseAudio - recording multiple input devices? Wintershade Linux - Software 4 04-30-2011 03:41 PM
ALSA - I need Line-Input recording with SB Audigy outspoken Linux - Software 0 05-21-2005 10:53 PM
ALSA Surround - Rear channels mmelin Linux - General 0 08-01-2004 03:18 PM
LynxTWO-c, six sound input channels jlgz Linux - Hardware 0 06-03-2004 03:26 PM
Don't know how to share channels with ALSA borrrden Linux - Hardware 14 05-07-2004 12:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration