[APP][4.1+] Spirit2: Real FM Radio for AOSP & root

What name would you prefer for this new FM app ?

  • Spirit2

    Votes: 441 81.4%
  • a2d.fm

    Votes: 23 4.2%
  • a2d

    Votes: 1 0.2%
  • A2D FM

    Votes: 51 9.4%
  • A2D

    Votes: 8 1.5%
  • Other: Please post

    Votes: 29 5.4%

  • Total voters
    542
Status
Not open for further replies.
Search This thread

mikereidis

Inactive Recognized Developer
Jan 28, 2011
7,823
4,146
Ottawa/Gatineau, Canada
The Moto G is now for sale here in Canada. I think it's the first Google-era-Motorola phone with official (or unofficial even) FM and is the closest thing to a Google phone with FM.

It's a $200 phone, so I'm hesitant to support it, but it has the potential to sell large quantities.

It appears the bootloader is easy to unlock and may not even void warranty.

I've looked at the FM app and system dump. It uses Qualcomm FM and I'd guess Qualcomm audio, so the OneXL/Qualcomm support in Spirit1 and Spirit2 should work or be close to working.

I think I'll get one and try it out...
 

LenAsh

Retired Forum Moderator
Mar 20, 2011
4,736
4,708
Midlands, UK
The 16GB Moto G is Amazon UK's #1 seller in Mobile phones... quite a potential market for you if extrapolated. And being QCom FM rather than BCom means the potential for excellent quality...
 

k-semler

Senior Member
Jan 6, 2009
757
284
40
Pullman WA
I recently purchased Spirit FM Unlocked. If I install this package, will it automatically recognize the lisence when I install a2d.fm? Or do I need to send you my order number?
 

mikereidis

Inactive Recognized Developer
Jan 28, 2011
7,823
4,146
Ottawa/Gatineau, Canada
I recently purchased Spirit FM Unlocked. If I install this package, will it automatically recognize the lisence when I install a2d.fm? Or do I need to send you my order number?

Not really, there is no cross recognition of licenses.

Just download and run Spirit2. At this time, the only difference if you buy it is you can turn statistics reporting off 3 days after purchase. Maybe I'll add a hidden code for that too.

I've promised that anyone who has Spirit Unlocked can upgrade to Spirit2 at no cost. The way I do that is cancel the original Unlocked order and Spirit2 can be bought when the price is lower/about the same as Unlocked. I expect to match prices around December 2-3.

The main conflicts here are that Spirit2 isn't "ready for prime time" yet, and Spirit Unlocked supports many more phones that Spirit2 does. So if you have 1 or more phones for which you need Unlocked as well as 1 or more for which you want to run Spirit2, that's a small bit of a problem. But not too big, because Unlocked doesn't have any license protection and I don't expect to update it much, if at all, anymore.
 

mikereidis

Inactive Recognized Developer
Jan 28, 2011
7,823
4,146
Ottawa/Gatineau, Canada
Here's the new Nov 24 release I've also updated on Play: http://d-h.st/J8p

- Some minor/cosmetic fixes & changes.

- Fixed support for 3rd party apps*.


This is my first release of an App Inventor 2 sample app: http://d-h.st/D8D

Go here for App Inventor 2: http://newblocks.appinventor.mit.edu


MIT App Inventor (AI) is a simple(-ish) non-programmer type APP development system, by which apps are built by graphically connecting blocks. I created the first Spirit1 prototypes with it in early 2011, and it was a great way to introduce myself to the basics of Android development.

It's still very difficult to almost impossible to produce "production quality" apps with AI, but it's cool for some basic prototyping, or messing around on a Sunday.

It can still be a bit of work to get started with AI. For AI2 there's a hassle with the MIT AI companion app. The a3a.aia file linked above needs to be imported into a new project to start.


By looking at the code/blocks, you can get a general idea of the API I'm providing for 3rd party Android Java apps. I did a special API for AI because AI can only do startActivity() and not startService(). The API is Android Intent based and it will take me a bit of time to document.

I also built an APK from this code if you want to look: http://d-h.st/Tcj

