Wednesday, September 29, 2010

Audio processing



Audio signals, much like images, can undergo filtering. It is somewhat easier
to understand the impact of signal processing on audio, since audio needs not
be translated from a spatial to a frequency domain.

To load a wave (PCM) audio file, Matlab provides the function wavread :

funky = wavread('funky.wav');
It's important to capture the sampling frequency at which the sound was
recorded, otherwise the speed of playback and results of further processing
is not guaranteed to be correct:

[funky, f] = wavread('funky.wav');
To play a wave file at sampling frequency f:

wavplay(funky, f);
To view the waveform, plot the wave. Since audio is represented with many
thousand samples per second, it may be required to plot small portions of the
waveform at a time.

subplot(2,1,1), plot(funky), title('Entire waveform');
smallRange = 100000:100000+floor(f/100);
subplot(2,1,2), plot(smallRange, funky(smallRange)),..

title('100 milliseconds');



Figure 10

 Spectrogram


Figure 10.27 


2-dimensional plots of audio waves can be used to easily identify magnitude;
however, combined frequency distributions and magnitudes are more easily
viewed in a spectrogram:

specgram(funky, 512, f);
where 512 is the number of samples that are used for the discrete Fourier
Transform, and thus a grouping factor of samples per column in the spectrogram image.




Figure 10.28


Plotting both the original waveform and the spectrogram, it is possible to find
correspondences between the two graphical representations:

subplot(2,1,1), plot(funky), axis('tight');
subplot(2,1,2), specgram(funky,128,f);


However, it is easier to find such similarities in smaller portions of audio.
We can also find
repeating patters:

subplot(2,1,1), plot(funky(100000:150000)), axis('tight');
subplot(2,1,2), specgram(funky(100000:150000),128,f);



Figure 10.29

 Filtering



We will examine audio filtering in the sense of specific frequency suppression and
extraction. There are many different types of filters available for the construction
of filters. We will specifically use the Butterworth filter.
Matlab includes function butter for building Butterworth filters of three sorts:
  • 'low' : Low-pass filters, which remove frequencies greater than some specified value.
  • 'high' : High-pass filters, which remove frequencies lower than some specified value.
  • 'stop' : Stop-band filters, which remove frequencies in a given range of values.

Frequencies values are specified in normalized terms between 0.0 and 1.0, where 1.0 corresponds
to half the sampling frequency: f/2. A given frequency is thus expressed in terms of this value,
for example, 1000Hz = 1000/(f/2).
Filters are described in terms of 2 vectors ([b, a] = [numerator, denominator]).
To apply a filter to a 1-D audio waveform, Matlab provides function filtfilt , which takes
as arguments the result [b, a] from butter, the waveform, and a value denoting the
order (number of coefficients) of the filter.
A filter's frequency response can be plotted using function freqz . Magnitude values at zero dB
are unaffected by the filter. Magnitude values below 0 dB are suppressed.

10.3.2.1 Low-pass filter



We design a 10th order low-pass filter to supress frequencies higher than 200Hz.


fNorm = 200 / (f/2);
[b,a] = butter(10, fNorm, 'low');
funkyLow = filtfilt(b, a, funky);
Add caption
The frequency response for this filter:
freqz(b,a,128,f);


wavplay(funkyLow,f);
Playing the new audio waveform clearly reveals that low (bass) frequencies are preserved, while all higher frequencies have been suppressed.

10.3.2.2 High-pass filter



We design a 10th order high-pass filter to supress frequencies below 5kHz.

fNorm = 5000 / (f/2);
[b, a] = butter(10, fNorm, 'high');
funkyHigh = filtfilt(b, a, funky);
















Figure 10.31

 The frequency response for this filter:
freqz(b,a,128,f);


wavplay(funkyHigh,f);
Playing the new audio waveform reveals only high-pitched tones.

 Stop-band filter


Figure 10.32

fNorm = [500/(f/2), 2500/(f/2)];
[b, a] = butter(10, fNorm, 'stop');
funkyBand = filtfilt(b, a, funky);
The frequency response for this filter:
freqz(b,a,128,f);



wavplay(funkyBand,f);







No comments:

$0 to $1 Million - How Did He Do It?

Hello Newbie,

If you sell a product or service, this is for you. If you don't, please feel free to let other people who you know that do sell products or services online. It could make the difference between their doing ok and their doing excellent.

They will owe you one for having shared this cutting edge secret with them.

If you are still with me, I will assume that you sell a product or service online.

Let me ask you this:

"If your website was featured on 1,000's of review sites around the internet and each review site owner was marketing their website using pay-per-click, articles, forums, and coregistration, how much would that affect your profits?"

10%, 100%, 500%, 1000? Well, some merchants are making millions of dollars as a result of just a handful of affiliates using endorsements or positive reviews of their website.

As a special bonus, you make money when everyone who you refer signs up to get hosting AND when they get upgraded training materials and support. Of course if people want a completely free site, we have that too, so you can truly offer your email list a FREE Cash Pulling Website announcement.

Learn more and get started when you continue below:

Feature Your Company On Thousands Of Review Websites

Everything is completely free for you and you can have your review site template built and your site members or affiliates using it as quickly as you can let them know about it.

It's as simple as 1-2-3:

1) You customize a review site with your affiliate link for your product or service that every affiliate will use to make money.

2) You let your affiliates, customers, site visitors know about how they can make money with their own review site (featuring your products).

3) You make money for each person who upgrades their account or gets advanced training materials.

Get started below.

Feature Your Company On Thousands Of Review Websites

To your success!

Awan Chaulagain

Free Completely free but you make money right away click below

How To Explode Your Affiliate Earnings

SUMMARY:

Any Cash needed? NO

Any Risk: NO

Appropriate for: Newbies, Intermediate, And Advanced

=========================================

Dear Affiliate Marketer ,

As an affiliate marketer, you are looking for the best way you can create massive ongoing income for you that takes as little time as possible.

Ideally, you can invest a couple of minutes and get paid on it for years.

Learn more by continuing here:

Make Money Giving Away Free Money Making Websites

All you need to do is log in to your account, and let people know about how they can get their own Cash-Pulling Websites. They are valued at $2,079, but they can get them for nothing for a very limited time.

You make cash when:

1) A person gets a website and upgrades to have their own domain 2) A person upgrades their training materials 3) A webmaster refers their affiliates/customers/visitors to get their own co-branded review sites. You make a 2nd tier commission based on the lifetime commissions of the webmaster you referred.

Sign up right now and get started making some cash!

Make Money Giving Away Free Money Making Websites

To your success!

Awan Chaulagain

One clicks can give you more than $

To find your love, friend, life partner.... log on to....

Google