yashsingh1/xdaforums huggingface dataset:
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
Please remember to make a backup image of your phone before experimenting.

============ WARNING!! =============

The highest setting is VERY loud (as I found out) and could potentially rip apart the speaker on your phone!

Exercise extreme caution when using this. You risk permanent damage to your phone and your ears.​

2013-Jan-20

-----------------

Thanks xda-developers members "skvalex" who wrote ALSAMixer and "chdlock" who is helping me figure out

how ALSA is mapping the audio chipset, we can now temporarily adjust the Digital Volume on the Nexus 4.

Unfortunately, the selected volume doesn't "stick" because the audio driver re-writes it every time it re-opens an audio stream.

A stream is usually opened when a music track begins to play so then the digital volume will reset back to default.

We need a kernel developer to modify the audio driver so it opens an audio stream using a user-selected Volume level.

***

If you don't mind setting the volume frequently or just want to try this out here's what you need:

1) Get ALSAMixer from the Play Store. It was updated recently and you need the latest version.

Please consider a donation to the author.

2) You can re-program the audio chipset by editing fields in ALSAMixer. Here is a list of what we can control so far.

Headphones volume:

Left: RX1 Digital Volume (numid=27)

Right: RX2 Digital Volume (numid=28)

Speaker volume:

RX3 Digital volume (numid=29)

Camcorder volume:

DEC6 Volume (numid=39)

Microphone volume:

DEC7 Volume (numid=40)

-----------------------------------------------

old OPs

-----------------------------------------------

2013-Jan-15

----------------

The creator of ALSAMixer updated it to correctly install for Nexus4. (Uninstall removes the app but the ALSA libraries remain on the phone.)

https://play.google.com/store/apps/details?id=com.skvalex.alsamixer&hl=en

Thank you so much!

--------

http://xdaforums.com/attachment.php?attachmentid=1653124&d=1358438577

This is a piped output of "alsa_amixer -c 0 contents" from a stock Nexus 4 (4.2.1)

2013-Jan-13

-----------------

Is anyone successfully running ALSA on their Nexus 4?

If you do please share instructions to do so.

I am on stock 4.2.1(rooted/busybox) and I ran the AlsaMixer from

the Play Store but it doesn't seem to complete the installation.
[Nexus 4 Q&A, Help & Troubleshooting] ChongoDroid:
http://xdaforums.com/showthread.php...ited Edition Kit★☆★ | aokp,minco,pa,rasbean |

Shameless promotion

Sent from my Nexus 4
[Nexus 4 Q&A, Help & Troubleshooting] Nuu~:
Next you're going to tell me that you want systemd and PulseAudio on your device too, right?
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
I wiped to stock,

I installed AOKP-jb-mr1-build1,

then Nocturnal 1.4 LE for AOKP

and the ALSAMixer still doesn't work. It installs but I get the same blank screen with no settings.

What am I doing wrong?
[Nexus 4 Q&A, Help & Troubleshooting] ChongoDroid:
I'm not sure what that app is, I just meant that some of the audio mods in the kit ROM referred to ALSA audio libs.

As you can tell I'm not the expert, sorry if that's not what you were referring too :o

Sent from my Nexus 4
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
I am looking for a way to control the audio stream parameters in particular the gain of the microphone.

Somebody suggested using ALSA and I'm trying get it going.
[Nexus 4 Q&A, Help & Troubleshooting] chdloc:
I have only a Nexus 7, and the SoC is different from the Nexus 4, but look for alsa_amixer (installed by AlsaMixer) from within a console and execute

"alsa_amixer -c X contents" (without the quotes)

where X is one of the card numbers shown in your /proc/asound directory (e.g. card0 [X=0], card1 [X=1], etc). In my case, X=1 is the actual card where (a lot of) values can be set. One of those values is called "ADC Boost Gain"(I guess a programmable analog gain?).

I established a call with CSipSimple and successfully raised that parameter by 24dB in mid-call by executing "alsa_amixer -c 1 cset numid=20 2" [the default value was 0 and each step increases the level by 12dB]

You can query individual parameters by executing alsa_amixer -c X cget numid=Y

YMMV with the Nexus 4. Good luck!
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
Thank you! This looks really promising.