It's basic and has a similar UI to Spirit1. It also looks spookily similar to the original 3 yr old Spirit1 prototypes, LOL.

Screenshot is here: http://xdaforums.com/album.php?albumid=10337&pictureid=41532

Unlike the actual Spirit2 UI, it's designed to be basic and functional, and not pretty. If you want to modify it and see what you can make, go ahead. I'm licensing this App Inventor 2 code/blocks as GPL v3.

Presets won't work right unless you reset them with Spirit2 v1124.

AI2 support requires Spirit2 v1124.

Screen data can only be updated by polling, which is set to 1 second.

Hypothetically, I or someone could build special easier to use and more efficient blocks for AI that are integrated with the FM, but I have doubts that will happen any time soon, or ever.
 
Last edited:

Airbag888

Senior Member
May 5, 2010
326
63
My feedback:

Running Temasek 4.4 (Temasek kernel) V8 for Samsung GS3 I9300 Dalvik

On 1st launch, I got a crash upon unmuting the sound.
On subsequent launches, no crash and app is able to switch channels, (either via dial or manual input or saved presets)
I have tried the record button, it appears to work although I don't know where it saves the audio clips.

Great app :)
 

danielalarcon

Senior Member
Aug 22, 2012
181
48
Guatemala
Not really, there is no cross recognition of licenses.

Just download and run Spirit2. At this time, the only difference if you buy it is you can turn statistics reporting off 3 days after purchase. Maybe I'll add a hidden code for that too.

I've promised that anyone who has Spirit Unlocked can upgrade to Spirit2 at no cost. The way I do that is cancel the original Unlocked order and Spirit2 can be bought when the price is lower/about the same as Unlocked. I expect to match prices around December 2-3.

The main conflicts here are that Spirit2 isn't "ready for prime time" yet, and Spirit Unlocked supports many more phones that Spirit2 does. So if you have 1 or more phones for which you need Unlocked as well as 1 or more for which you want to run Spirit2, that's a small bit of a problem. But not too big, because Unlocked doesn't have any license protection and I don't expect to update it much, if at all, anymore.

Just a note from a sattisfied Spirit Unlocked user. I've used Spirit U for around 2 years, now that work is getting done on Spirit2, all I can say is, thanks for the first gen, and, I will get the new version from the play store, this app and its support simply are priceless!
 
  • Like
Reactions: mikereidis

mikereidis

Inactive Recognized Developer
Jan 28, 2011
7,823
4,146
Ottawa/Gatineau, Canada
My feedback:

Running Temasek 4.4 (Temasek kernel) V8 for Samsung GS3 I9300 Dalvik

On 1st launch, I got a crash upon unmuting the sound.
On subsequent launches, no crash and app is able to switch channels, (either via dial or manual input or saved presets)
I have tried the record button, it appears to work although I don't know where it saves the audio clips.

Great app :)

Thanks for your report.

As with Spirit1, recorded WAV files go to SDCard: /sdcard/music/fm/

File names are mostly fixed length, easily parse-able date and time of recording start, like:

fm_2013-08-06_05-20-43.504+0000.wav
 

mikereidis

Inactive Recognized Developer
Jan 28, 2011
7,823
4,146
Ottawa/Gatineau, Canada
Just a note from a sattisfied Spirit Unlocked user. I've used Spirit U for around 2 years, now that work is getting done on Spirit2, all I can say is, thanks for the first gen, and, I will get the new version from the play store, this app and its support simply are priceless!

It's nice to hear from happy users. :)

I expect to post a new version within 12 hours. It fixes:

- Samsung no RDS after 60 seconds (code I forgot about when I wrote it 1 year ago for the first Spirit2 alpha releases.)

- Lots of problems on Qualcomm devices. I previously "borrowed" Sony's FM plugin, which shows that 3rd party plugins can work. Now I've written my own plugin that I control. I noted the latest Sony plugins have some proprietary stuff making it incompatible, at the lowest level anyway, <groan>...

- First support for HTC One with a 3rd low level root needed plugin. It's working for testing now, but needs some fixing.
 

