ALSA on the Nexus 4 (temporary volume control) - Nexus 4 Q&A, Help & Troubleshooting

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://forum.xda-developers.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.

http://forum.xda-developers.com/sho...ited Edition Kit★☆★ | aokp,minco,pa,rasbean |
Shameless promotion
Sent from my Nexus 4

Next you're going to tell me that you want systemd and PulseAudio on your device too, right?

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?

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
Sent from my Nexus 4

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.

-Mindroid- said:
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.
Click to expand...
Click to collapse
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!

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?

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...
Sent from my Nexus 7 using xda app-developers app

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.

I have installed this app but unfortunately I don't know how to completely uninstall it help please?:thumbup:
..sent from space.

amarb70 said:
I have installed this app but unfortunately I don't know how to completely uninstall it help please?:thumbup:
..sent from space.
Click to expand...
Click to collapse
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.

-Mindroid- said:
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.
Click to expand...
Click to collapse
Post the output of
alsa_amixer -c 0 contents
Any labels containing "ADC gain" or "Boost" would be prime candiates

amarb70 said:
I have installed this app but unfortunately I don't know how to completely uninstall it help please?:thumbup:
..sent from space.
Click to expand...
Click to collapse
Restore your back up
Sent from my Nexus 4 using xda premium

alsa_amixer c- 0 contents
chdloc said:
Post the output of
alsa_amixer -c 0 contents
Any labels containing "ADC gain" or "Boost" would be prime candiates
Click to expand...
Click to collapse
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.

-Mindroid- said:
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.
Click to expand...
Click to collapse
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?

chdloc said:
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?
Click to expand...
Click to collapse
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.

-Mindroid- said:
[...]
- 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.
Click to expand...
Click to collapse
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.

chdloc said:
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
Click to expand...
Click to collapse
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'.
chdloc said:
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
Click to expand...
Click to collapse
It seems that DEC7 controls to the MICROPHONE stream and DEC6 the CAMCORDER.
I will focus my attention on these.
chdloc said:
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.
Click to expand...
Click to collapse
I was wondering about that myself. There is very bad low frequency noise on video recordings so I will
definetly look into this.

-Mindroid- said:
I find some of their nomenclature confusing. They use "TX" for recording and "RX" for playback.
Click to expand...
Click to collapse
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.
-Mindroid- said:
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?
Click to expand...
Click to collapse
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).

Related

ADB Screenrecord longer than 3 minutes

I didn't know where to put this and I own a moto g so I decided to put it here.
As many people will know, in android 4.4 an inbuilt screen recorder was released. This recorder requires you to initiate the recording process using ADB and USB debugging, this seems great until you notice that the maximum length of a recording is 3 minutes.
Now, on windows I made a batch file which looks something like this:
CALL :Record
SET /a var1=0
:record
SET /a var1+=1
SET /a name=%var1%
adb shell screenrecord /sdcard/recording%name%.mp4 --bit-rate 3145728
GOTO :record
Click to expand...
Click to collapse
The batch file basically creates a loop which restarts the recording every time the previous recording finishes, every time the script loops 1 will be added to the number in the recording meaning the files will not overwrite each other so it will start with a file named "recording1.mp4" and then after 3 minutes it will make a new recording named "recording2.mp4".
I decided to use a 3mbps bit rate as it looks decent in 720p and doesn't effect the framerate in games as much as the default 4mbps although you can change it at any time by editing the .bat file.
There is a small gap between the recordings but it seems bearable between the test recordings I have done. It can be ended by pressing CTRL+C and then pressing Y to clear batch process.
You should be able to put this into notepad and save it as a .bat file and place it inside your adb folder within the android sdk folder.
I have attached the .bat file for download purposes.
Update
I have updated the bat file so that the user inputs the filename and bit rate before the recording starts, I also got rid of the %name% variable as it wasn't actually needed and I don't know why I included it at the time.
The new file looks like this:
@ECHO off
ECHO Welcome to TheDJGr33n's ADB recording script for windows.
SET /p filename=Filename:
ECHO I usually use 3mbps.
SET /p mbps=Bitrate(In mbps):
SET /a bitrate=%mbps%*1048576
CALL :Record
SET /a var1=0
:record
SET /a var1+=1
ECHO Recording %var1% started Filename:%filename%%var1%.mp4 at bitrate %mbps%mbps.
adb shell screenrecord /sdcard/%filename%%var1%.mp4 --bit-rate %bitrate%
GOTO :record
Click to expand...
Click to collapse
I will attach the new bat file to this reply.
TheDJGr33n said:
I have updated the bat file so that the user inputs the filename and bit rate before the recording starts, I also got rid of the %name% variable as it wasn't actually needed and I don't know why I included it at the time.
The new file looks like this:
I will attach the new bat file to this reply.
Click to expand...
Click to collapse
Is it possible to use screen recording with audio in non root moto g
androidsatti said:
Is it possible to use screen recording with audio in non root moto g
Click to expand...
Click to collapse
To do this I would recommend you get a 3.5mm to 3.5mm cable, these can be found on amazon for under £1, I would post a link but I'm unable due to the lack of posts on this account.
You would plug one end into your phone's headphone port and the other into your PC, then you could use a program like audacity to record the input as a microphone. The audio would need to be synced up in editing later but it could work.
Thanks friend I l try it
Sent from my XT1033 using XDA Free mobile app
Hi friend
I used this batch file and I am able to get decent frame rates for games.after 3 mins its showing y/n to continue.but I didn't got the screen recording for more than 3 mins
Sent from my XT1033 using XDA Free mobile app

