Dev Anecdotes #3 - Development of Quasar AtmoX™ Ultimate Sound Mod for Android Devices

Quasar-AtmoX-Banner.png

I am an audiophile and love experimenting with my sound system and android devices to get the best audio experience. As my cheap android device was not so good (unlike Xperia devices) in audio quality. I tried to search for a good Sound Mod which can provide best music experience according to my ever changing musical mood. :p

[For your information, a sound mod is a set of software and codes which can enhance audio experience in an android device by improving audio decoding quality and thus the sound output.]

After working for a few years in Android ROM development and porting, I decided to make a Sound Mod myself according to my requirement and of course of my ROM users. The time had come to implement what I had learnt through ROM development in something different. So I started working on the project with full dedication.

Thus, I successfully developed the sound mod called Quasar AtmoX™ Ultimate. Why “Ultimate”? “Ultimate”, because it included best in class sound enhancement technologies ported from various popular devices like Xperia, HTC, Lenovo etc. : Dolby Atmos®, Viper’s Audio, Xperia™ Audio Enhancement, HTC Beats™, MaxxAudio etc. Actually, all this was possible only because of the users and devs of these devices shared the required file. I am very thankful to them.

This sound mod comes with many awesome features but the most awesome thing that I have implemented is that it is inter-compatible other AudioFX that come preinstalled in different ROMs (like CM AudioFX, MaxxAudio etc.). So no need to disable your default equalizer while using this mod.

Now let’s discuss what this sound mod actually offers.

Features of Quasar AtmoX™ Ultimate


Xperia Music + Sony Audio Enhancement

sony.jpg

Technologies Included:

  • Xperia™ Equalizer
  • ClearAudio+
  • xLOUD™
  • Dynamic normalizer
  • Surround Sound (VPT) [Studio | Club | Concert Hall]
  • Clear Stereo
  • Clear Phase™
  • S-Force Front Surround
    MUsic.jpg

Dolby Atmos®

dolby-logo.jpg

FEEL EVERY DIMENSION™

“Dolby Atmos transports you into the story with moving audio that flows all around you with breathtaking realism.”

ViPER’s Audio

Viper2.jpg

Viper’s Audio (also known as Viper4Android) is the ultimate sound control system for android devices. Quasar Atmox™ includes the best and latest ViPER4Android FX v2.5.0.5. It comes with thorough audio customizations and provides expert level audio setup.

Quasar Additions

beats-audio.jpg

After incorporating these cool audio enhancement technologies if anything left, is completed by Quasar™ Additions which include:

  • Beats Audio™
  • Dirac HD (Ported from MIUI)
  • Extra Bass + Optimized Audio
  • Inter-compatibility with other AudioFX like CM AudioFX, MAXXAudio etc.

Extra Features

MaxxAudio: Latest version of MaxxAudio® is available as addon for Quasar AtmoX. It is ported from Alcatel Onetouch Idol 4S device.

waves_maxxaudio-mm.jpg

Quasar AtmoX™ Uninstaller: Another unique feature of Quasar AtmoX is that is comes with an uninstaller. That means it is totally safe to flash this mod. If something goes wrong, then you can easily revert back. But, how does it work? Don’t worry I’ll describe that as well.

Before discussing how this mod works and how did I develop it, let’s take a look at how audio output works in android.

Audio System in Android


android-audio-system.jpg
Android Audio System | Slideshare


In simple words, in an Android System audio output is basically a collective effort of software and hardware. When you play a music in an android app it basically goes through a bunch of java codes which control and decide the type of audio output to be sent to the hardware. Here this is done by Audio Policy and Audio Flinger. Then the audio data is transferred to Audio HAL (Hardware Abstraction Layer) which includes the audio drivers and controls the volume of output etc. Then the data is finally converted into sound by the speakers.

Making of Quasar AtmoX™ Ultimate Sound Mod


quasar-Atmox-xperia.jpg

As Quasar AtmoX includes different equalizer apps like Dolby Atmos, MaxxAudio, Viper4Android and Sony Audio Enhancement, they are required to be ported and modified to work on any android device.

Like, the Dolby Atmos app (Ds.apk and DsUI.apk) has been modified by reverse engineering the app (through apktool) and finding out the required libraries for it to function. Also we can get some idea about the additional files required for its functioning. Also the original Dolby Atmos app was large in size as it included useless demo video inside it and it was removed after decompiling the app to decrease its size to just 2.5 MB. Also the app was renamed to As.apk and AsUI.apk by modifying the AndroidManifest.xml file and signing the apk. Again all the remaining required files are detected through the logcat of the crashing Dolby Atmos app. Logcat is an incredible tool for porting apps and ROMs.

Similar was the process for MaxxAudio and Sony Audio Enhancement. But for Viper4Android it was not required as it is itself a full-fledged audio mod made for all devices. So, what is done for the Viper? Well, Viper4Android app installs some driver files after we launch the application which requires root access, busybox and selinux to be permissive. So in many of the cases it creates complications and fails most of times. So to bypass this troublesome driver installation what I did was that, I figured out what system files are being modified and what files are being added. Then I made a script which will do the same modifications and additions while flashing the Quasar AtmoX mod. So, there will be no need for driver installation afterwards. Thus people can easily run Viper4Android even if their device is not rooted.

In addition to that for better audio resampling and output and some audio enhancements like Dirac and Beats, no special app is given. It works on some modifications in the Audio HAL output and also some additional audio effect libraries (libs) and modification in audio_effects.conf and build.prop files. Some binaries are also added for doing some specific function in the audio enhancement process.

What does this Mod basically do?

Quasar AtmoX Ultimate is a recovery flashable (custom recoveries like TWRP) mod. When someone flashes this mod in his device, it extracts all the files required for Dolby Atmos, Sony Audio, Viper etc. and the extra audio enhancements to the /system and thus replacing/modifying older files, adding new files and symlinking them as per requirement.

It also runs a shell script (runme.sh) which carries out the required modification in the audio effects.conf and build.prop.

Here are some parts of codes used to modify the build.prop file:

echo " " >> /system/build.prop
echo "## Quasar AtmoX™ Details ##" >> /system/build.prop
echo "ro.quasar_atmox.version=3.0" >> /system/build.prop
echo "ro.quasar_atmox.developer=nitesh9" >> /system/build.prop
echo " " >> /system/build.prop
echo "## ViPER|Audio™ ##" >> /system/build.prop
echo " " >> /system/build.prop
echo "audio.deep_buffer.media=false" >> /system/build.prop
echo "lpa.decode=false" >> /system/build.prop
echo "tunnel.decode=false" >> /system/build.prop
echo "tunnel.audiovideo.decode=false" >> /system/build.prop
echo "lpa.releaselock=false" >> /system/build.prop
echo "lpa.use-stagefright=false" >> /system/build.prop
echo "af.resampler.quality=255" >> /system/build.prop
echo "persist.af.resampler.quality=255" >> /system/build.prop
echo "af.resample=52000" >> /system/build.prop
echo "persist.af.resample=52000" >> /system/build.prop
echo "ro.audio.samplerate=6144000" >> /system/build.prop
echo "persist.dev.pm.dyn_samplingrate=1" >> /system/build.prop
echo "ro.audio.pcm.samplerate=6144000" >> /system/build.prop
echo "ro.sound.driver=alsa" >> /system/build.prop
. . .

As you can understand simply from the code, echo command is used to write a “string” in the build.prop file. These codes contain information for the OS telling it how to decode the audio and the drivers to use.

Again we add new sound effects to the OS through adding some lines containing information about new libraries and their audio effect signature to the audio_effects.conf file. Here’s how the code looks like:

# Normal/vendor config locations
CONFIG_FILE=/system/etc/audio_effects.conf
VENDOR_CONFIG=/system/vendor/etc/audio_effects.conf
# Add Dirac Sound Effect
#
# Add libary
sed -i 's/^libraries {/libraries {\n  dirac {\n    path \/system\/lib\/soundfx\/libdirac.so\n  }/g' $CONFIG_FILE
#
# Add effect
sed -i 's/^effects {/effects {\n  dirac {\n    library dirac\n    uuid e069d9e0-8329-11df-9168-0002a5d5c51b\n  }/g' $CONFIG_FILE
#
# Add libary
sed -i 's/^libraries {/libraries {\n  dirac {\n    path \/system\/lib\/soundfx\/libdirac.so\n  }/g' $VENDOR_CONFIG
#
# Add effect
sed -i 's/^effects {/effects {\n  dirac {\n    library dirac\n    uuid e069d9e0-8329-11df-9168-0002a5d5c51b\n  }/g' $VENDOR_CONFIG

How does the Uninstaller Work?

When you flash Quasar AtmoX Ultimate Mod, it also runs another shell script called backup.sh. This script creates a backup directory in the /data partition of the device and copies all the files form /system which are going to be either replaced or modified. Here are the bunch of codes which are going to create the backup directories and copy the files to it:

# Create separate directories in /data
mkdir -p "/data/quasar-atmox"
chmod 755 "/data/quasar-atmox"
mkdir -p "/data/quasar-atmox/backup"
chmod 755 "/data/quasar-atmox/backup"
mkdir -p "/data/quasar-atmox/backup/app"
chmod 755 "/data/quasar-atmox/backup/app"
mkdir -p "/data/quasar-atmox/backup/bin"
chmod 755 "/data/quasar-atmox/backup/bin"
. . .
# From system/app folder
cp -rf "/system/app/GoogleLyricsPlugin" "/data/quasar-atmox/backup/app/GoogleLyricsPlugin"
cp -rf "/system/app/HeadphoneSelection" "/data/quasar-atmox/backup/app/HeadphoneSelection"
cp -rf "/system/app/SemcMetadataCleanup" "/data/quasar-atmox/backup/app/SemcMetadataCleanup"
cp -rf "/system/app/WikipediaPlugin" "/data/quasar-atmox/backup/app/WikipediaPlugin"
cp -rf "/system/app/YouTubeKaraokePlugin" "/data/quasar-atmox/backup/app/YouTubeKaraokePlugin"
cp -rf "/system/app/YouTubePlugin" "/data/quasar-atmox/backup/app/YouTubePlugin"
#
# From system/bin folder
cp -f "/system/bin/alsa_amixer" "/data/quasar-atmox/backup/bin/"
cp -f "/system/bin/alsa_aplay" "/data/quasar-atmox/backup/bin/"
cp -f "/system/bin/alsa_ctl" "/data/quasar-atmox/backup/bin/"
cp -f "/system/bin/aplay" "/data/quasar-atmox/backup/bin/"
cp -f "/system/bin/asound" "/data/quasar-atmox/backup/bin/"
. . .

Quasar Atmox Unistaller is also a simple recovery flashable zip which runs a shell script called uninstall.sh. Before starting the uninstaller (uninstall.sh), it first checks whether Quasar AtmoX Ultimate is installed or not. It does this by checking the build.prop for some special lines which are being added when the sound mod is installed. This is done by the updater-script itself by the “file_getprop()” command. Here is the code for the same:

file_getprop("/system/build.prop", "ro.quasar_atmox.developer") == "nitesh9" || abort("Quasar AtmoX not detected. Aborting uninstallation...!");

After that uninstall.sh file is initiated if an installation is found. It removes all the new and modified files added by the sound mod. And then it copies all the original files from the backup directories from /data to /system. Thus, it restores the ROM to its initial condition. Here is a sample code for the same:

# Deleting installation from system partition
# From system
rm -f "/system/build.prop"
#
# From system/app folder
rm -rf "/system/app/GoogleLyricsPlugin"
rm -rf "/system/app/HeadphoneSelection"
rm -rf "/system/app/MaxxAudio"
rm -rf "/system/app/MaxxService"
rm -rf "/system/app/SemcMetadataCleanup"
rm -rf "/system/app/WikipediaPlugin"
rm -rf "/system/app/YouTubeKaraokePlugin"
rm -rf "/system/app/YouTubePlugin"
#
# From system/bin folder
rm -f "/system/bin/alsa_amixer"
rm -f "/system/bin/alsa_aplay"
rm -f "/system/bin/alsa_ctl"
rm -f "/system/bin/aplay"
rm -f "/system/bin/asound"
. . .
# Restoring backup files
# In system
cp -f "/data/quasar-atmox/backup/build.prop" "/system/"
#
# In system/app folder
cp -rf "/data/quasar-atmox/backup/app/GoogleLyricsPlugin" "/system/app/GoogleLyricsPlugin"
cp -rf "/data/quasar-atmox/backup/app/HeadphoneSelection" "/system/app/HeadphoneSelection"
cp -rf "/data/quasar-atmox/backup/app/SemcMetadataCleanup" "/system/app/SemcMetadataCleanup"
cp -rf "/data/quasar-atmox/backup/app/WikipediaPlugin" "/system/app/WikipediaPlugin"
cp -rf "/data/quasar-atmox/backup/app/YouTubeKaraokePlugin" "/system/app/YouTubeKaraokePlugin"
cp -rf "/data/quasar-atmox/backup/app/YouTubePlugin" "/system/app/YouTubePlugin"
#
# In system/bin folder
cp -f "/data/quasar-atmox/backup/bin/alsa_amixer" "/system/bin/"
cp -f "/data/quasar-atmox/backup/bin/alsa_aplay" "/system/bin/"
cp -f "/data/quasar-atmox/backup/bin/alsa_ctl" "/system/bin/"
cp -f "/data/quasar-atmox/backup/bin/aplay" "/system/bin/"
cp -f "/data/quasar-atmox/backup/bin/asound" "/system/bin/"
. . .

This is the whole process of how QuasarAtmoX Ultimate works and how I developed it. Hope it gave you inspiration and knowledge about development of audio mods.

Important Information about Quasar Atmox Ultimate Sound Mod


GitHub for Quasar AtmoX™ Ultimate Sound Mod : https://github.com/Quasar-AtmoX/Quasar-AtmoX-SoundMod
GitHub for Quasar AtmoX™ Uninstaller : https://github.com/Quasar-AtmoX/Quasar-Atmox-Uninstaller
GitHub for MaxxAudio add-on : https://github.com/Quasar-AtmoX/MaxxAudio-addon

Here is the XDA Developers link for the thread of Quasar AtmoX Ultimate Sound Mod:
https://forum.xda-developers.com/android/software/mod-quasaratmox-ultimate-sound-mod-t3479705

Want to learn more about the mod, just search “Quasar Atmox” on Google or Youtube. :D

Proof of Work


Github-nitesh-prasad.png

My Commits:
https://github.com/Quasar-AtmoX/Quasar-AtmoX-SoundMod/commits/master
https://github.com/Quasar-AtmoX/Quasar-Atmox-Uninstaller/commits/master


Hope this post helps a lot of aspiring android developers out there. Happy developing.

Thanks. :)



Posted on Utopian.io - Rewarding Open Source Contributors

H2
H3
H4
3 columns
2 columns
1 column
8 Comments