mikereidis

Inactive Recognized Developer
Jan 28, 2011
7,823
4,146
Ottawa/Gatineau, Canada
It fixes:

- Samsung no RDS after 60 seconds (code I forgot about when I wrote it 1 year ago for the first Spirit2 alpha releases.)

- Lots of problems on Qualcomm devices. I previously "borrowed" Sony's FM plugin, which shows that 3rd party plugins can work. Now I've written my own plugin that I control. I noted the latest Sony plugins have some proprietary stuff making it incompatible, at the lowest level anyway, <groan>...

- First support for HTC One with a 3rd low level root needed plugin.

Spirit2 November 26: http://d-h.st/lhb

Also on Play: https://play.google.com/store/apps/details?id=fm.a2d.s2

The "Evaluation" period before Spirit2 goes to "Free" state is expanded to 7 days. In the "Free" state, RDS no longer works.


HTC One tested on stock ROM: UART mode with BT off only.

HTC One tested on GPE Kitcat and CM10.2 RC1. If BT is off, UART mode is used. If BT is on, Shim mode is used, but a reboot may be needed after first install or a ROM update.

HTC One in UART mode takes at least 8 seconds to start. Be patient.

HTC One Seek doesn't work well, and there may be other rough edges.
 

mikereidis

Inactive Recognized Developer
Jan 28, 2011
7,823
4,146
Ottawa/Gatineau, Canada
Galaxy S GT-I9000.

In case anyone missed it, I've reversed my decision to not support Galaxy S in Spirit2, at least for now, and likely until it disappears from my sales stats.

So, GT-I9000 is now supported in Spirit2, on rooted AOSP ROMs only.http://d-h.st/lhb

Speaker damage is still a risk for a small minority of phones.

Voodoo sound support is still required in the kernel, but almost every AOSP GS1 kernel has that now.

There is still likely a high pitched sound and mono issue in some cases where the microphone was used for non-telephony.

CPU consumption is high on this older, single core CPU.
 

mikereidis

Inactive Recognized Developer
Jan 28, 2011
7,823
4,146
Ottawa/Gatineau, Canada
I've now finished at least first support for all the main phones that Spirit2 is intended to target:

Samsung:

  • GT-I9000
  • GT-I9100
  • GT-I9300
  • GT-N7000
  • GT-N7100 (may be mono)

HTC:

  • One
  • OneX LTE
  • OneS
  • Evo 4G LTE


These phones are about 2/3rd of my Spirit1 sales these days. I could easily spend a year, and end up with a similar code mess to Spirit1 if I tried to support most of the last 1/3rd, most of which are older devices and incapable of digital FM audio anyway. Spirit2 will only support digital FM audio; it makes audio much simpler and robust and more functional.

But instead of the impossible & never ending task of supporting old and rare devices that I don't own, I can now concentrate on making operation close to flawless on these most popular devices that I do own. And I can add new features I wouldn't have time for otherwise.


I will also likely add support for these same phones (except Galaxy S) when stock and un-rooted. This is mostly intended for a different app package and name for un-rooted devices only. I may or may not make this stock support available in Spirit2.


I will also evaluate new phones on an ongoing basis for official support. Eg. I might support Moto G with the existing code, and Galaxy S5 with new code, etc.
 
Last edited:
  • Like
Reactions: AA1973

r0bilyn

Member
Sep 28, 2013
20
3
Rome
Galaxy S GT-I9000.

In case anyone missed it, I've reversed my decision to not support Galaxy S in Spirit2, at least for now, and likely until it disappears from my sales stats.

So, GT-I9000 is now supported in Spirit2, on rooted AOSP ROMs only.http://d-h.st/lhb

Speaker damage is still a risk for a small minority of phones.

Voodoo sound support is still required in the kernel, but almost every AOSP GS1 kernel has that now.

There is still likely a high pitched sound and mono issue in some cases where the microphone was used for non-telephony.

