PinePhone call quality

I bought a PinePhone a couple of months ago, mainly for the opportunity to play with it and see what it could do. Since I work for a company that does voice call quality testing, the first thing I wanted to do was figure out how to play back our audio quality test files and then do some call audio quality tests.

When doing call audio quality testing, it’s very important that the audio you’re playing back not be transcoded or even resampled, so using PulseAudio or PipeWire was completely out of the question. Figuring this process out turned out to be far harder than I expected, so I thought I should document how I made it work. My background is in IT infrastructure, and I am not an audio engineer or a telephony expert, so I wouldn’t be surprised if there are better ways of doing things. Suggestions are very welcome on Twitter or via email.

How to play audio over a call

  1. Insert your SIM into the phone. Then, setup Fedora on a microSD card and boot it
  2. Connect to the network either using wifi or a dock
  3. Make sure to enable sshd.service if it’s not already enabled. Then SSH into the PinePhone (default username is pine and default password is 123456), and become root (sudo su)
  4. Install asterisk dnf -y install asterisk
  5. Build and install the Quectel asterisk module. To build the channel module, you’ll need to download the source RPM for the asterisk package installed in step 4, build it (at least to the point where it’s generated the include files), and then pass the build directory to ./configure --with-asterisk=...
  6. Copy qeuctel.conf to /etc/asterisk. The defaults should suffice
  7. Stop phosh.service and ModemManager.service
  8. Setup an extension in /etc/asterisk/extensions.conf with the name [incoming-mobile]. This is what any incoming calls will be directed to. For testing, I suggest renaming the [demo] section to [incoming-mobile]
  9. Add the asterisk user to the audio and dialout groups
  10. Set the audio mode to Voice call in ALSA by running alsaucm -c PinePhone set _verb 'Voice Call'. (Rather embarrassingly, this step took me days to figure out!)
  11. In the playback tab of alsamixer, make sure that Line Out is unmuted (even if the volume is at 0%), along with AIF1 Slot 0 Digital DAC and AIF2 Digital DAC
  12. In the recording tab of alsamixer, disable recording for AIF1 Data Digital ADC and AIF2 ADC Mixer ADC. Then, enable recording for AIF2 ADC Mixer AIF1 DA0
  13. Start asterisk.service
  14. Run asterisk -vvvcgr
  15. Call your PinePhone’s number from another phone. On the other phone, you should hear the Asterisk demo (or whatever other audio you configured to play), and on the PinePhone, you should see something like this:

How the PinePhone modem routes audio

(short answer: Magic!)

Figuring out steps 10-12 above was a great example of 10% of the work taking 90% of the time. This section explains what I think is going on here, but a lot of it is guesswork. Unless you’re interested in the inner workings of the PinePhone and its modem, feel free to skip this section.

It didn’t take long for me to figure out how to build asterisk and the Quectel channel module, and, when I placed my first call after starting up asterisk, I was plenty excited when the call went through, Asterisk picked up… and then silence! Roughly 30 seconds of silence (oddly enough, the length of the file I was playing), and then asterisk hung up.

It became clear to me that asterisk thought it was playing audio, even if it wasn’t actually making it to my other phone. Thus started days of experimentation, trying to figure out the problem.

The PinePhone has a Quectel EG25-G LTE modem in it that, by default, provides a number of USB serial devices, one of which (supposedly) is where we’re supposed to send and receive audio.

After loads of scattered documentation around the internet (fun fact, the Quectel EC25 modem has some very different features, so you can’t just assume its manual applies to the EG25-G), it became more and more clear that, for voice calls, the PinePhone’s modem is tied into the PinePhone’s DSP, which is exposed in Linux through ALSA. AIF2 is the modem’s voice channel while AIF1 is the PinePhone’s normal audio DAC.

It took lots of experimentation to work out that, to get audio from the USB serial device to actually get sent through the modem, you need to route AIF1’s output audio into AIF2 (which is what we’re doing in step 12). You also need to enable the AIF1 and AIF2 DACS (step 11), and make sure that Line Out is unmuted.

The strange thing is that, even though we’re using ALSA to enable a number of different switches, none of the volume levels have any effect on the volume sent through the modem. I suspect that this is because Asterisk is already sending the exact audio data without any processing.

One limitation our current system has is that it only transmits audio in 8KHz, which means we haven’t yet been able to test VoLTE. From what I can see, the EG25-G supports VoLTE, but I’ll need to do more research to figure out how to turn it on.

Call quality

So, now that we can play audio through Asterisk, what does the actual call quality look like?