[Q] Help needed - difference in volume between music apps

Hi all, [I did a forum search using volume galaxy note 3; volume mod galaxy note 3 and didn't find anything related to my post below]
I have quite a bit of a head scratcher here and I'm not sure which way to go to resolve it....
I have an AT&T Galaxy Note 3 that is rooted running stock MJ5 firmware. When playing music using the speaker and built-in music app (or when setting up the sounds to use for ringtone, notifications, etc.), the volume output is decent respective to it's factory output level. However when I'm playing music via PowerAmp or JetAudio Plus - the volume output is not at the same level as it is with the built-in music app. I've made sure that AGC is off in JetAudio, de-selected the Limit option in PowerAmp, and checked and unchecked the Direct Volume Control option within the advanced audio settings in PowerAmp. In spite of all that I have checked - the volume output is not the same and it's driving me crazy. Here are all of the things that I've done so far (in no particular order) to see if I can 'fix' the problem:
1) Factory Reset my phone (from within the OS itself)
2) I've tried using the Volume Boosting Mods found in this forum post to see if that would correct anything.
3) Performed a FULL firmware restore (courtesy of this post) to see if I mucked something up along the way. (I kind of messed up my haptic feedback which was the catalyst for the restore. The volume restore was along for the ride at that point )
None of the above seems to work (EVEN with the firmware restore). Please note that with the firmware restore - I tested it out BEFORE loading my applications (except for JetAudio and PowerAmp). What makes the built-in music application different than apps such as PowerAmp, JetAudio, etc. that it accesses a different volume stream (say digital vs. analog)? (I know that last question was kind of confusing, but think of it as being analogous to Line Out vs. the 3.5mm headphone port for external sound output )
I know that the file used for modifying volume output levels is located in system/etc/snd_soc_msm (the file snd_soc_msm_Taiko_CDP is what's used to make the mods) but is there a specific line or lines contained within that file that control analog volume output for the built-in speaker?
I'm not sure how the PowerAmp or JetAudio app is configured to access volume output streams (if that makes any sense) but there seems to be something different because the volume output drops pretty badly when using either of these apps vs. the stock music player.
Has anyone else noticed this oddity (and found a way to fix it) or am I the odd man out here ?
Any help would be appreciated.
Silly question: Did you try disabling Adapt Sound?
ShadowLea said:
Silly question: Did you try disabling Adapt Sound?
Click to expand...
Click to collapse
I don't recall having Adapt Sound enabled (I did see it but don't remember having any checkboxes ticked....). I'll reply back once I downgrade my phone back to JB (I was forced to take an OTA update to kitkat and I need root access).
rob.allen78 said:
I don't recall having Adapt Sound enabled (I did see it but don't remember having any checkboxes ticked....). I'll reply back once I downgrade my phone back to JB (I was forced to take an OTA update to kitkat and I need root access).
Click to expand...
Click to collapse
So after going through a full factory reset (via ODIN), I can confirm that I'm not using Adapt Sound and have also ensured that I am not using any equalizers to enhance the sound in either application.
You cant compare PA or JA to the stock audio because those 2 apps using different drivers than a stock 1
rob.allen78 said:
I don't recall having Adapt Sound enabled (I did see it but don't remember having any checkboxes ticked....). I'll reply back once I downgrade my phone back to JB (I was forced to take an OTA update to kitkat and I need root access).
Click to expand...
Click to collapse
meawww said:
You cant compare PA or JA to the stock audio because those 2 apps using different drivers than a stock 1
Click to expand...
Click to collapse
Thanks for the info (The driver usage may be what the difference is respective to audio output.)
I wasn't really trying to compare the apps per se as more of a process of finding out if I have a unique hardware issue in which I would need to send my phone back to AT&T/Samsung for a warranty exchange.

ALSA from chroot -- Audio for the other side

