dimitris-c / AudioStreaming

An AudioPlayer/Streaming library for iOS written in Swift using AVAudioEngine.
MIT License
244 stars 50 forks source link

Feature request - Built-in equalizer #36

Closed kartik-venugopal closed 2 years ago

kartik-venugopal commented 2 years ago

Hi, first off, I wanted to applaud you on this project ... this is a really awesome concept that would be useful to many !

One suggestion - I know that you have provided an easy hook to attach audio nodes, but it would be great if you could include a built-in equalizer that is easy for clients to manipulate, so that clients don't have to deal with the complexity of configuring an AVAudioUnitEQ node themselves.

You could provide an ISO standard 10-band EQ out of the box, which would be the most common type of EQ.

Ideally, clients would use it as follows:

let player = AudioPlayer()

// Activate the EQ.
player.eqBypass = false

// Set global gain to +5.0 dB
player.eqGlobalGain = 5.0

// Set the gain of the 3rd band to +7 dB.
player.setEQBand(2, to: 7.0)

// Get the gain of the 4th band.
let fourthBandGain = player.getEQBand(3)

// Set all EQ band gains.
player.eqBands = [0.0, 2.5, 5.5, 7.5, 5.0, ...]

// Get all EQ band gains.
print("EQ bands are currently set to: \(player.eqBands)")
dimitris-c commented 2 years ago

Hey, thanks for the feature request.

I wanted to keep the library as clean as I could from such things but still provide an easy way to plug such functionality.

The example project shows how easy to add this functionality with a few lines of code — https://github.com/dimitris-c/AudioStreaming/blob/main/AudioExample/AudioExample/Services/EqualizerService.swift