Crashalot
Crashalot

Reputation: 34523

iOS: audio files used in app sound harsher than when played outside the app

The audio files for our iOS app sound much worse when played through the app than when played outside the app. The sounds seem harsher and more "ecohy".

Here's our code for playing audio. Are we somehow altering the playback or natural sound of the audio?

Two of the audio files we're using can be found here:

private func createAudioPlayer(filename: String) -> AVAudioPlayer  {
    // Define file URL
    let path = Bundle.main.path(forResource: filename, ofType: nil)
    let url = URL(fileURLWithPath: path!)

    // Create player
    let audioPlayer: AVAudioPlayer!
    do {
        audioPlayer = try AVAudioPlayer(contentsOf: url)
    } catch {
        audioPlayer = nil
        printError("Error creating audio player for \(url): \(error)")
        logEvent("Audio Error", userData: nil)
    }

    // Print status
    print("Created audio player for \(filename)")

    // Return player
    return audioPlayer
}


func play(file: AudioFileEnum) {
    if let player = audioPlayers[file] {
        if player.isPlaying {
            player.pause()
        }
        player.currentTime = 0
        player.play()
    } else {
        printError("Error finding audio player for \(file)")
    }
}

Upvotes: 0

Views: 62

Answers (1)

StevenOjo
StevenOjo

Reputation: 2488

Have you tried setting the volume on the audioPlayer object to something smaller, like 0.05f, and adjusting from there?

Upvotes: 1

Related Questions