First, a short story
After installing a chroot debian on my s2 I noticed that vlc player isn't working.
Sadly it took me several weeks to notice that sound in general wasn't working at all.
Problem: There was simply nowhere to output the sound.
So I tried to get alsa working from chroot to get some form of audio output.
and here it is.
ALSA ON CHROOT LINUX
The bumpy road to half broken (and therefore other half working) linux audio​
Once you have a working chroot (with correct mounts that is), download and install the following packages:
Code:
alsa-base alsa-oss alsa-utils
Now run
Code:
alsamixer
to open the alsa sound mixer.
There you should unmute
Code:
DL1 MM_EXT DL1 Mixer Multimedia DL1 PDM
Then set
Code:
HS Left
and
Code:
HS Right
to
Code:
HS DAC
This should enable headset output
ALso unmute
Code:
Earphone
to well....use the Earphone speaker.
To enable the Main speaker, unmute
Code:
DL2 Mixer Multimedia DL2 Mono
And set
Code:
HF Right
and
Code:
HF Left
to
Code:
HF DAC
For other devices, this section will be different. Just look through alsamixer and try to make sense of the countless options there.
Finished more or less.
Now you can play audio from chroot.:victory:
Notice: If you run any sound from android or plug the headset in/out, you need to reapply these settings.
To avoid that I run a script that continously re-enables the mentioned settings. (mainly the headset)
It looks something like this
Code:
#!/bin/bash
while true; do
[INDENT]
amixer -c 0 csent numid=74 1
amixer -c 0 csent numid=73 1
amixer -c 0 csent numid=35 1
amixer -c 0 csent numid=52 1
amixer -c 0 csent numid=33 1
sleep 0.5
[/INDENT]
done
This probably isn't the best way of doing it (it might actually be the worst), but it works.
It might put load on the cpu or it might not, but for me, running this decreases my SoD frequency. (idek why)
Also the best way to run the script is a few seconds after the system started using the "nohup" command. That way you can run it and close the terminal and it will still be active. To kill it, search its pid using
Code:
ps -x
and kill it with
Code:
kill (insert pid here)
If you want you can also run it as a start up script.
Though if you do that, you might see that it runs but doesn't do anything.
Don't panic. Or do if you want to.
But just restart the script anyways.
OPTIONAL: (because I force you to use the stuff above)
We can play no more than ONE audio source at a time
Soloution: PulseAudio
(I will fill this shortly....)
(there is also MPD which works...)
So for now we have
Solution 2: Dmixer
Dmixer is what it name sounds like. It downmixes multiple sources into a single audio stream.
And it works (sometimes).
So here is how to.
Simply copy the content of the file below into a new file called .asoundrc in /home/username
Code:
pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
}
bindings {
0 0
1 1
}
}
ctl.dmixer {
type hw
card 0
}
This one is mainly pulled directly from the alsa project site and should work most of the time.
hw:0,0 might need changing on different devices. Same with card 0.
run
Code:
aplay -l
and use that to find the correct card and device.
???
The standard: I am not responsible for anything that happens to you, your phone or anything else.
Also I didn't invent any of this stuff myself. All credit goes to the original developers.
I just wrote this guide (if you can call it that)
Oh...and if you can't understand my english, well.... I'm sorry but i can't do better.
ruleh said:
First, a short story
After installing a chroot debian on my s2 I noticed that vlc player isn't working.
Sadly it took me several weeks to notice that sound in general wasn't working at all.
Problem: There was simply nowhere to output the sound.
So I tried to get alsa working from chroot to get some form of audio output.
and here it is.
ALSA ON CHROOT LINUX
The bumpy road to half broken (and therefore other half working) linux audio​
Once you have a working chroot (with correct mounts that is), download and install the following packages:
Code:
alsa-base alsa-oss alsa-utils
Now run
Code:
alsamixer
to open the alsa sound mixer.
There you should unmute
Code:
DL1 MM_EXT DL1 Mixer Multimedia DL1 PDM
Then set
Code:
HS Left
and
Code:
HS Right
to
Code:
HS DAC
This should enable headset output
ALso unmute
Code:
Earphone
to well....use the Earphone speaker.
To enable the Main speaker, unmute
Code:
DL2 Mixer Multimedia DL2 Mono
And set
Code:
HF Right
and
Code:
HF Left
to
Code:
HF DAC
For other devices, this section will be different. Just look through alsamixer and try to make sense of the countless options there.
Finished more or less.
Now you can play audio from chroot.:victory:
Notice: If you run any sound from android or plug the headset in/out, you need to reapply these settings.
To avoid that I run a script that continously re-enables the mentioned settings. (mainly the headset)
It looks something like this
Code:
#!/bin/bash
while true; do
[INDENT]
amixer -c 0 csent numid=74 1
amixer -c 0 csent numid=73 1
amixer -c 0 csent numid=35 1
amixer -c 0 csent numid=52 1
amixer -c 0 csent numid=33 1
sleep 0.5
[/INDENT]
done
This probably isn't the best way of doing it (it might actually be the worst), but it works.
It might put load on the cpu or it might not, but for me, running this decreases my SoD frequency. (idek why)
Also the best way to run the script is a few seconds after the system started using the "nohup" command. That way you can run it and close the terminal and it will still be active. To kill it, search its pid using
Code:
ps -x
and kill it with
Code:
kill (insert pid here)
If you want you can also run it as a start up script.
Though if you do that, you might see that it runs but doesn't do anything.
Don't panic. Or do if you want to.
But just restart the script anyways.
OPTIONAL: (because I force you to use the stuff above)
We can play no more than ONE audio source at a time
Soloution: PulseAudio
Or so I thought... I can't seem to get it working. If someone can, please tell me how to.
So instead we have
Solution 2: Dmixer
Dmixer is what it name sounds like. It downmixes multiple sources into a single audio stream.
And it works (sometimes).
So here is how to.
Simply copy the content of the file below into a new file called .asoundrc in /home/username
Code:
pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
}
bindings {
0 0
1 1
}
}
ctl.dmixer {
type hw
card 0
}
This one is mainly pulled directly from the alsa project site and should work most of the time.
hw:0,0 might need changing on different devices. Same with card 0.
run
Code:
aplay -l
and use that to find the correct card and device.
???
The standard: I am not responsible for anything that happens to you, your phone or anything else.
Also I didn't invent any of this stuff myself. All credit goes to the original developers.
I just wrote this guide (if you can call it that)
Oh...and if you can't understand my english, well.... I'm sorry but i can't do better.
Click to expand...
Click to collapse
To use Pulseaudio, I found someone who used the Simple Protocol module to get sound and I'm now able to use MPD + MPDroid to play music from my Arch Linux chroot. Unfortunately, the playback get choppy when I open a on a single core phone with less that 1GB of RAM so if you have a better device, I'm sure the playback will be way better!
The phone I'm using is a Samsung Galaxy Ace II X (GT-S7560M) with LinuxDeploy (and CM11)
http://kaytat.com/blog/?page_id=301
TheST4RL said:
To use Pulseaudio, I found someone you used the Simple Protocol module to get sound and I'm now able to use MPD + MPDroid to play music from my Arch Linux chroot. Unfortunately, the playback get choppy when I open a on a single core phone with less that 1GB of RAM so if you have a better device, I'm sure the playback will be way better!
The phone I'm using is a Samsung Galaxy Ace II X (GT-S7560M) with LinuxDeploy (and CM11)
http://kaytat.com/blog/?page_id=301
Click to expand...
Click to collapse
I wish you would have told me this yesterday.
I spend all of yesterday doing the simple protocol player method. (It works on a quadcore 4gb phone.)
However I still prefer the alsa method on low performance phones because it has nearly no latency and is very smooth.
I will try the MPD method and see how it goes.
ruleh said:
I wish you would have told me this yesterday.
I spend all of yesterday doing the simple protocol player method. (It works on a quadcore 4gb phone.)
However I still prefer the alsa method on low performance phones because it has nearly no latency and is very smooth.
I will try the MPD method and see how it goes.
Click to expand...
Click to collapse
I tried ALSA today and it's working but the playback is super choppy and when I listen to music the audio is slower when compared to the real one. Pulseaudio may have some latency but if you're listening to music, it doesn't really matters.

