Prabhu,
Most codecs have only ONE analog to digital converter (ADC). That means
you can only record ONE digital stream at a time (mono or stereo).
In front of the ADC there can be a mixer, combining some ANALOG signals.
Instead of a mixer there could also be a selector, that can select only
one input at a time.
We still need to know something about your hardware and what you try to
do:
* Do you have two ADC's and do you want to record LINE on one ADC,
MIC on the other ADC?
* Or: do you have one ADC and do you want an analog mixer to
combine the two analog signals, then send them to the ADC?
Then the SW driver will indicate that you have a LINE input and
a MIC input, and in this case you can use them at the same time.
Also, don't forget to control the volumes of each input before
mixing.
* Or: do you have one ADC and an analog input selector, that can
only select one input at a time?
Then the SW driver will indicate that you have a LINE input and
a MIC input, but is does NOT mean you can use them at the same time.
* Or: are you being creative and do you want to record LINE on the
right channel, MIC on the left channel of a stereo ADC?
The software will most likelly not support this.
Maybe we could help you better if you specify the actual hardware ADC
chip (and software driver) that you use.
Kind regards,
Arie de Muijnck
________________________________
From: [email protected]
[mailto:[email protected]] On
Behalf Of Prabhu Kalyan Rout
Sent: Tuesday, March 10, 2009 12:43
To: Steve Chen
Cc: [email protected]
Subject: Re: Need help
Hi Steve,
as i said my audio codec supports to select more then one recording
source at a time. so i download one application and did some
changes to capture from both the surface at the same time by orring with
both LINEIN and MIC.
But i got the below error
Failed to ask mixer for available recorders -- 1.
: Invalid argument
but recording from individual sources working fine. So what is the right
way to select both the recording source at the same time. Below is the
code
that i executed.
/* Standard Linux headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <signal.h>
#include <getopt.h>
#include <pthread.h>
#include <errno.h>
#include <linux/soundcard.h>
#define FAILURE -1
/* The number of channels of the audio codec */
#define NUM_CHANNELS 1
/* The sample rate of the audio codec */
#define SAMPLE_RATE 8000
/* The gain (0-100) of the left and right channels */
#define LEFT_GAIN 100
#define RIGHT_GAIN 100
/* Number of samples to process */
#define NUMSAMPLES 320
/* Mono 16 bit */
#define RAWBUFSIZE NUMSAMPLES * 2
/* Stereo 16 bit */
#define INPUTBUFSIZE NUMSAMPLES * 2
unsigned short rawbuf[RAWBUFSIZE],inputbuf[INPUTBUFSIZE];
int main()
{
int vol = LEFT_GAIN | (RIGHT_GAIN << 8);
int channels = NUM_CHANNELS;
int sampleRate = SAMPLE_RATE;
int format = AFMT_S16_LE;
int soundFd;
int mixerFd;
int recMask;
/* Open the sound device for writing */
if ((soundFd = open("/dev/dsp", O_RDWR)) == -1) {
printf("Failed to open the sound device (/dev/dsp)\n");
return FAILURE;
}
/* Set the sound format (only AFMT_S16_LE supported) */
if (ioctl(soundFd, SNDCTL_DSP_SETFMT, &format) == -1) {
printf("Could not set format %d\n", format);
return FAILURE;
}
/* Set the number of channels */
if (ioctl(soundFd, SNDCTL_DSP_CHANNELS, &channels) == -1) {
printf("Could not set mixer to %d channels\n", channels);
return FAILURE;
}
/* Set the sample rate */
if (ioctl(soundFd, SNDCTL_DSP_SPEED, &sampleRate) == -1) {
printf("Could not set sample rate (%d)\n", sampleRate);
return FAILURE;
}
/* If we are sampling select the right capture device and volume */
if ((mixerFd = open("/dev/mixer", O_RDONLY)) == -1) {
printf("Failed to open /dev/mixer\n");
return FAILURE;
}
recMask |= SOUND_MASK_MIC;
recMask |= SOUND_MASK_LINE;
if (ioctl(mixerFd, SOUND_MIXER_WRITE_RECSRC, &recMask) == -1) {
perror("Failed to ask mixer for available recorders --
1.\n");
return FAILURE;
}
if (ioctl(mixerFd, SOUND_MIXER_READ_RECMASK, &recMask) == -1) {
printf("Failed to ask mixer for available recorders --
2.\n");
return FAILURE;
}
if ((recMask & SOUND_MASK_MIC) == 0) {
printf("Line input not a supported recorder.\n");
return FAILURE;
}
if ((recMask & SOUND_MASK_LINE) == 0) {
printf("Failed to read the current recorder.\n");
return FAILURE;
}
if (ioctl(mixerFd, SOUND_MIXER_WRITE_IGAIN, &vol) == -1) {
printf("Failed to set the volume of line in.\n");
return FAILURE;
}
close(mixerFd);
printf("Audio sample rate set to %dHz\n", SAMPLE_RATE);
int outputFd = open("audio",O_WRONLY | O_CREAT | O_TRUNC, 00644);
int i=0,numBytes;
if (outputFd == -1) {
printf("Failed to open file for writing\n");
exit(0);
}
while(i++<500)
{
numBytes=read(soundFd, inputbuf, INPUTBUFSIZE);
if(numBytes==-1)
{
printf("error\n");
exit(0);
close(outputFd);
}
else{
printf("numBytes=%d\n",numBytes);
}
usleep(10);
write(soundFd, inputbuf, INPUTBUFSIZE);
//stereoToMono(inputbuf, rawbuf, NUMSAMPLES);
if (write(outputFd, inputbuf, INPUTBUFSIZE) == -1) {
printf("Error writing the encoded \n");
close(outputFd);
exit(0);
}
}
close(outputFd);
close(soundFd);
return 0;
}
Steve Chen wrote:
On Mon, 2009-03-09 at 19:42 +0530, Prabhu Kalyan Rout wrote:
Actually i wanted to record from both MIC and LINE IN at the
same
time. From the
It would be difficult to record separate audio streams on mic and
line-in since both goes to the same ADC.
below code i found that my codec does supports that
status = ioctl(fd, SOUND_MIXER_READ_CAPS, &caps);
if (status == -1)
perror("SOUND_MIXER_READ_CAPS ioctl failed");
if (!(caps & SOUND_CAP_EXCL_INPUT))
Thanks
Viral Sachde wrote:
On Mon, Mar 9, 2009 at 3:38 PM, Prabhu Kalyan Rout
<[email protected]>
<mailto:[email protected]> wrote:
Hi,
My requirement is to capture from both LINE IN
and MIC. But current OSS
functionality does not allow us to do that
Can any body tell me how to achieve this
functionality using OSS as the
driver?
Thanks
Do you mean, you wish two separate analog input support,
one inserted
in Line-in, another in Mic ?
______________________________________________________________________
http://www.mindtree.com/email/disclaimer.html
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
________________________________
http://www.mindtree.com/email/disclaimer.html
This message contains confidential information and is intended only for the
individual named. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and delete
this e-mail from your system. E-mail transmission cannot be guaranteed to be
secure or error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents of this
message, which arise as a result of e-mail transmission. If verification is
required please request a hard-copy version.
Please consider the environment before printing this email message
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source