At Spearline, we commonly use PESQ to test a call’s audio quality, and we’ve got a great summary of what PESQ is and what the scores actually mean here. We ran two sets of tests on the PinePhone, one when the phone was in Spearline’s headquarters, and the other when it was in my home (a couple of kilometers away from the office).

This first chart shows the PESQ scores when the phone was at Spearline’s headquarters.

The scores vary from 3.51 to 4.01 with an average of 3.78, which puts them at the top end of the second-highest band of PESQ scores: 3.30-3.79 Attention necessary: no appreciable effort required. In other words, a call placed to the PinePhone while in Spearline’s headquarters would sound good, but you would have to put in a very small amount of effort to pay attention.

This second chart shows the PESQ score when the phone was moved to my home.

Here the scores were higher and more consistent, ranging from 3.88 to 4.02 with an average of 3.96, which puts them in the highest band of PESQ scores: 3.80-4.50 Complete relaxation possible; no effort required. In other words, a call to the PinePhone at my home would result in a call where the conversation could be completely relaxed, with no strain to understand what the other person is saying.

This shows that, as expected, call quality will depend on the tower you’re connected to and the distance to the tower. However, both sets of scores are high enough to make it clear that the PinePhone is fully capable of making high quality audio calls.

Photo Pinephone betaedition by ICCCC used under the CC0 license

An update

Zchunk metadata in Fedora

It’s been four months since my last post, so an update is long overdue. First things first, after a couple of last-minute near disasters, Fedora 30 was released with zchunked metadata. We’ve had a few bugs show up, but, at this point, I think they’re all fixed.

Fedora 30’s release has sparked some interest in zchunk, and a new contributor has started working on a native java port. I’m hoping to get some time soon to clean up the documentation and add some more features.

My life

For those who aren’t aware, after over fifteen years in Beirut, last July we moved to my wife’s hometown of Skibbereen in Ireland, and next week will mark our first year here. It’s been an interesting year with a lot of ups and downs.

The first four months were spent job-hunting, and it was an interesting experience that I’d be quite happy to never have to repeat. I naively assumed that, with my background, finding work would be a quick process, and that definitely wasn’t the case. It was less that I couldn’t find work and more that the whole hiring process took much longer than I expected.

Apparently coding experience doesn’t translate into interview experience, as I found out when I did my first. In the stress of the moment, I completely bombed one of the low-level skill questions, painting myself, I’m sure, as a first-class idiot. The interviewer was very gracious, but the interview ended shortly afterwards and I got my official rejection a few minutes later. It was only afterwards that I realized that, at age 37, this had been the very first interview I had ever done in my life.

I applied for positions in companies around Ireland, and one thing I found interesting is that a majority of the interviews I got were as a result of connections I’d made, mostly through Fedora. In the tech world, as much as any other field, it seems that our ability to build and foster relationships is still essential to our professional growth. It’s not a substitute for competence, but skill can’t replace it either.

One thing that paints a compelling picture of a company is how it handles rejections. Most companies did well enough, having the courtesy to send out an email when they had decided against me. A number ghosted me, which still puts a sour taste in the mouth when thinking about them. And then there was Red Hat. Now, to be fair, my interviews at Red Hat were different anyway, but a Red Hat rep personally called me and let me know that they were passing on me because they’d found a more qualified applicant. While I was obviously disappointed, I felt that this set a really high bar for other companies.

In November, I got hired on by a local automated phone number testing company called Spearline. They test phone call quality using in-country servers around the world, and I quickly settled in, getting the opportunity to move their web applications over to a micro-services architecture. The company gave me a lot of responsibility, was a great place to work, and I built a lot of good friendships there.

This brings me to a few months ago, when I got a call from Sangoma, a VOIP hardware and software company. I had interviewed with Sangoma back in August, and it had gone really well, but they then acquired Digium, the maker of Asterisk, and put a hiring freeze into place. The call was to tell me that the hiring freeze was over and they wanted to interview me again. One thing led to another, and, in May, I joined Sangoma as a software engineer on their cloud development team. I’m working from the Ludgate Hub, a local co-working space, and I’m thoroughly enjoying the job.

Last week, I passed my Irish driving test, which was the last major item on the “Moving to Ireland” to do list (for context, last year, less than half of the people who took their driving test passed). The process is far more convoluted and stressful than it should be for someone who already has two driving licenses, but it’s finished.

It’s been an interesting year, but, in the end, a really good one. While we miss Lebanon, we are truly blessed to be able to start building a new life here in Ireland.

Dun Laoghaire Lighthouse by Kevin Williams, used under a CC BY-SA 2.0 license.