I'm creating a sort of drum pad app, and it seems like AKPlayer is the best of many classes available in AudioKit for playing my samples.
Trouble is, when I start playing a low-frequency (bass note) sample, there's always a clicking sound (or "pop") when playing the sample!
This can be easily heard by running an unmodified "Mixing Nodes" demo from the AudioKit Playgrounds. Turn down the volume on everything but the Bass, and you'll notice the clicking every time the Bass sample loops.
I also tested the issue with AVFoundation and it is the case too. This only happens with low frequency sounds like bass. Lead and other sounds dont produce this. I also tested with my own bass sample and same issue was here.
Here is the code for both:
import AudioKitPlaygrounds
import AudioKit
import AVFoundation
//: This section prepares the players
let drumFile = try AKAudioFile(readFileName: "drum.wav")
let bassFile = try AKAudioFile(readFileName: "bass.wav")
let guitarFile = try AKAudioFile(readFileName: "guitar.wav")
let leadFile = try AKAudioFile(readFileName: "lead.wav")
var drums = AKPlayer(audioFile: drumFile)
var bass = AKPlayer(audioFile: bassFile)
var guitar = AKPlayer(audioFile: guitarFile)
var lead = AKPlayer(audioFile: leadFile)
bass.play() // will produce click/pop
guitar.play() // will not produce click/pop, only low frequency samples produce click
let path = Bundle.main.path(forResource: "3", ofType:"aac")!
let url = URL(fileURLWithPath: "path")
var bombSoundEffect = try AVAudioPlayer(contentsOf: bassFile.url)
bombSoundEffect.prepareToPlay()
// uncomment below for AVFoundation
// bombSoundEffect.numberOfLoops = -1
// bombSoundEffect.play()
How may I get rid of this click/pop?