I only have "card0" aka [apq8064tablasnd].

When trying to execute "alsa_mixer -c 0 contents" I get an error stating that I'm missing

library "libasound.so". Any ideas what could be wrong?
[Nexus 4 Q&A, Help & Troubleshooting] chdloc:
I'm not sure whether libasound.so came with the AlsaMixer app. If it did you may need to copy the library into a system library path, e.g. /system/lib. If not, I could send you the library that I have. I actually forgot whether I found the library somewhere online or whether I cross-compiled it myself...
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
ALSA on Nexus 4 sound capabilities

ALSAMixer in the Play Store was updated to support Nexus 4. See OP.

---------------------------------------------------------------

The attached file is the output of running

alsa_amixer -c 0

I'm new to ALSA and have trouble figuring out which one is the microphone gain control.
[Nexus 4 Q&A, Help & Troubleshooting] amarb70:
I have installed this app but unfortunately I don't know how to completely uninstall it:( help please?:thumbup:

..sent from space.
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
If I understand correctly the app is just an installer that puts the ALSA libraries on your system.

If you are not using them it probably doesn't matter if they are there or not. You can contact the app creator about it.
[Nexus 4 Q&A, Help & Troubleshooting] chdloc:
Post the output of

alsa_amixer -c 0 contents

Any labels containing "ADC gain" or "Boost" would be prime candiates
[Nexus 4 Q&A, Help & Troubleshooting] Locksmith81:
Restore your back up
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
alsa_amixer c- 0 contents

Thank you for being so patient with me!

I'm such a Linux noob. It took me forever to figure out that I need 'su' to do anything.

I will update the OP to link to this file.
[Nexus 4 Q&A, Help & Troubleshooting] chdloc:
Holy smokes! This is one complicated mixer! And I've seen many.

It may help in narrowing choices down by you capturing another

alsa_amixer -c 0 contents

while you are on a call and look at the diffs. While you do that (being on a call, but don't run anything else that may use audio such as music playback apps) also report the output of

cat /proc/asound/card0/pcm0p/sub0/status

to make sure that phone calls are actually routed through ALSA. Anything but "CLOSED" is good.

I do not have a Nexus 4 so I cannot help trying to find the best parameters for a given application. The app ALSAMixer should help I would think.

Does this program now actually display anything?
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
It's a long shot but if you are in the New York tri-state area I wouldn't mind meeting up and letting you mess around with the Nexus4.

The invitation is open to anyone with ALSA experience. I would love to learn more about it first-hand.

As far as I can tell:

- ALSAMixer installs the ALSA libraries and displays the control set. I tried modifying a value with it and it didn't work.

It's a matter of wrong syntax I think, I will contact the app creator about it.

- Terminal Emulator works. I was able to change the value of "AUX_PGA_LEFT Volume" with the following command:

alsa_amixer cset numid=54 39

I'm not sure what this one does yet but I will investigate later today.

- unfortunately, during a phone call "proc/asound/card0/pcm0p/sub0/status" (playback) as well as

"proc/asound/card0/pcm0c/sub0/status" (capture) report "closed". Earlier I tried recording a voice call from an app

and trying to prepare an audio stream with MediaRecorder.AudioSource.VOICE_CALL throws an exception.

- when recording an audio stream with MediaRecorder.AudioSource.MIC and CAMCORDER

"proc/asound/card0/pcm0c/sub0/status" reports audio stream parameters. I'm attaching the piped output of

"alsa_amixer -c 0 contents" during a voice call, recording with mic and recording with camcorder.
[Nexus 4 Q&A, Help & Troubleshooting] chdloc:
This is fun...;)

There is certainly a difference between the "idle" set of parameters you had posted earlier and the ones that you took during a voice call.

I found some good information that explains the parameters here

https://github.com/psykick5/android_device_lge_mako/blob/master/snd_soc_msm_2x_Fusion3

Try to change numid=48 (i.e. 'ADC1 Volume') and numid=40 (i.e. 'DEC7 Volume'); these two parameters should change the microphone level, provided automatic gain control does not compensate for the changes.

