Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matlab audio formating

Status
Not open for further replies.

megfourfun

Electrical
Sep 9, 2008
5
Hi all,

Im running vista and recording .wav files with the recording software offered by windows. I then import this data in matlab to process it.

When I plot the data "plot()" it returns the normal looking audio file plot (ill try to include an image). The problem is the file y axis max is from -.4 to .4 but the data exceeds these bounds. So, is there a way to fix this so that it includes all data (other than taking more samples at lower levels)?
Also there is a lot of unwanted data (no audio present). I need to remove this...edit the data so that it only includes the portion where actual audio recording is present.

Thanks in advance.

James
 
Replies continue below

Recommended for you

Looks like you've clipped the signal at some point in the recording process. That is an unrecoverable error.

Wen you've fixed that, decide on a level and a time that represents 'silence' and chop those bits out.

Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Thanks. I figured it was due to the vista recorder...ill try some others.
as far as "chopping those bits out" how do you edit the matrix within matlab?
 
Copy the noisy bits into a new matrix.

?

Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
ok...like new_matrix = old(old>.01)
or something...
 
Not really. Why not use music editing software like goldwave?




Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Agree, you don't need Matlab for the agricultural stuff.

- Steve
 
But I do. Im taking inputs from users and need to clean up the recording for processsing in order to determine cepstral coefficients to provide input to a neural network...now, I could go through the samples one by one (hundreds of samples) and cut them up to look nice...but yea...a program to do it all for me would be nice =.=
 
Fair enough.

Well, i'd create an nx2 matrix called goodbits with start and end of the good bits in each sample


k=1;
for i=1:n
for j=goodbits(i,1):goodbits(i,2)
noisy_wav(k)=original_wav(j);
k=k+1;
end
end

Steve will now present a one liner, probably using sparse.

Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Locating and removing the silent bits requires a thresholding method, something like an RMS filter is common, these are on the FEX if not in Matlab already. Then you can use logical indexing for your chopping.

% Untested, assumes an rms() function.
idx=rms(data)>threshold;
new_data=data(idx);

Which could of course by combined into a single line if "idx" has no further uses.

Another envelope method I like is based on a hilbert transform:

idx=abs(hilbert(data))>threshold;

Just to comment on Greg's code...

This line:
>> noisy_wav(k)=original_wav(j);

will cause the array noisy_wav() to grow each time a sample is copied across. The loop slows down as the array grows. It's almost always better to calculate the final array size and preallocate it with zeros.

No sparse() solutions today, sorry :-(

- Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor