I'm trying to make an incoming signal of a desired length in order to perform speech recognition calculations on it in a similar manner to every incoming signal. I originally tried interpolating and decimating to get to desired length, but that would result in a vector with every element being 0, probably because it had to run through the decimation process so many times.
And it seemed like this would accomplish what I wanted in the first place, stretching or shrinking the signal array whilst keeping the form of the signal.
I understand the following inputs:
speech_out = speech(1:2:length(speech),:); will delete every other row starting with the second element.
speech_out = speech(1:1/2:length(speech),:); will duplicate every other row starting with the second element.
speech_out = speech(1:1/1.25:length(speech),:); will duplicate every fourth row starting after the newly duplicated element.
This is essentially multiplying the length of the array by the inverse of the 2nd input (e.g. 2, 1/2, 1/1.25, etc...) and results in the correctly sized signal and seems to keep the form of the signal.
desired_length = 89728;
speech_out = speech(1:(1/(desired_length/length(speech))):length(speech),:); %iso_sig
BEFORE CODE: (After taking out the silences from the signal)
AFTER CODE: (Now of correct size, while seemingly retaining the important information)
What I don't understand is when it starts to come down to weirder fractions like 1/1.01964, where it swings between duplicating every 51st, 52nd, or 53rd row (might be a larger range, but this is just what I noticed after scrolling through some of the array). I would like to know how it determines which row to duplicate, because I'm eventually going to want to move this code to C to program a DSP.
*Bonus: I also think that this may be screwing up my end result 256pt-FFT, because every window of FFT shows the same form for whatever signal I put through it.
This is showing the dominant frequencies to consistently be at Fs/2 and Fs, where my Fs = 44kHz. I was thinking that the above function I was asking about is somehow affecting my FFT, but I don't see why it would be if my signal is still keeping its form.