[SOLVED] Volume control--USB Audio

SOLVED!!!! See post #25.
I am going to test this, for sure. If it indeed works, which I am very confident it will, you're going on the Important Links list.
Tested it, multiple times. Your steps did not work for me.
What does work, though, is this:
- Plug in OTG cable, set in Host mode.
- Plug in audio device.
- Open AudioCtl. Hit "Beep".
- Unplug audio device.
- Open ES Task Manager. Open Volume.
- Set "Media" meter to whatever you like.
- Plug audio device back in.
- Open AudioCtl. Hit "Beep".
Good to go.
Trying to track down volume adjustment
I've been thinking about the volume adjustment as described above and wondering if it could not be examined to reveal what is going on behind the scenes with a view to incorporating those changes into either Renate's AudioCTRL app or my one-touch USB Audio app--or both. My Android knowledge is, however, very basic.
I've attached a logcat session (including everything...) which begins with the usual sequence for enabling USB audio on a freshly booted NST. There's a lot to wade through, much of it irrelevant--even I can tell that. The beginning of the actual volume adjustment operation can be found by text searching for "Removed device", which is where the USB Audio gizmo is disconnected from the OTG cable while Task Manager is used to adjust the volume (as described in the post above). The logcat ends with the disconnection of the OTG cable and termination of USB host mode.
I've begun looking over this in hopes of seeing something that indicates what is different when AudioCTRL is invoked the second time to see if the volume is indeed no longer ear-splitting. Maybe there is something there, and maybe there is a better log to look at.
Any suggestions/help/joiners?
nmyshkin said:
I've been thinking about the volume adjustment as described above and wondering if it could not be examined to reveal what is going on behind the scenes with a view to incorporating those changes into either Renate's AudioCTRL app or my one-touch USB Audio app--or both. My Android knowledge is, however, very basic.
I've attached a logcat session (including everything...) which begins with the usual sequence for enabling USB audio on a freshly booted NST. There's a lot to wade through, much of it irrelevant--even I can tell that. The beginning of the actual volume adjustment operation can be found by text searching for "Removed device", which is where the USB Audio gizmo is disconnected from the OTG cable while Task Manager is used to adjust the volume (as described in the post above). The logcat ends with the disconnection of the OTG cable and termination of USB host mode.
I've begun looking over this in hopes of seeing something that indicates what is different when AudioCTRL is invoked the second time to see if the volume is indeed no longer ear-splitting. Maybe there is something there, and maybe there is a better log to look at.
Any suggestions/help/joiners?
Click to expand...
Click to collapse
Have you made any more progress on this volume adjustment problem?
The ES Task Manager's volume setting doesn't do anything more than what I can do with the hardware volume control on the USB Audio adapter.
My solution at the moment is to use some low-efficiency earbuds/headphones.
digixmax said:
Have you made any more progress on this volume adjustment problem?
The ES Task Manager's volume setting doesn't do anything more than what I can do with the hardware volume control on the USB Audio adapter.
My solution at the moment is to use some low-efficiency earbuds/headphones.
Click to expand...
Click to collapse
Unfortunately it seems beyond my skill and no one else seemed interested in tackling it. This leads me to believe that either not many people use the audio capability (maybe for this reason?!) or they just found other methods that "worked" for them. In searching for something--anything--that would make the volume other than full on I thought I had the solution several times and that suggests to me--along with your experience with ESTM--that the behavior is almost device idiosyncratic. That's a scary thought.
That said, I hope you'll give the ESTM another try. It works wonderfully well for me and provides full range volume control from a whisper to blasting using the native android controls as well as external buttons. I have two USB audio devices, one with volume buttons and one without. Both work equally well with this method, but you do have to follow the procedure exactly:
1. Set up your USB audio device in the usual way, using Renate's two apps (you can also use my one-touch app--must be version 3--to set the volume this way).
2. Remove the USB audio device from the cable (do not detach the OTG cable from the NST)
3. Open ESTM and access only the quick menu (three bars at the top left)
4. Select volume adjust.
5. Adjust only the media volume to something on the order of 60%--don't diddle with this. One adjustment. If you do too much you can cause a reboot.
6. Close ESTM
7. Reattach the USB audio device.
You should be good to go at that point until your next cold or warm boot and unless you're working on your system, that can be a very long time with the Nook ST! It doesn't matter that you get in and out of USB mode. Something in that hoo-doo process sets a flag or pushes an unruly gaggle of electrons around in the system so that the volume control works as it should. I only wish I knew what it was!
Just in case, the version of ESTM I am using is 1.4.2 (attached below).
nmyshkin said:
...
but you do have to follow the procedure exactly ...
...
Click to expand...
Click to collapse
That did the trick!!!
I think I had previously skipped the step of removing the US Audio adapter ...
Can you post the link to your one-touch app?
Tx.
digixmax said:
That did the trick!!!
I think I had previously skipped the step of removing the US Audio adapter ...
Can you post the link to your one-touch app?
Tx.
Click to expand...
Click to collapse
Good! I hate kludges, but this one does actually work
Here's the one-touch app.
nmyshkin said:
Good! I hate kludges, but this one does actually work
Here's the one-touch app.
Click to expand...
Click to collapse
Thanks.
Now, if your one-touch app can finagle the volume control I'd be in heaven and go stocking up a few more NSTs
digixmax said:
Thanks.
Now, if your one-touch app can finagle the volume control I'd be in heaven and go stocking up a few more NSTs
Click to expand...
Click to collapse
Amen to that, brother--from your fingertips to the terminal screens of those who can do it. It's the last piece of the audio puzzle and it would be a shame not to complete the work.
digixmax said:
Thanks.
Now, if your one-touch app can finagle the volume control I'd be in heaven and go stocking up a few more NSTs
Click to expand...
Click to collapse
Oh....I'm so close!!!!! I can write a little volume setting app to use after the USB Audio toggle (or the standard method). Like the kludge above the adjustment is persistent until a reboot but you don't need ES Task Manager.
What I can't do (yet) is combine the volume adjustment with the USB Audio toggle
I need to consult the Tasker experts for a workaround. In the meantime I'll get the app posted later today after a little more testing.
Edit: Ugh. Or maybe not. The app causes a reboot.... Still working on the problem.
nmyshkin said:
Oh....I'm so close!!!!! I can write a little volume setting app to use after the USB Audio toggle (or the standard method). Like the kludge above the adjustment is persistent until a reboot but you don't need ES Task Manager.
...
Click to expand...
Click to collapse
Not having to navigate through ES Task Manager to get to its Volume tab is a significant improvement.
Does your app still entail the ritual of disconnecting/reconnecting the audio adapter?
digixmax said:
Does your app still entail the ritual of disconnecting/reconnecting the audio adapter?
Click to expand...
Click to collapse
I'm afraid so but that is rather moot since I've run into the reboot problem. I'm not giving up, though :fingers-crossed:
tiny "progress"
Oy. This really needs someone who can understand all the stuff thrown out in the logcat.
But...I have made one discovery that tames (not controls) the ALSA volume. In the master ALSA configuration file at /system/etc/asound.conf there are three instances of Speaker Volume of one kind or another. All three are set to the maximum (150 for each channel). Although the minimum is supposed to be 0, anything lower than 4 effectively mutes the sound card. Reducing the setting to 4 may make some headphones usable without the kludge described earlier. You can do this with a simple text editor, either on the device, or pull the file to your computer, edit and put it back. A reboot is needed for this to take effect even though ALSA documentation says this file is always read anew when a device is detected.
If you want to see whether this is even worth the trouble and you have adb access, you can fire up the USB Audio (without the kludge) and send the following shell command:
Code:
adb shell alsa_amixer -c 1 set Speaker 4
The volume change will be instantaneous but not permanent. For that you need to make the change in the asound.conf file.
The real issue, of course, is that without the mysterious beneficial effect of the kludge, the native android volume control has no effect on either actual media volume OR the ALSA volume. When the kludge is used there is still (I believe) no effect on the ALSA volume but the native volume control is able to take the static value of the ALSA volume and decrease it, thus giving the effect of a volume control.
I think this is correct because when the asound.conf file is edited as described above, the maximum android volume is less than the earsplitting level when the ALSA controls were set to their maximum (150).
In any case if you query the ALSA volume post-kludge it's clear that the android media volume setting is having no effect on the ALSA value which remains whatever is specified in asound.conf
Therefore part of the problem is that rather than controlling the ALSA volume, the native android volume control overlays the constant ALSA value.
OK, I admit I wrote most of that to clarify the issues in my own mind. Maybe someone will get another idea. I've Googled every search string I can think of and have only learned to tinker a little with ALSA commands. But the real mystery is in the android system and what the logcat shows.
nmyshkin said:
...
OK, I admit I wrote most of that to clarify the issues in my own mind. Maybe someone will get another idea. I've Googled every search string I can think of and have only learned to tinker a little with ALSA commands. But the real mystery is in the android system and what the logcat shows.
Click to expand...
Click to collapse
@nmyshkin:
You solved the mystery!!!
Following the lead in your PM, I re-enabled Phone.apk (which many of us had disabled to conserve battery) and now volume-control using my USB Audio adapter's volume-button works like a charm.
digixmax said:
@nmyshkin:
You solved the mystery!!!
Following the lead in your PM, I re-enabled Phone.apk (which many of us had disabled to conserve battery) and now volume-control using my USB Audio adapter's volume-button works like a charm.
Click to expand...
Click to collapse
LOL--I hope you are correct, but there seems to be a devil in my details. I now cannot get it to work using my one-touch toggle app, but it does seem to work with the standard 2-app setup. What seems to fail using my app is that mediaserver is not killed (maybe it's just wounded....). So I'd be curious to know if this continues to work for you, even after a reboot. I thought I had it all sewed up until a reboot showed me otherwise.
When I found the PID for mediaserver as @Renate NST instructed in order to replicate the function of her AudioCtl app, I may have oversimplified things too much. Not knowing much, I just assumed the PID was constant. So I wrote the value I found (19409) into my app. But now that I am having trouble, I find that this:
Code:
adb shell ps
which lists the PID values for apps and processes gives something quite different for /system/bin/mediaserver (1818 right now).
So.....Renate's app continues to work and I'm guessing that's because it queries the PID value before killing mediaserver. I can't say that enabling the Phone.apk has changed the PID value for mediaserver, but there are a whole lot of processes listed now that it's back compared to when I checked PIDs before.
So as a "proof of concept" I just edited the Tasker task from which my one-touch app was produced, changing the PID value to 1818. That worked like a charm.
Next I ran the one-touch app again andthis time it worked. I guess I'm showing my ignorance (yet again) but that does not make sense. I'm betting that if I reboot something different will happen.
........
OK, so on a reboot I get a PID of 978 for /system/bin/mediaserver and (not surprisingly) my one-touch app does not work. And now Renate's 2-step method hangs up on the AudioCtl app. Another check of the PID via adb shows it has changed to 2263.
I'd be very curious to know how your device behaves after a reboot. Mine's a mess (as far as this audio stuff goes---everything else is fine).
This morning it occurred to me that my one-touch toggle app might just be corrupted. I've really put my poor NST through the wringer the past few weeks working on this problem
So I uninstalled it and put on a fresh copy. It worked on the first try
I'm hoping your experience is the same. If so I'll monitor the power issue for a week and then write a summary post and call this "solved".
Edit: Or not. After a reboot the one-touch toggle app again failed to work. What does seem to work consistently is using Renate's two apps for the first time after a reboot. Thereafter, for some reason known only to Heisenberg (and maybe Renate), the one-touch toggle app successfully sets up the USB Audio with proper volume control. Until another reboot. I need to contact Renate.
nmyshkin said:
LOL--I hope you are correct, but there seems to be a devil in my details. I now cannot get it to work using my one-touch toggle app, but it does seem to work with the standard 2-app setup. What seems to fail using my app is that mediaserver is not killed (maybe it's just wounded....). So I'd be curious to know if this continues to work for you, even after a reboot. I thought I had it all sewed up until a reboot showed me otherwise.
Click to expand...
Click to collapse
Sorry I should have been clearer: I have not gotten around to try your one-step app yet, as I want to make sure I don't introduce more variables into my mysterious "loss of sound" problem (as I described in my PM). So what work for me so far (fingers crossed as I am starting to lose faith in Bacon's principles ) is Renate's two step-process.
When I found the PID for mediaserver as @Renate NST instructed in order to replicate the function of her AudioCtl app, I may have oversimplified things too much. Not knowing much, I just assumed the PID was constant. So I wrote the value I found (19409) into my app. But now that I am having trouble, I find that this:
Code:
adb shell ps
which lists the PID values for apps and processes gives something quite different for /system/bin/mediaserver (1818 right now).
Click to expand...
Click to collapse
Yes the PID for a Linux-type OS process is not deterministic (except for the one and only "init" process which has PID of 1). You can find the PID of a currently running process with the command pipe "ps ax | grep <process-name>" (but I have no idea if/how you can make use of this from inside your app).
So.....Renate's app continues to work and I'm guessing that's because it queries the PID value before killing mediaserver. I can't say that enabling the Phone.apk has changed the PID value for mediaserver, but there are a whole lot of processes listed now that it's back compared to when I checked PIDs before.
Click to expand...
Click to collapse
Yes, I now see the old familiar "Cell Idle" process topping the battery-usage list .
digixmax said:
Sorry I should have been clearer: I have not gotten around to try your one-step app yet, as I want to make sure I don't introduce more variables into my mysterious "loss of sound" problem (as I described in my PM). So what work for me so far (fingers crossed as I am starting to lose faith in Bacon's principles ) is Renate's two step-process.
Yes the PID for a Linux-type OS process is not deterministic (except for the one and only "init" process which has PID of 1). You can find the PID of a currently running process with the command pipe "ps ax | grep <process-name>" (but I have no idea if/how you can make use of this from inside your app).
Yes, I now see the old familiar "Cell Idle" process topping the battery-usage list .
Click to expand...
Click to collapse
Thank you for that helpful info about the PID. I'll see what I can do with it. It does not explain how the one-touch app worked before the phone.apk was awakened nor how it works after the 2 step method has been used once. But it's a start.
I installed a battery app today to keep an eye on things but it's showing me the "dialer" as consuming only 0.8% of the battery usage. I may not have access to what I need to know with this particular app.
digixmax said:
...
You can find the PID of a currently running process with the command pipe "ps ax | grep "...
Click to expand...
Click to collapse
Apparently the ps command in Android behaves a bit differently than its Linux counterpart, there is no need for the "ax" option stuff.
Instead, this command pipe
Code:
ps | grep phone | tr -s ' ' | cut -d ' ' -f 2
(note the single blank between the two single quotes as value for the -s and -d options) will yield the PID for the phone process.

