AVAudioUnitEQ / .BandPass filter doesn't work
I can’t get the
AVAudioUnitEQ to work.
Here’s a piece of code that should filter out everything except 659.255Hz +/-0.05 octaves:
// Create Audio Engine var audioEngine = AVAudioEngine() // Create Equalizer Node var equalizerNode = AVAudioUnitEQ(numberOfBands: 1) var epualizerParameters: AVAudioUnitEQFilterParameters = equalizerNode.bands.first as AVAudioUnitEQFilterParameters epualizerParameters.filterType = .BandPass epualizerParameters.frequency = 659.255 epualizerParameters.bandwidth = 0.05 epualizerParameters.bypass = false audioEngine.attachNode(equalizerNode) // Configure Audio Engine var format = audioEngine.inputNode.inputFormatForBus(0) audioEngine.connect(audioEngine.inputNode, to: equalizerNode, format: format) audioEngine.connect(equalizerNode, to: audioEngine.outputNode, format: format) // Start Audio Engine var error:NSError? audioEngine.startAndReturnError(&error)
However, when I run it, put on my headphones and sing into the microphone, I can hear myself loud and clear.
Now, according to Wikipedia, the Band Pass filter is:
… a device that passes frequencies within a certain range and
rejects (attenuates) frequencies outside that range.
What am I doing wrong? I want to filter out everything except given frequency range.
- Allow users background music in swift 2.0
- Playing many different videos on iphone using AVPlayer
- How do I make AVCaptureSession and AVPlayer respect AVAudioSessionCategoryAmbient?
- AVCaptureVideoPreviewLayer orientation - need landscape
- AVFoundation: add text to the CMSampleBufferRef video frame
- UIImagePickerController: Getting image capture from video
2 Solutions Collect From Internet About “AVAudioUnitEQ / .BandPass filter doesn't work”
It was your EQ params.
I created a github project with sliders and switches. You can hear the difference.
This works in my project which uses a playerNode.
var format = engine.mainMixerNode.outputFormatForBus(0) engine.connect(playerNode, to: EQNode, format: format ) engine.connect(EQNode, to: engine.mainMixerNode, format: format)
I see you’re using the engine’s inputNode. Try swapping out these few lines (hook into the mixer instead of the outputNode) and let us know if it works.
- How to deal with MKReverseGeocoder / PBHTTPStatusCode=503 errors in iOS 4.3?
- How to fit view controller for all iPhones?
- Local notification sound not working
- Add new templates in Xcode
- Are headphones plugged in? iOS7
- Swift. Proper initialization of UITableViewCell hierarchy
- What is the android.widget.Toast equivalent for iOS applications?
- Error when using
- Drawing gradient on UIView not working with iOS 9
- Force static linking of library linked to Xcode target?
- How can I set the UINavigationbar with gradient color?
- Documentation about compiler options for Swift
- How to calculate percentage using % as a postfix unary operator in Swift 3 and still be able to use % for modulo?
- Debugging in XCode: Exception Breakpoints
- Parsing a Java Properties file in Objective-C for iPhone