Alfred
Alfred

Reputation: 1663

Finding Sampling Frequency of .wav file in MATLAB

I am reading a .wav file in Matlab. Then I play the read file with a specified sampling frequency 44100Hz. But when I try to play a file sampled at low sampling frequency, it gets played as if I am playing it in fast forward mod and thats because the sampling frequency at which I am playing is higher than at which the file is sampled.

So my question is How can I find the sampling frequency of a file I read using wavread() in Matlab. I tried to convert the read signal in frequency spectrum and then pass the magnitude of the fft() signal but it didn't work.

Any suggestions?

Upvotes: 1

Views: 8788

Answers (2)

JohnColtraneisJC
JohnColtraneisJC

Reputation: 198

First off you can find the sample frequency by using this function:

def read_samplepoints(file_name):

    sampFreq, snd1 = wavfile.read(file_name)

    samp_points = len(snd1)

    data_type = snd1.dtype

    return samp_points, data_type, sampFreq

Execute in terminal by using 'folder_name'.'class_name'.read_samplepoints(file_name). The last number in the returned sequence will be the sample Frequency.

To enhance the bass of your song you need to use a low band filter to only capture your lower frequencies and keep your higher ones. However, this will chance all the frequencies in your file, which you may not want. Another way is to take your file into audacity (or a similar program) and go to the effects section and adjust the bass and treble levels (similar to the Equalizer on iTunes). Those are two options and there may be a few more but try those to begin with and see where they lead you.

Upvotes: 0

petrichor
petrichor

Reputation: 6579

Observe that wavread can return sampling frequency Fs as follows:

[y, Fs] = wavread(filename)

Upvotes: 4

Related Questions