Created
May 19, 2012 22:45
-
-
Save bartolsthoorn/2732661 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NVHighpassFilter.h | |
// NVDSP | |
// | |
// Created by Bart Olsthoorn on 18/05/2012. | |
// Copyright (c) 2012 Bart Olsthoorn. All rights reserved. | |
// | |
#import "NVDSP.h" | |
@interface NVHighpassFilter : NVDSP | |
@property (nonatomic, assign, setter=setCornerFrequency:) float cornerFrequency; | |
@property (nonatomic, assign, setter=setQ:) float Q; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NVHighpassFilter.m | |
// NVDSP | |
// | |
// Created by Bart Olsthoorn on 18/05/2012. | |
// Copyright (c) 2012 Bart Olsthoorn. All rights reserved. | |
// | |
#import "NVHighpassFilter.h" | |
@implementation NVHighpassFilter | |
@synthesize Q; | |
@synthesize cornerFrequency; | |
- (id) init { | |
[super init]; | |
return self; | |
} | |
- (void) setQ:(float)_Q { | |
Q = _Q; | |
[self calculateCoefficients]; | |
} | |
- (void) setCornerFrequency:(float)_cornerFrequency { | |
cornerFrequency = _cornerFrequency; | |
[self calculateCoefficients]; | |
} | |
- (void) calculateCoefficients { | |
if ((cornerFrequency != 0.0f) && (Q != 0.0f)) { | |
[self intermediateVariables:cornerFrequency Q:Q]; | |
a0 = 1 + alpha; | |
b0 = ((1 + omegaC)/2) / a0; | |
b1 = (-1*(1 + omegaC)) / a0; | |
b2 = ((1 + omegaC)/2) / a0; | |
a1 = (-2 * omegaC) / a0; | |
a2 = (1 - alpha) / a0; | |
} | |
} | |
- (void) dealloc | |
{ | |
[super dealloc]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment