467,074 Members | 905 Online

# low and high frequency of an audio file

 How to get the frequency of an audio file and how to separate the low and high frequency of an audio file Apr 6 '07 #1
• viewed: 3665
Share:
7 Replies
 Udhay wrote: How to get the frequency of an audio file and how to separate the low and high frequency of an audio file I don't know. It isn't a C++ problem, try a group where audio files are topical (there are many different formats of audio file). -- Ian Collins. Apr 6 '07 #2
 Udhay wrote: How to get the frequency of an audio file and how to separate the low and high frequency of an audio file Look at "Discrete Fourier Transform" and the implementations of a "Fast Fourier Transform". Here is some code I toyed with - I lifted it from somewhere, I don't know exactly where and then I templateized it a little. The FFT is done in the complex number space.... You could also look up the DCT (discrete cosine transform) which I think operates in the real number space but it's not as accurate - I really don't know much about DCT's. #define PI 3.1415926535897932384626 inline long revbin_update(long r,long n) { do { n=n>>1; r=r^n; } while ((r&n)==0); return r; } template inline void revbin_permute(TranType *a,long n) { if (n<=2) return; long r=0; for (long x=1; xx) swap(a[x],a[r]); } } template TranType omega(double theta) { return TranType(cos(theta),sin(theta)); } template void fft(TranType *a, long ldn) // O(N log N) // // a[] is the TranType input data set, lsb in 0 and msb in N // ldn is the power of 2 which contains the entire data set, try to // align the data to a power of 2 by padding with zeroes. // is is the direction of the transform, +1 = forward, -1 = backward // // result is a[] { long n=1 << ldn; revbin_permute(a,n); for (long ldm=1; ldm<=ldn; ldm++) { long m=1 << ldm; long mh=m/2; for (long j=0; j(is*2*PI*j/m); for (long r=0; r<=n-m; r+=m) { TranType u=a[r+j]; TranType v=a[r+j+mh]*e; a[r+j]=(u+v); a[r+j+mh]=(u-v); } } } } template void fft_convolution(TranType *x,TranType *y, long n) // x[], y[] are the two input TranType data sets. // n is the power of 2 which contains the entire data set. // // result is y[] { long pw=1 << n; fft<1>(x,n); // forward transform of x[] fft<1>(y,n); // forward transfomr of y[] for (int i=0; i(y,n); // backward transform of y[] for (int i=0; i /// example of use int main() { static std::complex( a, 21 ); } Apr 6 '07 #3
 On Apr 6, 5:53 am, "Udhay"
 Dnia Thu, 05 Apr 2007 21:53:13 -0700, Udhay napisał(a): How to get the frequency of an audio file and how to separate the low and high frequency of an audio file NTG, but maybe it would help you: 1. Think about what is frequency. It's an occurence of something over some particular time. The more often it occurs, the higher is that frequency. 2. Sound consists from waves. Every sound can be decomposed to its component waves, which are sines. 3. A lowpass filter is lowering the amplitude for higher frequency components, and doesn't change the amplitude for lower frequency components. 4. Audio file stores values of the amplitude in particular moments of time [samples]. 5. A wave is the change in ampliture over time. So, use advices of the other posters and use FFT to decompose sound to its frequency components [spectral analysis], deamplify the frequencies you don't want and compose your sound back again using only the frequency components you want [they're sines, you know]. -- SasQ Apr 6 '07 #5
 SasQ wrote: Dnia Thu, 05 Apr 2007 21:53:13 -0700, Udhay napisaĆ(a): ..... > So, use advices of the other posters and use FFT to decompose sound to its frequency components [spectral analysis], deamplify the frequencies you don't want and compose your sound back again using only the frequency components you want [they're sines, you know]. No no ... if you want to create a filter (filter out a certain set of frequencies) then create a low-pass/high-pass/band-pass filter. There is no need to do it in the frequency domain. FFT's are relatively expensive computationally. Apr 6 '07 #6
 Dnia Fri, 06 Apr 2007 14:18:50 -0700, Gianni Mariani napisał(a): >So, use advices of the other posters and use FFT to decomposesound to its frequency components [spectral analysis], deamplifythe frequencies you don't want and compose your sound back againusing only the frequency components you want [they're sines,you know]. No no ... if you want to create a filter (filter out a certain set of frequencies) then create a low-pass/high-pass/band-pass filter. There is no need to do it in the frequency domain. FFT's are relatively expensive computationally. Oh, I didn't know that can be done better. Can you tell me something more about it? [maybe on priv, if it's NTG here]. -- SasQ Apr 7 '07 #7
 SasQ wrote: Dnia Fri, 06 Apr 2007 14:18:50 -0700, Gianni Mariani napisaĆ(a): >>>So, use advices of the other posters and use FFT to decomposesound to its frequency components [spectral analysis], deamplifythe frequencies you don't want and compose your sound back againusing only the frequency components you want [they're sines,you know]. No no ... if you want to create a filter (filter out a certainset of frequencies) then create a low-pass/high-pass/band-passfilter. There is no need to do it in the frequency domain.FFT's are relatively expensive computationally. Oh, I didn't know that can be done better. Can you tell me something more about it? [maybe on priv, if it's NTG here]. I don't remember all the details. You can probably find enough information if you google for "discrete low pass filter" or somthing like that. Apr 7 '07 #8

### This discussion thread is closed

Replies have been disabled for this discussion.