CPU consumption is high on this older, single core CPU.
Thank you for your new decision! :)
Under what conditions can occur speaker damage for GT-I9000? Does it depend on a particular HW characteristic of some phones?
In order to avoid speaker damage, is it better to use Spirit1 or Spirit2?
 

whiskerp

Senior Member
Mar 22, 2012
273
127
KitKat

Hi

I've been trying to get this to work on Temasek's CM11 (Android 4.4) for Samsung i9300 but it just seems to hang. Do you intend to support i9300 CM11 KitKat?

Thanks
Peter

EDIT: OK, I've now got it to work on Temasek's 4.4 build (25/11/2013) - thanks! The old Spirit Free app doesn't seem to work.
 
Last edited:

Cookie Ninja

Senior Member
Jan 21, 2010
2,043
700
No Xperia Z series support? I am saddened....... Spirit was the only reason I could venture beyond stock-based ROMs and flash AOSP/PAC ROMs (and still have FM radio support). Started loving spirit way back in 2011 after flashing CM7 on my Inc S......

Dead Cookies leave no trails...
 
Last edited:

xeizo

Senior Member
Nov 3, 2013
939
551
Stockholm
www.xeizo.com
Hi

I've been trying to get this to work on Temasek's CM11 (Android 4.4) for Samsung i9300 but it just seems to hang. Do you intend to support i9300 CM11 KitKat?

Thanks
Peter

EDIT: OK, I've now got it to work on Temasek's 4.4 build (25/11/2013) - thanks! The old Spirit Free app doesn't seem to work.

Works fine here with Temasek CM11 V9 and Boeffla-kernel, but I gave up and went back to Dalvik as some essential apps doesn't work under ART as of yet, could be that's why it works ...

edit. oh, and many thanks to the creator, it works flawlessly on my phone :) One ugly default icon though ;)

edit2. heh, you edited while I edited, nice that it works now!
 
Last edited:
  • Like
Reactions: mikereidis

DNASoldier

New member
Nov 26, 2013
1
0
I got a N7100 CM11 Kitkat
spirit unlocked doesn't work on my phone and spirit 2 does work when i have ear plug in left is very low volume and right is peeping en when i unplug it it does work when i hold the plug very close to the phone.

are you going to fix mono when earplugs are in?
or can you help to config the spirit unlocked version?
 

mikereidis

Inactive Recognized Developer
Jan 28, 2011
7,823
4,146
Ottawa/Gatineau, Canada
No Xperia Z series support? I am saddened....... Spirit was the only reason I could venture beyond stock-based ROMs and flash AOSP/PAC ROMs (and still have FM radio support). Started loving spirit way back in 2011 after flashing CM7 on my Inc S......

Dead Cookies leave no trails...

I've added device detection for XperiaZ for next release of Spirit2. Hopefully it will work, on rooted devices at least.

Let's call it unofficial support, until we see how many problems it may have.

I have very few sales on Sony devices*, and though the XperiaZ is the top Sony phone in my stats for 2013, that only represents about $220 income over the last 6 months.


*- 1 reason may be that there is a CM/FreeXperia FM app on some Sony devices.
 
  • Like
Reactions: Cookie Ninja

mikereidis

Inactive Recognized Developer
Jan 28, 2011
7,823
4,146
Ottawa/Gatineau, Canada
Works fine here with Temasek CM11 V9 and Boeffla-kernel, but I gave up and went back to Dalvik as some essential apps doesn't work under ART as of yet, could be that's why it works ...

edit. oh, and many thanks to the creator, it works flawlessly on my phone :) One ugly default icon though ;)

That icon is just a picture of one of the most legendary "ghetto blasters". Most icons are very simple to allow quick identification.

What sort of icon would you prefer ? What about Spirit1 icon ?


I only briefly tested ART on one of the earliest KitKat builds for HTC One, I think OmniROM.

I saw an error about JNI, and SpiritX requires JNI.

