473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
7 4015
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 <typename TranType>
inline void revbin_permute(TranType *a,long n)
{
if (n<=2) return;
long r=0;
for (long x=1; x<n; x++)
{
r=revbin_update(r,n);
if (r>x) swap(a[x],a[r]);
}
}

template <typename TranType>
TranType omega(double theta)
{ return TranType(cos(theta),sin(theta)); }

template <int is, typename TranType>
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<mh; j++)
{
TranType e=omega<TranType>(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 <typename TranType>
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<pw; i++)
y[i]=y[i]*x[i]; // element wise multiplication

fft<-1>(y,n); // backward transform of y[]

for (int i=0; i<pw; i++)
y[i]=y[i]/TranType(pw,0); // normalize
}

#include <complex>
/// example of use
int main()
{
static std::complex<double a[1<<21];

// revbin_permute( a, 1<<21 );
fft<1>( a, 21 );
}
Apr 6 '07 #3
On Apr 6, 5:53 am, "Udhay" <udhyakum...@gmail.comwrote:
How to get the frequency of an audio file and how to separate the low
and high frequency of an audio file
as someone else has pointed out, performing a fourier transform on the
raw data is what you need. Instead of trying to build your own
fourier transform there are ones available in the Intel Performance
Primitives Library that will do everything that you need. I've used
them for a while now and find them very fast and accurate.

Flamingo

Apr 6 '07 #4
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 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.
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 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.


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bruce Bon | last post by:
The class below is intended to play a Sun audio file (.au) in the background while the main thread, which is servicing a GUI, continues without impact. It doesn't work. For a sound file that...
1
by: laredotornado | last post by:
Hello, I want to play an audio file embedded on my page by clicking on an audio image and the page change to a new page. Is there a cross-browser Javascript way to do this? Right now the code I...
0
by: laredotornado | last post by:
Hello, I want to play an audio file by clicking on an audio icon and not having the page switch out underneath. Right now the code I have is ... <html> <head> <title>Dictionary:...
5
by: Shelly | last post by:
I had a problem with uploading images in that some files did not have a type of "image/something" from the $_FILES which I used for my verification. Someone (THANK YOU) suggested using...
4
by: Gary Morrison | last post by:
I need to create a lot of fairly-short audio files from the concatenation of a lot of even shorter audio files. I'd like to control that from a Perl script. The audio files would presumably be...
3
by: abrtlt | last post by:
I would like to have a web page in which, when the user clicks on any of several specific elements, a specific audio file is played, without reloading the page. The specific audio file name is...
6
by: Quentin | last post by:
Hi, I want to save an audio stream into a circular file so that I only keep say the last hour's audio. Can anybody help? Cheers, Quentin
13
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives,...
1
by: =?Utf-8?B?Qm9iQWNoZ2lsbA==?= | last post by:
I am using Windows Media Player to play my half second audio files one after the other using the code below... My problem comes when I play a second audio file immediately after the first one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.