A problem I confront while using the speakers of iPhones

I write to consult on a problem I confront while using the speakers of iPhones.

The project I am working on depends largely on the sound fidelity of phone speakers. Nevertheless, a problem stands in the way: when I play through iPhone speakers an audio file (whose waveforms are illustrated in Figure 1), I get the distorted waveforms in Figure 2. The volume difference of around 5db between the first and second half of the original file somehow disappear.

However, when played through the high-fidelity speakers, the audio waveforms remain undistorted. It seems the distortion of sound volume is a feature of the iPhone speakers. So I write to confirm whether this is the case and is there a way to get rid of the distorting effects.

Figure 1:

Figure 2:

Replies

It's hard to say why the waveforms might be different in this way. The audio system does apply some signal processing.

I suggest you try "measurement" mode for your audio session:

https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/1616608-measurement

Depending on what else is going on, this might preserve your waveform more precisely.