0
$\begingroup$

First off: I'm really new in the signal processing department and MatLab as well, so please bear with me here.

What I want to achieve is to split my audio signal into smaller 25ms frames, where the frames overlap with 50%, apply a window function, thus the overlapping (probably Hamming or Hann), and then add it together again (write out a new sound file), so that I basically get the original signal back. Someone mentioned overlap-add, but I'm not quite sure if convolution is correct here, as mentioned, I'm new to all this.

So I have a sound file that I read like this:

function output = readSoundFile(filename, channels)

if isscalar(channels)
    chN=channels;
    channels=ones(1,chN);
else
    chN=length(channels);
end

fid=fopen(filename,'r','n');
[output, elementCount] = fread(fid,[chN,inf], '*int16');
fclose(fid);

for i=chN:-1:1
    if channels(i) == 0
        output(i,:)=[];
    end
end

end

In another MatLab file, I use the readSoundFile function:

fileUrl = 'whatever/file.format';
sound = readSoundFile(file);
soundsc(double(sound), 16000); % sound is sampled with 16kHz. Don't know, if this information is needed

How do I split the resulting data into 25ms frames with an overlap of 50%, apply a window function, and write out a new file?

Should it help, I can convert the file into a wav file, if wavread/audioread would be any easier.

$\endgroup$
  • $\begingroup$ Difficult to answer without a specific idea of what your goal is. If you want to do any frequency domain filtering, overlap-add is the way to go. If you want to do any other kind of frequency domain processing, things get a lot more complicated. Just recreating the file seems kind of pointless. $\endgroup$ – Hilmar Oct 8 '13 at 11:40
  • $\begingroup$ Yes, later on, I want to do frequency domain filtering on the frames, but for now I just need to know how to divide the received signal into 25ms frames. What I do with the frames later on, shouldn't matter now, right? $\endgroup$ – SignalRookie Oct 8 '13 at 12:30
  • $\begingroup$ Actually what you want to do with the frames matters a LOT. Choice of analysis window, synthesis window, window length, FFT size, step size, etc. are all heavily dependent on the application. The easiest application would probably be linear time invariant filtering for which overlap-add or overlap-save work well and are fairly simple and straight forward. $\endgroup$ – Hilmar Oct 8 '13 at 14:42
  • $\begingroup$ @Hilmar Alright. Then I'll probably start with that. Could you point me to some good documentary or give me a simple example? $\endgroup$ – SignalRookie Oct 8 '13 at 16:29
1
$\begingroup$

Von Hann (but not Hamming) windows with a 50% overlap sum to unity (except possibly at the very start or end of a file). If you do any processing, rather than just analysis, in the frequency domain, you may find overlap add or overlap save with a rectangular window to be more appropriate.

$\endgroup$
  • $\begingroup$ Could you give any code examples? $\endgroup$ – SignalRookie Oct 9 '13 at 13:26
0
$\begingroup$

Segmenting signal into overlaping frames is called "enframe" operation. A simple example is here:

http://www.mathworks.com/matlabcentral/fileexchange/22372-wavelet-subband-coding-for-speaker-recognition/content/sbc/enframe.m

You might then filter (convolve) your signal with any kernel using for example "conv" command. Then apply the inverse operation of enframe.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.