I'll look at ART again now that I have 3 official stock KitKats, 1 for each Nexus7 and GPE HTC One.
 
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 64
    Spirit2 is the successor to Spirit1 Unlocked and is the "Best Darn FM app"* in existence ! :)

    I'm closing this thread again in favor of the general Spirit1/Spirit2 thread: http://xdaforums.com/showthread.php?t=1059296&page=868#post57106533

    It's too confusing trying to figure out where to post what.

    I will update first 10 posts of this thread as documentation when I can.

    Spirit2 Beta releases on Play for customers, updated sign up info: http://xdaforums.com/showpost.php?p=57079402&postcount=795

    Android ONE = Google FM Radio ?? !! http://xdaforums.com/showpost.php?p=53677209&postcount=781

    Spirit2:
    Hi Mike, I am still enjoying Spirit 1, is there any reason to pay again for Spirit 2? : http://xdaforums.com/showpost.php?p=52304934&postcount=647

    HTC One M8 Verizon ! :) http://xdaforums.com/showthread.php?p=51904184

    Spirit2 is a real, tuned, over-the-air FM radio app for Android. It does not require Internet access.

    Requires AOSP !: If you don't know what AOSP means, Spirit2 is not for you. Spirit1 Unlocked works on numerous stock phones: http://xdaforums.com/showthread.php?t=1059296

    *"Best darn FM app": Yes, it has some bugs, and some device support issues, and may lack some of the "polish" of many stock FM apps, but it's the most functional and even the current RC1 has more settings than stock apps.

    The ONLY FM app supporting ALL this: Equalizer, Effects, Recording, BT A2DP and Visualizer.

    Spirit2 also supports multiple "remote" displays and controls: Home and lock-screen widget, lock-screen, notification shade, BT AVRCP and future Android remotes. AVRCP puts RDS and station info on the display of compatible BT headsets, and controls Pause/Play and preset selection. Was pretty cool the first time I saw that working. ;)


    Install Spirit2 RC2, March 26 Google Play: https://play.google.com/store/apps/details?id=fm.a2d.s2

    Spirit2 Beta group. Latest releases for Play customers: https://play.google.com/apps/testing/fm.a2d.s2


    March 25 New Info:


    "Upgrades" from Spirit1:


    If you've been happily using Spirit1 Unlocked for at least 3-6 months, please consider Spirit2 as a second purchase, for a next generation FM app. Help me give Spirit2 the 3+ year lifespan that Spirit1 has had so far. My income is still at the lowest end of "tolerable". Support me and I can support you.

    The price is a bit higher than Spirit1 Unlocked. It will be dropped a bit on the 1st day of each month.

    At Release Candidate #1 all known major bugs have been addressed. Please understand: software always has bugs, new ROMs can require new code and improvements are ongoing.

    Thanks ! :)
    Mike.
    13
    Spirit2 "Official Support"*: ONLY these phones running "Compatible AOSP"** ROMs:

    • Samsung GS3 GT-I9300
    • Samsung GS2 GT-I9100
    • Samsung GS1 GT-I9000
    • Samsung Note2 GT-N7100
    • Samsung Note1 GT-N7000
    • HTC One (GPE requires BT off)
    • HTC OneXL LTE, OneS, Evo 4G LTE (2013 CM11 only. 2014 kernels broke FM)
    • LG G2 D802 International and Sprint LS980 only. (Some stock, CM11 and Mahdi ROMs only as of March, 2014)
    • Motorola Moto G
    *"Official Support" means I own the phone and I can properly support it.


    **"Compatible AOSP" ROMs includes as many AOSP ROMs as I can reasonably support, that have the FM and audio kernel drivers needed to enable FM. CM11 is the most popular and best supported, except for the incompatible 2014 kernels for HTC OneXL LTE, OneS, and Evo 4G LTE. LG G2 is only supportable on CM11 and Mahdi ROMs as of March, 2014.


    Unofficial Support:

    The only other devices with a chance of working fully are those with Qualcomm WCN3660 or newer compatible FM/BT/WiFi chips as well as Qualcomm WDC9310 or newer compatible audio chips. This includes most late 2012+ Sony devices starting with Xperia T. These may or may not work well, and are not officially supported. With sufficient demand I will consider buying a "Z" device and officially supporting some Sony's.


    Stock ROMs:

    Spirit2 also works reasonably well on many stock or stock derived ROMs when rooted. But there are often problems, such as FM over BT issues on Samsung stock ROMs. Most of my customers are on AOSP/CM ROMs.

    Stock FM apps are available on stock ROMs, and few stock ROM users support Spirit financially, so I focus on AOSP. The Death of access to stock, unrooted OEM proprietary FM APIs has sharpened that focus: http://xdaforums.com/showthread.php?p=50954346


    Support for New Devices:

    Support for new devices will be considered IF all of these are true:

    • FM is possible. GS4, Note3 (except Sprint) and GS5 are not possible for anyone to ever support. See GS5: http://xdaforums.com/showpost.php?p=50600906&postcount=7541
    • Digital FM Audio is possible, the Spirit way. Most higher end 2013+ phones are capable, as well as some lower end, such as Moto G.
    • Popular among AOSP ROM users. Galaxy S and 5 inch Note class flagships are the vast majority of Spirit2 and current Spirit1 Unlocked sales.
    • Higher end ; Inexpensive phones are great, but most apps are sold on high end devices.
    • I need to be convinced that the costs of purchasing this phone, PLUS the much greater costs of supporting it will result in at least a liveable wage. Just learning how to and flashing various ROMs can add up to hundreds of hours. Add fixing soft-bricks, learning the HW & SW, investigating, reverse-engineering, coding, and doing ongoing updates, fixes, workarounds and support and you get a glimpse of why Spirit2 support is limited to a handful of the most popular devices.
    • Ideally, the non-International North American variants support FM, at least in hardware. LG G2 and all Samsungs are a great disappointment here.

    Every day I get MANY Spirit1 Unlocked debug logs in my email from pirates. Most of them come from less expensive devices, especially Mediatek devices from Huawei, ZTE, and much lesser known companies.

    I have little interest in supporting phones that might earn me $100 if I got lucky, and would drown my email with even more pirate debug logs.
    10
    Usage:

    Power control:

    • Status: Center of shiny frequency dial power icon is blue if on or grey if off.
    • Toggle: Tap center of shiny frequency dial where blue (if on) or grey (if off) power icon is.
    • On: Tap Play button at lower right or in widget.
    • Off: Tap square Stop button at lower left, in widget or in notification shade.
    • Auto on: Start app to automatically turn on FM.
    • Auto off: Start another music app and FM will automatically turn off.
    Tuning:

    • Dial: Big shiny frequency dial displays and can be used to set frequency.
    • Blue Digital: Tap numbers to manually enter frequency.
    • Seek: Previous and Next buttons to left and right of Blue Digital display seek down or up to next strong station. Same for widget, notification shade, lock-screen and other remote controls, but ONLY when there are less than 2 presets programmed.
    • -/+: Left and right buttons below seek buttons tune down or up to next valid channel, depending on Band setting.
    • Presets: There are 16 presets at bottom. Press or long press a "+" to set or reset the current frequency as a preset. RDS names are now supported.
    • Preset -/+: When 2 or more presets are programmed, they can be navigated with the Previous and Next buttons for the widget, notification shade, lock-screen and other remote controls. With 0-1 presets, these are seek controls.
    Mute/Unmute:

    • Status: Pause/Play button at lower right, in widget or in notification shade shows expected result of tapping it. Eg shows Pause if currently playing.
    • Toggle: Tap Pause/Play button to pause or play audio.
    Volume:

    • Status/Change: Tap speaker button at top right or use hardware or headset media buttons to display and change Music stream volume.
    Record:

    • Status: Red button at top left is brighter when recording.
    • Toggle: Tap red button to change recording state. Files at /sdcard/Music/fm.
    Equalizer:

    • AOSP compatible equalizers, such as CM DSP Manager, can be accessed in ROM Audio settings, or with the Spirit2 on app "Menu" key (not the old style phone Menu keys). This key has 3 horizontal lines and is at low center between Stop and Pause/Play.
    Settings:

    • Some settings are accessible by swiping from right to left to access a window to the right of the main window.
    • UI Visual: To replace the frequency dial with a waveform and spectrum analysis visualizer.
    • Band: Use "USA" in North America or "EU+" everywhere else.
    • Tuner Stereo: Stereo 2 channel when checked or Mono when unchecked.
    • Tuner AF: Alternate Frequency switching enabled when checked.
    • Audio Stereo: Distinct from Tuner Stereo and can lower CPU load and recording size.
    • Audio Speaker: Experimental Speaker mode works on some phones but may have volume control issues.


    Notes:

    • Other settings: none at this time.
    • Debug log sending is experimental.
    • Remote display and controls: for lock-screen, notification shade, widget, wired headset media buttons and remote controls and info display via BT AVRCP.
    • Speaker output experimental. Workaround: remove wired headset plug enough to switch to speaker, but still inserted enough for a good antenna connection.
    6
    About "Digital Audio":

    History:

    Before 2013, most FM radio audio on Android phones was "mostly analog"*. FM audio bypassed the digital audio chain and was injected in the final stages, after the final D->A conversions.

    FM audio was a special path that did not follow the same rules as every other source of audio on Android. Hundreds if times I've heard "... but it works fine with music players etc." and I explained how FM is different. Fm audio usually can not be equalized or modified with effects. It usually can not be recorded, visualized, or routed to BT headsets.


    AOSP Difficulties:

    Besides lacking these digital audio features, "non-digital"** FM audio is difficult to do on AOSP ROMs. AOSP usually does not use the stock audio libraries that contain support for FM. This has been a never ending source of grief and work for me; I spend at least 50% of my development time on audio issues as a result.

    Basically, Spirit will use SU/root low level functions to set up the audio hardware for FM, via kernel device driver commands for ALSA or earlier APIs. But the ROM audio library has no idea that FM is running. This can often result in conflicts that break audio, especially during audio notifications. On some popular older devices, such as HTC Desire HD, I had to create a hack that resets the entire audio system when FM is turned off. And users just have to live with the fact that audio notifications break audio, at least until FM is turned off or the device is rebooted.

    There were many other problems, including a need to continuously loop a silent audio file, to convince the audio libraries that music was playing. Otherwise, volume control was lost, among other things.

    This was rarely a problem on CM7 ROMs that included a CM FM app, because the audio libraries supported FM. But most CM9 ICS and later ROMs dropped support for FM. I considered making code contributions to CM and other ROMs to fix this problem the proper way, in the audio libraries. But I concluded this would take all of my time, may create personal conflicts and might never cover the majority of ROMs anyway.


    *"Mostly" analog: Surprisingly, just about every FM chip does internal signal processing digitally, after the initial A->D conversions, Frustratingly, virtually every 2012- phone did not use digital outputs, where they existed, but converted the Digital left and right audio back to analog.

    "Non-digital"**: I do not use this term to strictly mean "Analog". I use it to mean a method to enable FM audio that stock OEM FM apps use, and that Spirit1 uses, when not using one of the "Digital..." Audio-> Method settings. At the chip level, the audio may be digital, as is the case when using Qualcomm FM/combo chips with Qualcomm WCD9310 or compatible audio chips.


    Spirit's Digital Audio Solution:

    A digital solution to most of these problems was envisioned in late 2012, and resulted in the 1st prototype alpha releases of Spirit2 in early 2013. Spirit2 was digital only and this proved to be a much easier way to do FM audio, with few problems. When it became clear how much more work was needed to complete Spirit2, and given that Spirit1 continued to sell well enough to live, digital audio was "back ported" to Spirit1.

    Here's how it works: Instead of just sending a few commands to the audio drivers, Digital audio mode sends different commands to enable digital, then continuously reads the ALSA PCM channel. All audio data read is then written to the Android Audiotrack API, the same as most streaming apps do. A streaming app reads from the network; but Spirit reads from the FM/audio chip.

    The main disadvantage of this digital audio method is higher CPU and battery consumption. OTOH, "non-digital" audio on most AOSP ROMs required a constantly looping silent audio file anyway, so the difference is minimized.

    Another digital disadvantage is that some devices can experience brief audio drop-outs. This does not affect Samsung devices. Full and partial workarounds include modifying CPU frequency or kernel scheduler. Tuning and investigative work is ongoing.

    There are also challenges for speaker mode. The current support is experimental and does not work on all devices. But the current code is much cleaner and much more robust than Spirit1 non-digital audio, which can have issues during phone call interruptions. Volume control can also be unusual over speaker. The reason for these problems is that Android is designed to switch to speaker only when the wired headset is unplugged. But FM is unique: the wired headset is used for the antenna. A workaround for motion-less devices: remove the wired headset plug just enough to switch to speaker, but not enough to lose the antenna affect.

    But the advantages of this form of digital audio are HUGE, IMO. They have allowed me to provide all the audio features people had been asking for: recording, equalization, effects, A2DP BT headset and visualizers.

    AND it allowed me to minimize the MANY FM specific audio problems with much smaller, better designed and better written code, with a minimum of special cases. The Spirit1 audio (and other) code is a huge mess and can never be re-written IMO.

    Audio dropouts on non-Samsung devices made me consider non-digital audio methods in Spirit2, despite the work and complications that would create. But a variety of fixes and re-tuning has improved audio, workarounds have been identified and work is ongoing.

    The advantages of digital only are too great IMO to "pollute" Spirit2 code with non-digital audio. I've even removed previous non-official support for stock Sony devices in order to concentrate on digital audio that is as flawless as possible.


    Drop-out Workarounds:

    Samsung devices only rarely have audio drop-outs. I've only seen this on the oldest, now "vintage" original Galaxy S GT-I9000, and only when recording, at the same time that the equalizer, effects and the visualizer are all running. The old single core CPU gets close enough to it's processing limit that very occasional ticks may be heard, but the recording is usually fine.

    LG G2 and Moto G are working pretty well now. The worst affected are the HTC One and the HTC OneXL/S/Evo 4G LTE, or other Qualcomm FM+audio devices. Further tuning and investigation is ongoing, but these things can minimize the problem:

    • Don't record.
    • Turn screen off.
    • Disable visualizers or any other app or service that might be using CPU resources.
    • Disable equalizer or other audio effects. Bass-boost and EQ alone don't seem too bad.
    • Raise CPU minimum and/or maximum frequency (Only if you understand the risks of CPU burnout.)
    • Change CPU scheduler: Performance risks CPU failure; Interactive or Pegasusq may be better.
    6
    Troubleshooting:

    Does not start:

    • SU/root missing is the most common problem. Ensure Spirit has permission enabled in the SuperUser or SuperSU app, or with the ROM Super* settings.
    • Omni & many other ROMs require manually flashing SuperSU. After flashing, run SuperSU and respond Yes when prompted to allow SU reflash after ROM updates.
    • If your device is not officially supported, it will likely not work. Except for devices with both recent Qualcomm FM and Qualcomm audio, phone architectures for FM are very different from each other.
    Stops playing or hangs:

    • Workaround: Force stop or reboot. Fixes are ongoing.
    Audio Stops at Homescreen:

    • Disable Google Now Launcher: Homescreen Long Press-> Settings-> Voice-> "OK Google" hotword detection-> Off.
    Audio Dropouts:

    Odd frequencies only:

    • Set Band to "EU+" after swiping from right to left to reveal right side settings. Default is "EU+" unless ROM identifies location as North America.
    Where are recordings ?:

    • See /sdcard/Music/fm for WAV files named with parseable start time. Compression to MP3 files will be considered in future. Maximum of 4 GB results in 5-10 hour maximum time, depending on sample rate (22-48 K depending on phone).
    Speaker does not work:

    • Experimental at present. Workaround: remove wired headset plug enough to switch to speaker, but still inserted enough for a good antenna connection.
    Speaker volume control broken:

    • Experimental at present. Turn Screen off or use on app volume.
    Phone call problems:

    • Avoid speaker mode
    • Avoid removing or inserting wired headset while FM or phone call is active.
    Other: