[DEV] Galaxy S Dual Mic Recording

Search This thread

Quake2

New member
Oct 8, 2011
1
1
Hi, I'm almost new here :)
Since this is my first post, I cannot post in the development section, I hope this do not cause problems.

A few days ago I got my first android phone and started to do some low-level development and I needed to record both the input from the headset mic and the internal mic at the same time. I searched a lot on the net and did not find anything useful for the Galaxy S (Vodafone european I9000), so I decided to add this feature to the wm8994 driver included in the samsung kernel source for the Galaxy S.

Since I've never worked with this kind of device, I do not know if this is the correct way to do it, but it seems to work great.
Basicly I've enabled both input at the same time and routed left adc channel output to left audio interface channel and right adc channe output to right audio interface channel. Everything else is on default settings (as configured by MAIN and SUB path, in fact I've just used the same code).

The code also adds a new enum entry for the capture path, called "DUAL", which now is after "MIC OFF", but its just an hack, I'll clean it up later. Using the command "amix" will dump all the mixer channel:
Code:
...
   7 MIXER   0   0   0   1 rw        ENUM   Capture MIC Path { Main Mic=0, Hands Free Mic=1, BT Sco Mic=2, MIC OFF=3, Dual=4 }
...

It can be tested using the pcm_* and mixer_* routines taken from samsung's libaudio, you just need to call pcm_open without specifying PCM_MONO but just PCM_IN, since now both left and right channels will be populated. If you have access to Cyanogen Mod repository, just grab the arec.c source from there and remove the PCM_MONO flag. Beside this I suggest you to dump raw pcm audio and load it into something like Audacity, arec.c seems to produce a wrong riff header.

Now for the questions... :)

Any ideas on how to correctly setup the gain on both channels? Currently the gain of the headset mic is set to +15 dB on the input PGA and +0 dB on the adc channel while the gain of the internal mic is set to +10.5 dB on the input PGA and +0 dB on the adc channel. I also tried to use the same settings from Voodoo Sound high sensitivity path (with drc enabled), but no results so far... The default gain is far too low, I must talk very near to the headset mic.

Beside this, I've also noticed a strange behavior when recording from both mic. If they're very near, the audio recorded from the headset mic channel will be highly suppressed, if they're far apart, no suppression occurs. As far as I know, wm8994 do not perform noise cancellation on device, any clues on this? Anyway this is not a big deal, since the two microphones will be quite far during normal usage. By far the biggest problem is on the gain for the headset mic.

I hope someone might be interested on this extension to wm8994, this device is really powerful, it's a shame that samsung is using 1/10 of its power...

Attached to this post is the patch file, I've worked on the 2.6.35-12 (recently switched to -13) kernel from teamhacksung, you can get it on github (cannot post the link for the 8 post limit...), just apply the patch from the root kernel directory and rebuild the kernel image as usual.

Any help is highly appreciated :)

Thanks.
Bye!

EDIT: OPS :) I'm sorry but I forgot to mention that to enable dual mic recording, you have to activate its path of course through alsa_mixer, like this:
ctl = mixer_get_control(mixer, "Capture MIC Path", 0);
printf("ctl: %x\n", ctl);
if(ctl)
{
int r;
r = mixer_ctl_select(ctl, "Dual");
printf("res: %d\n", r);
}
forgive me :)
 

Attachments

  • dualmic.zip
    2.8 KB · Views: 124
Last edited:
  • Like
Reactions: xpcomputers

xpcomputers

Senior Member
Nov 11, 2006
135
15
Welcome to xda! .... That's a great first post!

Sorry to not have any info to help you, but I hope you find what you are looking for and get this working how you want.

I agree that Supercurio is probably the most clued up on audio for these phones. But you probably already knew that since you mention Voodoo Sound (which is his work).

Good luck

Mike
 

amalphard

New member
Nov 11, 2011
2
0
Hi, I'm almost new here :)
Since this is my first post, I cannot post in the development section, I hope this do not cause problems.

A few days ago I got my first android phone and started to do some low-level development and I needed to record both the input from the headset mic and the internal mic at the same time. I searched a lot on the net and did not find anything useful for the Galaxy S (Vodafone european I9000), so I decided to add this feature to the wm8994 driver included in the samsung kernel source for the Galaxy S.

Since I've never worked with this kind of device, I do not know if this is the correct way to do it, but it seems to work great.
Basicly I've enabled both input at the same time and routed left adc channel output to left audio interface channel and right adc channe output to right audio interface channel. Everything else is on default settings (as configured by MAIN and SUB path, in fact I've just used the same code).

The code also adds a new enum entry for the capture path, called "DUAL", which now is after "MIC OFF", but its just an hack, I'll clean it up later. Using the command "amix" will dump all the mixer channel:
Code:
...
   7 MIXER   0   0   0   1 rw        ENUM   Capture MIC Path { Main Mic=0, Hands Free Mic=1, BT Sco Mic=2, MIC OFF=3, Dual=4 }
...

It can be tested using the pcm_* and mixer_* routines taken from samsung's libaudio, you just need to call pcm_open without specifying PCM_MONO but just PCM_IN, since now both left and right channels will be populated. If you have access to Cyanogen Mod repository, just grab the arec.c source from there and remove the PCM_MONO flag. Beside this I suggest you to dump raw pcm audio and load it into something like Audacity, arec.c seems to produce a wrong riff header.

Now for the questions... :)

Any ideas on how to correctly setup the gain on both channels? Currently the gain of the headset mic is set to +15 dB on the input PGA and +0 dB on the adc channel while the gain of the internal mic is set to +10.5 dB on the input PGA and +0 dB on the adc channel. I also tried to use the same settings from Voodoo Sound high sensitivity path (with drc enabled), but no results so far... The default gain is far too low, I must talk very near to the headset mic.

Beside this, I've also noticed a strange behavior when recording from both mic. If they're very near, the audio recorded from the headset mic channel will be highly suppressed, if they're far apart, no suppression occurs. As far as I know, wm8994 do not perform noise cancellation on device, any clues on this? Anyway this is not a big deal, since the two microphones will be quite far during normal usage. By far the biggest problem is on the gain for the headset mic.

I hope someone might be interested on this extension to wm8994, this device is really powerful, it's a shame that samsung is using 1/10 of its power...

Attached to this post is the patch file, I've worked on the 2.6.35-12 (recently switched to -13) kernel from teamhacksung, you can get it on github (cannot post the link for the 8 post limit...), just apply the patch from the root kernel directory and rebuild the kernel image as usual.

Any help is highly appreciated :)

Thanks.
Bye!

EDIT: OPS :) I'm sorry but I forgot to mention that to enable dual mic recording, you have to activate its path of course through alsa_mixer, like this:

forgive me :)
@Quake2 : DO you have datasheet /pin diagram of wm8994

I would like to insert digital data on mic instead reading from analog input
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Hi, I'm almost new here :)
    Since this is my first post, I cannot post in the development section, I hope this do not cause problems.

    A few days ago I got my first android phone and started to do some low-level development and I needed to record both the input from the headset mic and the internal mic at the same time. I searched a lot on the net and did not find anything useful for the Galaxy S (Vodafone european I9000), so I decided to add this feature to the wm8994 driver included in the samsung kernel source for the Galaxy S.

    Since I've never worked with this kind of device, I do not know if this is the correct way to do it, but it seems to work great.
    Basicly I've enabled both input at the same time and routed left adc channel output to left audio interface channel and right adc channe output to right audio interface channel. Everything else is on default settings (as configured by MAIN and SUB path, in fact I've just used the same code).

    The code also adds a new enum entry for the capture path, called "DUAL", which now is after "MIC OFF", but its just an hack, I'll clean it up later. Using the command "amix" will dump all the mixer channel:
    Code:
    ...
       7 MIXER   0   0   0   1 rw        ENUM   Capture MIC Path { Main Mic=0, Hands Free Mic=1, BT Sco Mic=2, MIC OFF=3, Dual=4 }
    ...

    It can be tested using the pcm_* and mixer_* routines taken from samsung's libaudio, you just need to call pcm_open without specifying PCM_MONO but just PCM_IN, since now both left and right channels will be populated. If you have access to Cyanogen Mod repository, just grab the arec.c source from there and remove the PCM_MONO flag. Beside this I suggest you to dump raw pcm audio and load it into something like Audacity, arec.c seems to produce a wrong riff header.

    Now for the questions... :)

    Any ideas on how to correctly setup the gain on both channels? Currently the gain of the headset mic is set to +15 dB on the input PGA and +0 dB on the adc channel while the gain of the internal mic is set to +10.5 dB on the input PGA and +0 dB on the adc channel. I also tried to use the same settings from Voodoo Sound high sensitivity path (with drc enabled), but no results so far... The default gain is far too low, I must talk very near to the headset mic.

    Beside this, I've also noticed a strange behavior when recording from both mic. If they're very near, the audio recorded from the headset mic channel will be highly suppressed, if they're far apart, no suppression occurs. As far as I know, wm8994 do not perform noise cancellation on device, any clues on this? Anyway this is not a big deal, since the two microphones will be quite far during normal usage. By far the biggest problem is on the gain for the headset mic.

    I hope someone might be interested on this extension to wm8994, this device is really powerful, it's a shame that samsung is using 1/10 of its power...

    Attached to this post is the patch file, I've worked on the 2.6.35-12 (recently switched to -13) kernel from teamhacksung, you can get it on github (cannot post the link for the 8 post limit...), just apply the patch from the root kernel directory and rebuild the kernel image as usual.

    Any help is highly appreciated :)

    Thanks.
    Bye!

    EDIT: OPS :) I'm sorry but I forgot to mention that to enable dual mic recording, you have to activate its path of course through alsa_mixer, like this:
    ctl = mixer_get_control(mixer, "Capture MIC Path", 0);
    printf("ctl: %x\n", ctl);
    if(ctl)
    {
    int r;
    r = mixer_ctl_select(ctl, "Dual");
    printf("res: %d\n", r);
    }
    forgive me :)