05-23-2021, 11:24 AM
(This post was last modified: 05-23-2021, 11:37 AM by vortex.
Edit Reason: Corrected a mistake about filtering
)
Was able to reproduce the issue by calling another phone number, this time someone else's cellphone. So it definitely is not the receiving phone.
I did some digging in the sound system. I started with the schematics for the 1.2b revision and megi's page Audio on PinePhone to understand the system. The CPU's audio unit handles all audio routing and mixing. The microphone essentially connects directly the the CPU (see pages 5 and 8 of the schematic), meaning that the amplifiers in megi's diagram are inside the CPU itself rather than external. Sound is transmitted to the modem from the CPU via its PCM interface (page 15), passing through a TXB0104YZT level shifter (can find the part on the PinePhone component list).
So the pickup is happening between the CPU and the microphone and there is no external amplifier involved, for better or worse.
One good news is that the connection between the CPU and the modem is digital, so short of really really bad noise that connection is immune to pickup.
I am assuming that Mobian at the present time (and likely other distros) are using either the sound routing scheme in megi's page Audio on PinePhone or a similar one where the CPU's audio unit is doing the heavy lifting and the CPU cores are doing nothing since that saves power. A brief look at callaudiod suggests that this is the case since Arnaud Ferraris says in Issue #13
Based on how it looks the the CPU's audio unit works, it looks like it should be possible to instead read the microphone into userspace, filter it with a notch/band-stop filter, and then send it back into the audio unit to send to the modem. I still need to record the audio and look at the spectrogram to see what frequency needs to be filtered out and how wide the band would need to be. My guess, from playing around with some Butterworth filters with scipy.signal, is that a 2nd to 5th order notch/band-stop IIR filter would probably be sufficient and would be relatively cheap to compute, though it would need to have small and/or constant lag.
Luckily, it seems like pulseaudio can do lowpass filtering (https://askubuntu.com/questions/869822/h...io-profile), so there might be a notch/band-stop. So it is possible that no pulseaudio filters would have to actually be written.
[EDIT- I mistakenly said that a notch/band-stop filter could be made by combining a lowpass and a highpass filter. This does not actually work. They can be combined to make a bandpass filter. I usually work with bandpass filters rather than notch/band-stop filters, so I spoke before I thought.]
Once I get a spectrogram, I am going to try to see if I can hack a filtering solution together. Though, I am really out of my depth since I would need to figure out both pulseaudio and callaudiod enough to hack the latter to do it.
The filter would obviously cut out some useful audio, but the pickup is overwhelming the useful audio in that frequency range anyways and making it hard to hear other frequencies. Luckily, people's voices' fundamental frequencies are below 1 kHz and vowels stay in the low range. It is consonants that have the high frequency tails that might suffer a bit.
[EDIT- I mistakenly said that a notch/band-stop filter could be made by combining a lowpass and a highpass filter. This does not actually work. They can be combined to make a bandpass filter. I usually work with bandpass filters rather than notch/band-stop filters, so I spoke before I thought.]
I did some digging in the sound system. I started with the schematics for the 1.2b revision and megi's page Audio on PinePhone to understand the system. The CPU's audio unit handles all audio routing and mixing. The microphone essentially connects directly the the CPU (see pages 5 and 8 of the schematic), meaning that the amplifiers in megi's diagram are inside the CPU itself rather than external. Sound is transmitted to the modem from the CPU via its PCM interface (page 15), passing through a TXB0104YZT level shifter (can find the part on the PinePhone component list).
So the pickup is happening between the CPU and the microphone and there is no external amplifier involved, for better or worse.
One good news is that the connection between the CPU and the modem is digital, so short of really really bad noise that connection is immune to pickup.
I am assuming that Mobian at the present time (and likely other distros) are using either the sound routing scheme in megi's page Audio on PinePhone or a similar one where the CPU's audio unit is doing the heavy lifting and the CPU cores are doing nothing since that saves power. A brief look at callaudiod suggests that this is the case since Arnaud Ferraris says in Issue #13
Arnaud Ferraris Wrote:No, as the signal is only routed in hardware, pulseaudio never "sees" the audio data.
Based on how it looks the the CPU's audio unit works, it looks like it should be possible to instead read the microphone into userspace, filter it with a notch/band-stop filter, and then send it back into the audio unit to send to the modem. I still need to record the audio and look at the spectrogram to see what frequency needs to be filtered out and how wide the band would need to be. My guess, from playing around with some Butterworth filters with scipy.signal, is that a 2nd to 5th order notch/band-stop IIR filter would probably be sufficient and would be relatively cheap to compute, though it would need to have small and/or constant lag.
Luckily, it seems like pulseaudio can do lowpass filtering (https://askubuntu.com/questions/869822/h...io-profile), so there might be a notch/band-stop. So it is possible that no pulseaudio filters would have to actually be written.
[EDIT- I mistakenly said that a notch/band-stop filter could be made by combining a lowpass and a highpass filter. This does not actually work. They can be combined to make a bandpass filter. I usually work with bandpass filters rather than notch/band-stop filters, so I spoke before I thought.]
Once I get a spectrogram, I am going to try to see if I can hack a filtering solution together. Though, I am really out of my depth since I would need to figure out both pulseaudio and callaudiod enough to hack the latter to do it.
The filter would obviously cut out some useful audio, but the pickup is overwhelming the useful audio in that frequency range anyways and making it hard to hear other frequencies. Luckily, people's voices' fundamental frequencies are below 1 kHz and vowels stay in the low range. It is consonants that have the high frequency tails that might suffer a bit.
[EDIT- I mistakenly said that a notch/band-stop filter could be made by combining a lowpass and a highpass filter. This does not actually work. They can be combined to make a bandpass filter. I usually work with bandpass filters rather than notch/band-stop filters, so I spoke before I thought.]