[DEV] Galaxy S Dual Mic Recording - Galaxy S I9000 General

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);
}
Click to expand...
Click to collapse
forgive me

i think you should contact supercurio ( https://twitter.com/#!/supercurio )
he's a real badass when it comes to tweaking WM8994 driver
also you might want to check out his app called "voodoo control (plus)"

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

Quake2 said:
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
Click to expand...
Click to collapse
@Quake2 : DO you have datasheet /pin diagram of wm8994
I would like to insert digital data on mic instead reading from analog input

Related

answering machine (without recording, I have read others)

Well from reading other threads I learned that an answering machine software is not possible due to lacking ability to record from the radio audio output (on most phones, possible on univ?).
Well then how about not recording, but automatic pickup and sending prerecorded audio? Would that be possible? Like in: someone calls my phone->software picks up and plays back prerecorded message to caller "I'm in a meeting, please call back at 5pm" ->software hangs up.
Possible or not? Who would be willing to write something like this?
I think there's the same issue - the phone audio path is seperated from the PDA audio path. Read Odeean's posts on TAPI and his frustrations. However, the http://teksoftco.com boys seem to have hinted that this may in fact be possible anyway.
It may be possible I suppose, by writing specific drivers, but I don't think any of us have ever tried I guess.
V
We'll keep you updated with what can be done altough the system is not built to support this kind of features. Firstly because in the US recording audio on phone conversation is ilegal so MSFT doesn't supports this and onestly i don't see HTC being able to offer this kind of support.
Also what Vijay outlined is correct... but we have a few more ideas that we are curently testing...as i said we'll post it if we succeded.
Cheers,
Raul
i believe that it is not a hardware limitation.
The sound from the gsm is not analogue. It passes through the OS somehow, otherwise how is the audio transmitted to the bt hfree?
I don't believe that the transmition of audio (from gsm) to the bt hfree is done only by hardware.
Please comment
andrew_sh is making a good point there. Maybe something can be done by "faking" bluetooth data input?
We have a working answering machine on Himalaya.
See last ROM from TofClock...
Good point made by Andrew. A new bluetooth headset driver or a fake one might do the trick. Cross your fingers guys.
The OS has evolved since Himalaya and HTC has restricted access to drivers by creating a locking mechanism and also the signing process is a hop to pass.
Guys, from my understanding and a poll I've run:
http://forum.xda-developers.com/viewtopic.php?t=40100&highlight=telephone+poll
it doesn't seem like many people have succeeded in recording calls, and those that have are generally using the Himalaya only. The gigabyte can, but it has custom hardware.
We've discussed spoofing the bluetooth audio path before by using a dummy driver and receiver, but mamaich has stated that the audio path for the bluetooth is in hardware only, and seperated from the interceptable paths in the OS.
Rain (for those who don't know, is one of the genii at http://teksoftco.com) - if you have any new ideas, may I ask you to PM me?
Odeean, Mamaich and I have had numerous discussions about this and I'd be interested to know how your research is going. I read that you guys have experience at low level audio driver work (great work on the speakerphone btw!), and I think that might be a good way to go. There is certainly some OS control of the audio path (speakerphone, mute, headset<>bluetooth etc), so I've thought about this way...
V

Microphone Gain Control and Current Audio Path

Hello, all
Hopefully there're some real developers here who can help me
Recently developing VoIP App for HTC devices I've found that none of them support 'Hardware Mixer' functionality. This means that mixerGetNumDevs() had returned 0 for all 4 different devices I had.
My App should at least control Microphone Input Gain to prevent signal distortion with echo from loudspeaker. In addition I'd like to control current audio path, because all HTC devices use rear loudspeaker indstead of the front one when you try to use waveOutOpen() with the single supported device ID (0).
Did anyone here develop audio recording/playing solution???
Are there any hints on this problem???
Please, help me, if you can
P.S. For now it looks like HTC produces the worst devices in the World from developers' point of view

Getting valid PCM data from the Mic

Hey guys,
I am trying to record some pcm data from the built in microphone in my windows mobile 6 phone. (ATT Tilt)
I am using Waveform Audio functions to accomplish this and have a program written that looks for available input devices, lets me select from the found devices and then proceeds to store a few second's worth of data into my buffer.
Everything goes smoothly - the device opens and all of my calls to the waveform audio functions return MMSYSERR_NOERROR. When I start recording, I physically loop for the expected amount of time while I wait for the buffer to fill and once it finishes my WAVEHDR contains the expected number of samples.
The problem is that WAVEHDR.lpData is still all zero'd out (I zero it before I begin using it), except for the first byte which is always set to 0x03.
My two questions right now are these:
1 - My phone reports a single device, whose szPname is "Audio Input". Sounds pretty generic to me. I've not been able to find anything about what I should expect to see on google or searching the forums. I am wondering if this is really all I should be seeing?
2 - Assuming I am connecting to the correct input device to receive mic input, are there any cases where it might legitimately fill my buffer with zeroes?
Thanks,
Nick

EVO A2DP Quality

I just picked up an EVO and I'm pretty disappointed in the BTAudio quality on such a high end phone. I have the Blackberry media gateway hooked up in my car and paired to my iPod touch and iPhones it sounds indistinguishable from hooking the aux jack up directly to the phone/iPod.
When I connect the evo, I get a lot of crunching and distortion in the mid's and highs. In WinMo I could simply alter the bitpool settings in the registry to solve this issue, however as a first time android user I am at a loss as to how to make those changes.
Android seems like a far superior OS so there has to be a way to change these settings if it was that simple in WinMo. Can anyone point me in the right direction?
I just found this page here which discuss some terminal and backend files in OSX for modifying these settings. Is there any similar file or terminal command we can do on our own unix based systems?
naorion said:
I just picked up an EVO and I'm pretty disappointed in the BTAudio quality on such a high end phone. I have the Blackberry media gateway hooked up in my car and paired to my iPod touch and iPhones it sounds indistinguishable from hooking the aux jack up directly to the phone/iPod.
When I connect the evo, I get a lot of crunching and distortion in the mid's and highs. In WinMo I could simply alter the bitpool settings in the registry to solve this issue, however as a first time android user I am at a loss as to how to make those changes.
Android seems like a far superior OS so there has to be a way to change these settings if it was that simple in WinMo. Can anyone point me in the right direction?
Click to expand...
Click to collapse
I have been looking for ways to adjust the bitpool, linespeed etc like we used to do in winmobile. Despite googling everything related have come up with nothing. Also went into the recently released htc source code. But I am not a programmer and not sure where to look. Only thing I have noted using the logcat file is that the bitpool is 32 and bitrate 229
W/BTLD ( 1677): ### :: codec open ::
W/BTLD ( 1677): ### mtu 512, 660 bytes/frame, bitrate 229, nbr ch 0, freq 240
W/BTLD ( 1677): ### alloc : 3, blk len 240, chmode:15, bitpool 32:2, subbands 12
I have the same problem on my sony radio the Bluetooth audio streaming sounds like crap I get a background hiss and crackling on the highs.
I attempted to ask some questions on how to adjust these settings but seems Dev's don't look in the Q&A section no wonder development is always crowded with crap threads.
http://forum.xda-developers.com/showthread.php?t=724023
Thread about the matter.
come over to this thread for more info
http://forum.xda-developers.com/showthread.php?p=10006164#post10006164
Have you tried DSPManager yet to see if that helps clean it up? Just a thought.

Adjust Parametric Equalizer of Wolfson DAC (Voodoo/Boeffla)

As many out there know the wolfson audio DAC has been the subject of many sound mods to improve smartphone sound quality. Supercurio was the pioneer in this and made some great DAC control enhancements namely voodoo sound. This has been continued with the work of the boeffla sound, scooby doo and various wolfson control programs in many kernels for the Note 2, S3 intl. In both boeffla and voodoo mods there is a section for activating the onboard parametric equalizer of the DAC. What has NOT been available is a way to adjust the frequency, bandwidth of the bands. So we were left with fixed bands that could have gain adjustment only. Up to now I have been using the parametric equalizer of Neutron player which is quite good but thought why not try to do the same thing with the wolfson DAC directly. Since it is an on chip feature it takes not extra cpu time or battery use. Looking through many posts and boards, there was no real data on how to do this. So I started tinkering with the equalization band parameters directly and was able to get frequency adjustment changes looking at RMAA curves. But there seemed to be no good pattern to what I was doing. I was ready to just give up but found a post on a raspberry pi thread about changing some registers on the wolfson DAC and was finally able to do it. So here it is:
Go to http://www.wolfsonmicro.com/support/wisce and download the WISCE software for the 8994 board. Then download the 8994 "board" http://www.wolfsonmicro.com/product...ments/uploads/software/WM8994Setup_Rev3_0.zip.
Install the wisce, then the 8994 board.
Do not open either yet.
After all installed, open the 8994 program, create a new system, choose simulated and keep the default device, hit ok and you are ready.
Proceed down the left side to Tuning- A1F1Dac1, if you click that you will see the equalizer settings and curve.
Here you can adjust the center freq, high and low pass filters and bandwidth of each.
When you are satisfied , go to the View menu and choose registers.
See the screen shot but the values you are interested in are circled, they correspond to the file in sys/devices/virtual/misc/voodoo_sound/headphone_eq_bands_values. They are in hex. In wolfson/boeffla they are in a different file but in decimal. Under the File/Preferences menu of wisce you can change the display to decimal so no need to hand convert.
The gain must be set independently, so in the same folder sys/devices/virtual/misc/voodoo_sound, there will be files for gain of bands 1-5. Be gentle here, or you will get clipping. In fact I would make cuts in the parametric settings at least equal to your gains. If you use Neutron , you can set up a similar equalization curve, "normalize" the tracks to the curve and Neutron will set the preamp gain for each track individually. Then just disable Neutron's equalizer and the gain settings will still stick for the wolfson DAC changes.
Make sure that you go into either boeffla or voodoo settings and enable the bass booster, or equalizer even if you don't want the extra bass. That enables the use of the settings.
The changes may not survive a reboot and the equalization bands file will only show the changes if a headset is in the jack
I use tasker to overwrite the files each reboot and have a different profile if I am using my Shure 535 with a microphone control vs playing to a speaker setup(3 band plug)
Here is the result using RMAA including neutron as my original base.
Happy tuning!
Additional Note 2 tech data:
Hi
this applies to the nexus? 5-6
perobot said:
this applies to the nexus? 5-6
Click to expand...
Click to collapse
Sorry no
But see http://forum.xda-developers.com/android/software-hacking/reference-qualcomm-audio-codec-iir-t3093000
Pretty interesting, you know your stuff. Am i able to use this with my note 2 n7100?

Categories

Resources