tumtumtum / StreamingKit

A fast and extensible gapless AudioPlayer/AudioStreamer for OSX and iOS (iPhone, iPad)
Other
2.42k stars 523 forks source link

Equalizer not working for me #143

Open beeef opened 9 years ago

beeef commented 9 years ago

Hello,

At first, I really love your project - helped me a lot! But now I want to add some fancy functionalities to my app, e.g. an equalizer. I'm creating my own STKAudioPlayerOptions with my own gains on different frequency bands, so that the equalizerEnabled option is set to true after "initWithOptions". Then when a song is playing, I want to change the first 2 or 3 bands (0-2) to add some more bass to my music (hehe). In your comments in STKAudioPlayer.h you say, that this can be between -96 and +24. I tried different values and nothing works. The song stops playing after I change the equalizer bands. Is it even possible to change the equalizer while music is playing?

I have a UISlider with range [-1, +1]. When the slider changes, I want to change the value for the equalizer band.

EDIT: I tried this: after initializing the audio player I immediately set the gains for the different bands and then it works. If I use the slider to change the equalizer, it doesn't work. Even if I set the equalizer with fixed values after playing some music it doesn't work.

tumtumtum commented 9 years ago

What are you using to set the equaliser bands?

usrfrndly commented 9 years ago

Hi tum tum, thank you so much for your wonderful streamer. I'm using swift and it looks like xcode made me explicitly initialize the bands as a tuple when i was setting my options as in :+1:

let equalizerB:(Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32) = (50, 100, 200, 400, 800, 600, 2600, 16000, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0 )

        var optns:STKAudioPlayerOptions = STKAudioPlayerOptions(flushQueueOnSeek: true, enableVolumeMixer: true, equalizerBandFrequencies:equalizerB,readBufferSize: 0, bufferSizeInSeconds: 0, secondsRequiredToStartPlaying: 0, gracePeriodAfterSeekInSeconds: 0, secondsRequiredToStartPlayingAfterBufferUnderun: 0)

        println("bp making a new Player")
        self.player = STKAudioPlayer(options: optns)

Is that the correct setting of the eq bands in swift?

tumtumtum commented 9 years ago

That's the correct way to set the bands.

Do you use setGain:(float)gain forEqualizerBand:(int)bandIndex to set the band gain?

So, for example, if you want to set the gain for the 800Hz band you configured to maximum (+24db) you would use [player setGain:24 forEqualizerBand:4](4 being the index of the 800Hz and you configured)

usrfrndly commented 9 years ago

Right. I see. So would a "bass boost" be equivalent to setting the the gain to a high level for the low bands? Or is there a filter for that. I suppose I'm confused about the purpose of filters versus bands, if you could lead me in the right direction, I would much appreciate that!

tumtumtum commented 9 years ago

Yes that's right. Set the gain to a high value on a low frequency band to boost the bass. Don't worry about filters....that's a different thing.

doriansgithub commented 7 years ago

Hi Thong, we can't get audio out of the player once we move a slider in the EQ. Any ideas? Also, can you confirm that we can use NVDSP with your library for the EQ and keep your player as the Gapless player, since it's working?

doriansgithub commented 7 years ago

Is this what we need to implement before the audio plays?

[audioPlayer appendFrameFilterWithName:@"MyCustomFilter" block:^(UInt32 channelsPerFrame, UInt32 bytesPerFrame, UInt32 frameCount, void* frames) { ... }];

Thanks!