ios - Building a metronome with GCD but sounds play unevenly when screen locked -
i using gcd fire loop play tick sound periodically.
i have configured avaudiosession avaudiosessioncategoryplayback , edited info.plist file audio background mode enable background execution.
this worked when in app or goes background. however, sounds played unevenly when screen locked. sounds dick-dick-dick---dickdick-dick-dick-dick
i run in debug mode screen locked , log outputted evenly expected. guessed may audio problem.
i've spent lots of time using different audio engines , libraries none of them improved situation.
is making own loop audio way go? know audioqueue may no idea started.
any idea appreciated.
gcd doesn't guarantee timings sort of precision need doing audio timings. need jitter down <20ms, ideally <10ms or <5ms if want useful musicians, drummers.
audioqueue or audio units way go (i'd recommend audioqueue). need sample-level access sound stream, can precisely write samples 22/44/48khz resolution, you'll need. if count samples can guarantee ticks happen @ right time, long cpu can keep demands of audio hardware.
if go down route, you'll need understanding of samples, interleaving , buffer sizes.
Comments
Post a Comment