The loop performs easily in audacity however once I run it within the machine or simulator it clicks every loop at completely different intensities.
Im utilizing .flac format as a result of it is the one one not including a bit of silence at the beginning/finish of every file like mp3 or m4a and isn’t heavy like wav.
I config the session at App stage:
//Audio
let audioSession = AVAudioSession.sharedInstance()
do {
attempt audioSession.setCategory(.playback, mode: .default, choices: [.mixWithOthers])
attempt audioSession.setActive(true)
} catch {
print("Setting class session for AVAudioSession Failed")
}
After which I made my technique on my class:
//PlaySound
func playSound(soundId: Int) {
let sound = ModelData.shared.sounds[soundId]
if let bundle = Bundle.predominant.path(forResource: sound.filename, ofType: "flac") {
let backgroundMusic = NSURL(fileURLWithPath: bundle)
do {
audioPlayer = attempt AVAudioPlayer(contentsOf:backgroundMusic as URL)
audioPlayer?.prepareToPlay()
audioPlayer?.numberOfLoops = -1 // for infinite occasions
audioPlayer?.play()
isPlayingSounds = true
} catch {
print(error)
}
}
}
Does anybody have any clue?