[Request] Speaker balance mod

There are a lot of users with uneven speakers, some have even exchanged their phones and still had the same problem with their second device. So I don't see the point in exchanging mine atm.
Using power amp I fixed my issue by panning my sound a little more to my bottom speaker, however this only works when listening to music.
Since the fix for music was so simple, is there anyone that can make a mod to change the phones speaker balance for the whole system?
I tried viper4android which has channel pan, but that setting is not available for phone speakers. Is there any other solution?
jamespat93 said:
There are a lot of users with uneven speakers, some have even exchanged their phones and still had the same problem with their second device. So I don't see the point in exchanging mine atm.
Using power amp I fixed my issue by panning my sound a little more to my bottom speaker, however this only works when listening to music.
Since the fix for music was so simple, is there anyone that can make a mod to change the phones speaker balance for the whole system?
I tried viper4android which has channel pan, but that setting is not available for phone speakers. Is there any other solution?
Click to expand...
Click to collapse
I do not have a 6P, but I still follow especially audio-related posts with interest.
One solution (root required!) would be to first play around with the audio mixer while playing music (or other audio material). First, go here and download the tinymix_lollipop.tar.gz file from the second post. This is the user-space mixer interface that at least on my Nexus 5 also works on Marshmallow. Copy the binary (tinymix) from that archive to, for instance, /system/bin and make executable (permission 755). Once installed, go to a root shell on your phone and execute
Code:
tinymix "Left Speaker Gain" X
and/or
Code:
tinymix "Right Speaker Gain" Y
where X and Y seem to be 20 by default. Carefully (!) change X and Y independently of each other until you find a satisfactory balance. I'd suggest you go one "tick" at a time and initially lower the gain instead of increasing it. Without having looked at the device-specific kernel, I don't know what the range of this mixer control is, but you can find out by issuing
Code:
tinymix "Left Speaker Gain"
Note X and Y that sound good to you and hard-code them, I believe, in the "speaker-gain-default" section of your /system/etc/mixer_paths.xml file and reboot.
chdloc said:
I do not have a 6P, but I still follow especially audio-related posts with interest.
One solution (root required!) would be to first play around with the audio mixer while playing music (or other audio material). First, go here and download the tinymix_lollipop.tar.gz file from the second post. This is the user-space mixer interface that at least on my Nexus 5 also works on Marshmallow. Copy the binary (tinymix) from that archive to, for instance, /system/bin and make executable (permission 755). Once installed, go to a root shell on your phone and execute
Code:
tinymix "Left Speaker Gain" X
and/or
Code:
tinymix "Right Speaker Gain" Y
where X and Y seem to be 20 by default. Carefully (!) change X and Y independently of each other until you find a satisfactory balance. I'd suggest you go one "tick" at a time and initially lower the gain instead of increasing it. Without having looked at the device-specific kernel, I don't know what the range of this mixer control is, but you can find out by issuing
Code:
tinymix "Left Speaker Gain"
Note X and Y that sound good to you and hard-code them, I believe, in the "speaker-gain-default" section of your /system/etc/mixer_paths.xml file and reboot.
Click to expand...
Click to collapse
Thank you so much! this is extremely helpful and seems like it will be a great solution. I'm trying to go through the steps now but just need a little help.
I download tinymix_lollipop.tar.gz, extracted the tinymix file and copied it to system/bin. Then I changed its permissions to 755 to make it executable like you said. Next I tried to use terminal emulator and typed 'tinymix "Left Speaker Gain" 1' just to test it. However it just gives me the error message 'failed to open mixer'. I'm rooted and made the file executable so I'm not sure why it didn't work?
jamespat93 said:
Thank you so much! this is extremely helpful and seems like it will be a great solution. I'm trying to go through the steps now but just need a little help.
I download tinymix_lollipop.tar.gz, extracted the tinymix file and copied it to system/bin. Then I changed its permissions to 755 to make it executable like you said. Next I tried to use terminal emulator and typed 'tinymix "Left Speaker Gain" 1' just to test it. However it just gives me the error message 'failed to open mixer'. I'm rooted and made the file executable so I'm not sure why it didn't work?
Click to expand...
Click to collapse
Before executing tinymix you need to make sure that this particular shell session has been granted root privileges. You need to type
Code:
su
in your terminal emulator to accomplish that. The prompt should switch to #
chdloc said:
Before executing tinymix you need to make sure that this particular shell session has been granted root privileges. You need to type
Code:
su
in your terminal emulator to accomplish that. The prompt should switch to #
Click to expand...
Click to collapse
Yeah its working perfectly now thanks! Just going to play with it a bit till I find settings I'm happy with but this is exactly what I was looking for!
The range is 0-31 so does that mean its safe to put the gain anywhere between those numbers?
jamespat93 said:
The range is 0-31 so does that mean its safe to put the gain anywhere between those numbers?
Click to expand...
Click to collapse
Who knows? I'm guessing things will start to audibly distort at gains higher than 20, maybe even to the point of physical damage at the top end.
Wow guess I'll be leaving it below 20 then, but seriously thanks again!
jamespat93 said:
Yeah its working perfectly now thanks! Just going to play with it a bit till I find settings I'm happy with but this is exactly what I was looking for!
The range is 0-31 so does that mean its safe to put the gain anywhere between those numbers?
Click to expand...
Click to collapse
What values did you end up using? And just to confirm....the top speaker is left?? because my top speaker is way louder than my bottom...so should I increase the bottom "1" or decrease the top speaker "-1". Also I'm assuming you can do a negative gain right?
bsg411 said:
What values did you end up using? And just to confirm....the top speaker is left?? because my top speaker is way louder than my bottom...so should I increase the bottom "1" or decrease the top speaker "-1". Also I'm assuming you can do a negative gain right?
Click to expand...
Click to collapse
Yeah top speaker gain is for the left speaker. The gain is '20' at default and it changes to whatever number you change it to. So to reduce it just change it to any number below 20. I changed my left speaker gain to 16.
Also elemental kernel now has left and right speaker gain controls too.
jamespat93 said:
There are a lot of users with uneven speakers, some have even exchanged their phones and still had the same problem with their second device. So I don't see the point in exchanging mine atm.
Using power amp I fixed my issue by panning my sound a little more to my bottom speaker, however this only works when listening to music.
Since the fix for music was so simple, is there anyone that can make a mod to change the phones speaker balance for the whole system?
I tried viper4android which has channel pan, but that setting is not available for phone speakers. Is there any other solution?
Click to expand...
Click to collapse
How did you install Viper4android and get channel pan? I installed using this http://forum.xda-developers.com/nex...er4android-t3250579/post65464645#post65464645
and the setting seems to be missing!

Categories

Resources