(It bothers me, though, that the range of values shown by alsa_amixer and the ones shown in the above link don't match)

Make sure that the changes stick by issuing

alsa_amixer cget numid=X

For phone calls I would certainly change numid=65 (i.e. 'TX6 HPF cut off') from 0 (apparently really only a DC offset filter) to 2 (apparently a high-pass filter with a cutoff frequency of 150Hz), which would be good enough for HD voice.
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
Great find! This seems to be exactly what we need.

Most intriguing there are also facilities for Voice Call and FM Radio audio streams. Those are not currently working on

the Nexus4 at the moment and this might shed some light on a possible solution.

I find some of their nomenclature confusing. They use "TX" for recording and "RX" for playback.

Also they seem to set values twice - :1:0 for turn off and :1:1 for turn on. Do I have to issue commands twice?

I confirmed with 'cget' that I am indeed setting values with 'cset'.

It seems that DEC7 controls to the MICROPHONE stream and DEC6 the CAMCORDER.

I will focus my attention on these.

I was wondering about that myself. There is very bad low frequency noise on video recordings so I will

definetly look into this.
[Nexus 4 Q&A, Help & Troubleshooting] chdloc:
Actually, the nomenclature is quite common, TX, i.e. transmit [to the network] denotes the signal to be transmitted (taken from from microphone)

while RX is the receive signal [from the network] to be played back through a loudspeaker.

No, you will have to issue the command only once. Without having looked at the underlying code I tend to think that the first number denotes the type, i.e. integer vs string, and the second number the actual value.

Another interesting observation is that the SoC of the Nexus 4 seems to support SRS TruMedia via an effects mixer, which reportedly has potential to improve audio considerably (http://www.srstechnologies.com/content.aspx?id=1269 , I believe).
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
If SRS TruMedia is supported on the SoC it probably has to be calibrated for each device, I doubt it's configured out of the box.

The description on that site said something about SRS engineers working together with manufacturers on every product.

Personally, I'm an audio purist and I can care less about standards like these. I don't even want surround sound in my house.

With all that said, the S4 Pro is a very interesting SoC indeed and I'm very curious about OPPO's implementation in the Find 5.

They have a great reputation for sound quality and quality products in general. I can't wait to peek at some of their code.
[Nexus 4 Q&A, Help & Troubleshooting] chdloc:
I work in the area of audio. As a professional I would be interested in what SRS PureSpeech (component of SRS TruMedia),

http://www.srstechnologies.com/content.aspx?id=1963, offers.

(Like you, I'm a believer in true signal enhancement and not voodoo which has grown like a cancer in the audio industry.)

I assumed that SRS TruMedia may be enabled on the Nexus 4 due to the reference to

EffectsMixerCTL "SRS TruMedia"

in the SoC audio verb control code on github.

I also thought that the highpass filter that we identified above was part of the SRS TruMedia library.

Maybe this is not the case...
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
I could be wrong but I suspect a feature like SRS TruMedia will be heavily advertised. :eek:

The Nexus 4 is an exercise in cutting costs, there's no point in paying royalties for something like this, at least IMO.

----------------------------------------------------------------

Anyway, I got "something" done!

I figured out how to change the digital volume for the speaker.

=================== WARNING!! =====================

The highest setting is VERY loud (as I found out) and could potentially rip apart the speaker on your phone!

Exercise extreme caution when using this. You risk permanent damage to your phone.

alsa_amixer cset numid=29 X

Substitute X for a number between 0-124 to adjust the loudness of the speaker. I think 84 is default.

It is best tested by applying this command while playing music in the player. (no headphones)

In case you are wondering, numid=29 is an alias for the "RX3 Digital Volume" control.
[Nexus 4 Q&A, Help & Troubleshooting] chdloc:
FWIW, http://www.qualcomm.com/media/blog/...andles-51-surround-sound-capture-and-playback

Maybe it is not advertised because it is currently not enabled?
[Nexus 4 Q&A, Help & Troubleshooting] strikelight:
Thanks for your findings, Mindroid. numid=27/28 seem to be for left/right headphone... setting those between 90-93 helped me alot, thanks again!
[Nexus 4 Q&A, Help & Troubleshooting] ChongoDroid:
Re: [WORKING] ALSA on the Nexus 4

Edit: disregard

Sent from my Nexus 4
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
ALSAMixer was updated again and now we can now edit values directly from it's interface.

By directly editing the settings they stick until the audio stream is restarted because then the driver

writes it's default values over the ones we enter. A permanent solution should let us edit the

values that the driver writes when it opens an audio stream. It shouldn't be hard for a developer to

include that in the kernel.

Despite trying many settings I have not been able to eliminate the microphone noise.

Here is a list of what we can control so far.

Adjust headphones volume:

Left: numid=27 RX1 Digital Volume

Right numid=28 RX2 Digital Volume

Adjust speaker volume:

numid=29 RX3 Digital volume

Adjust Camcorder volume:

numid=39 DEC6 Volume

Adjust Microphone volume:

numid=40 DEC7 Volume
[Nexus 4 Q&A, Help & Troubleshooting] mikereidis:
Umm, no offense intended, but...

Unless you've done this type of development, I don't think it's easy to estimate the difficulty.

These modern audio hubs are VERY complex, having data sheets that run into the 300+ page mark. That's if you can find the info (most is secret) and doesn't include many associated documents, such as interconnections with SOC, BT, HDMI, mics, digital mics, etc.

I can, and have, spent weeks and months reading over the info and source code I can find and trying to see how it all fits together.

In any case, this is exactly what Supercurio did with Voodoo Sound for the Galaxy S, a 3 year old phone now. But amazingly with a WM8994 audio hub that is very similar to the GS3s WM1811.

The Qualcomm WDC9310 in the N4 and HTC OneS/XL etc. seems to be about the most complex audio hub I've seen among popular Android devices to date. Having ALSA controls numbering near the 300 mark should give a clue to that.
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
Oh, of course!

I agree that guessing how to program the Audio Mixer without the proper documentation borders on the impossible.

But as more phones come out with similar configurations our guessing abilities can improve a little.

I only meant that since we know what ALSA commands control the digital volumes developers can use them

to allow for user manipulation of the digital volume. We suspect that this file is used to program the Audio Mixer

when preparing audio streams.

https://github.com/stormtroopercs/android_device_lge_mako/blob/master/snd_soc_msm_2x_Fusion3

For example in line1872 a developer can substitute the default value of 68 for the digital volume for the Speaker

to a user-defined one.

I'm confused about the audio chip. The WDC9310 is indeed the DAC in the Nexus 4 but ALSA references

the S4 Pro SoC [apq8064tablasnd]. Is the Audio Mixer in the SoC or in the DAC?
[Nexus 4 Q&A, Help & Troubleshooting] mikereidis:
Not impossible, just takes time and experimentation. Yes, experience helps, and I'm in the process of getting mine. Chips that do the same thing tend to be rather similar.

Yes, that's an important file. It defines "use case" verbs, devices, and modifiers. For info on ALSA use case management: http://www.slimlogic.co.uk/2009/02/alsa-use-case-manager/ & http://opensource.wolfsonmicro.com/node/14

"EnableSequence" and "DisableSequence" are ALSA control settings to enable or disable a verb, device or modifier. ALSA PCMs may be specified for digital transfers. I think there's a lot of duplicated, overlapping and unused stuff in that file.

Call the wdc9310 an audio chip or hub. DACs (digital to analog converters) are just one of the many components inside these chips/hubs, and modern ones have many DACs (and ADCs, mixers, DSPs, PGAs, interfaces etc.)

Qualcomm has an interesting, and IMO successful strategy going with integrated solutions. The most common S4 designs are all Qualcomm, instead of, for example with Samsung GS/GS3, an audio chip from Wolfsson, an FM chip from Silicon Labs, a BT/WiFi chip (with unused FM) from Broadcom and the SOC an Exynos from Samsung.

Most S4 devices are all Qualcomm for major components: S4 SOC, wdc9310 audio, wcn2243 BT/WiFi/FM/(GPS ?) and a Qualcomm modem/BB of course.

The wcn2243 WiFi has a special high speed connection to the SOC.

Similarly, the wcn2243 FM and BT audio each have a special dedicated digital audio connection to the SOC. These are called "Internal". The wdc9310 audio chip connects to the SOC via a "Slimbus". I'm going from memory here and don't want to pore over datasheets and schematics right now, so I may be wrong about some details.

So, audio can be mixed digitally in the SOC, particularly when it comes from or goes to Bluetooth or FM. It can also be mixed in the wdc9310 audio chip. It depends on what your audio routing needs are, and what choices Google and LG made when building the Android audio system and the audio libraries/HALs, as well as whatever driver and hardware supports Qualcomm built in at the lower levels.

And mixing is just part of what can happen. DSPs can do all sorts of filtering, equalization, compression, sample rate conversions, echo cancellation, and many other things. So can/could software running on the SOC/applications processor, but the fancy stuff usually is done in "hardware" (meaning DSPs in the audio chip, but DSP internal processing may also be considered "software").
[Nexus 4 Q&A, Help & Troubleshooting] meangreenie:
hi thx for the info.

Can you tell me how to get the rx1/2 digital to stick at all? everytime i change it in the alsa app the volume goes up in the earphones only for a split second before returning to normal. (84)
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
I'm afraid we can't make it stick manually because the audio driver re-writes it every time it re-opens an audio stream.

A stream is usually opened when a music track begins to play so then the digital volume will reset to default.

I tried it with the Apollo Music and interestingly it kept the stream open the entire time the app was running.

We need a kernel developer to modify the audio driver so it opens an audio stream using a user-selected Volume level.
[Nexus 4 Q&A, Help & Troubleshooting] kn100:
Finally a proper way to boost the volume on this handset! A value around 91 seems perfect and the volume is significantly better. Thanks to everyone in this thread!
[Nexus 4 Q&A, Help & Troubleshooting] chdloc:
Hmm, I don't think this is a driver-level (kernel space) issue. I suspect every application sets its own levels through a library called libaudioflinger during their respective initialization stage (application space). Note that not all devices support ALSA (e.g. my Nexus One does not), so there needs to be a level of abstraction for being able to support a wide range of devices. So I doubt there are many applications that access ALSA directly.

For ALSA-based devices, someone with more spare time could look into porting the LADSPA family of libraries, see www.ladspa.org, which can act as ALSA plugins to perform a wide range of signal manipulation tasks (volume, filtering, etc). For this to work we will need to redirect the default audio interface to use the plugins. On Linux, this can be done with a file called .asoundrc in a user's home directory or system-wide with a file called asound.conf sitting somewhere in the system path...
[Nexus 4 Q&A, Help & Troubleshooting] frontomix:
I thing, the Nexus 4 LG-E960 service manual could help us:

Google for EN_LG-E960_SVC_ENG_121121.pdf :rolleyes:

:cowboy:
[Nexus 4 Q&A, Help & Troubleshooting] meangreenie:
how do you get it to stick for more than a split second ?:confused:

what music app etc ? everyone i have tried don't work wether i use settings before/during/or after playing a song
[Nexus 4 Q&A, Help & Troubleshooting] mikereidis:
I mentioned Supercurio's voodoo kernel driver before, which intercepted calls to the audio driver. It's quite a bit of work, and requires special kernel support.

Later I realized a relatively simple app could do this:

1 - Regularly poll the ALSA controls to see if they change. Or since polling is "evil", tie into some callback event that happens shortly after audio is setup.

2 - If they change to wrong values, re-write them with what you want.

3 - Profit. :)
[Nexus 4 Q&A, Help & Troubleshooting] -Mindroid-:
It depends on how the music player ( on the specific app that makes the sound ) is implemented.

The values seem to stick for a long time with the Apollo music player.
[Nexus 4 Q&A, Help & Troubleshooting] meangreenie:
Does this file have anything there to control volume ?

.. system/etc/snd_soc_msm/snd_soc_msm_2x_Fusion3
[Nexus 4 Q&A, Help & Troubleshooting] Laurentwb:
This thread has no activity since a long time but I try in case someone is still following it.

Is there a way to keep new settings with Tasker ?

Laurent
[Nexus 4 Q&A, Help & Troubleshooting] marcelkraan:
handsfree mic

EDIT:

I already found the answer myself

I changed all the "DEC*" volumes

'DEC4 Volume':1:20

'DEC7 Volume':1:20

'DEC8 Volume':1:20

'DEC9 Volume':1:20

etc etc

Does anyone know which device is the "hands free" speaker volume?

i need to lower the speaker input from the handsfree option

thanks in advantage