Audio Degapinator - The Poor Dev’s Smart Speed
I’ve been listening to podcasts with Overcast’s Smart Speed feature turned on for long enough to have saved 55 hours of not listening to the silences between every podcast host’s thoughts.
I decided to spend 1 of those hours today making my own very simple, very limited, but surprisingly effective AVAudioPlayer version of that feature. I’ll explain below how it works, but you can check out the full Swift iOS source (there’s not much to it) on GitHub: Audio Degapinator on GitHub.
AVAudioPlayer offers features for audio level metering:
/* metering */ open var isMeteringEnabled: Bool /* turns level metering on or off. default is off. */ open func updateMeters() /* call to refresh meter values */ open func peakPower(forChannel channelNumber: Int) -> Float /* returns peak power in decibels for a given channel */ open func averagePower(forChannel channelNumber: Int) -> Float /* returns average power in decibels for a given channel */
And for adjusting playback, including:
open var rate: Float /* See enableRate. The playback rate for the sound. 1.0 is normal, 0.5 is half speed, 2.0 is double speed. */
My code then:
- turns metering on
- updates meters with a timer
- checks if there is currently silence playing using averagePower
- increases the playback rate 2x until the silence ends
I tested using the latest episode of ATP and Debug episode 49. In both cases the silences were noticeably reduced and, to my ear, sounded completely natural. I listened to the entire episode of Debug and it had shaved off a little over 3 minutes by the end.
This was a fun little project, it’s the first time I’ve looked at anything related to audio playback on iOS in quite a while and it was super interesting … I fear I may just have to write my own podcast app now.