So, I've been scouring the forum for a while now and I'm having trouble finding successful implementations of the invfreqz function. But moreover, I'm not entirely sure this is the easiest way to even obtain the results I'm looking for, so I suppose I should start from the beginning...
I'm trying to implement a function that will take a source signal, extract its spectral weighting (which I'm doing via spectrogram) and then create a filter with an identical frequency response to the source file. From there, it will be applied to a noise signal to generate a spectra approximation of the original source signal. After reading through the documentation, invfreqz seemed to be my magical cure, but I can't get it to work properly!!! I either end up with a very strange time-domain response or end up getting a frequency response match that is not even close to that of the spectral data I feed the function. Since then, I've resorted to an adaptive filter setup that is fairly inefficient and doesn't match my source particularly well, either...
Anyways, any help that you fine ladies and gents could offer would be much appreciated!
Thanks,
Brett
Hi Brett, just a couple questions to clarify. You are inputting the complex-valued frequency response into invfreqz() correct? And you say that you are using spectrogram, are obtaining an impulse response for each column of your spectrogram output, in other words, a filter for each segment in the STFT?
Wayne
Wayne-
Thanks for the response! I am indeed inputing the complex frequency response (in rad/sample) into invfreqz, as obtained by by spectrogram. As for the filtering, I was trying to generate a single filter, not one for each bin; could that be my problem?
Thanks!
Yes, if you have a nonstationary signal that would require some kind of analysis like the STFT, I don't see how you can generate one filter for that process. invfreqz() is returning a filter with a rational Z-transform indicative of a linear time-invariant system.
Wayne
OK, that makes total sense. I was, in my haste, neglecting spectrogram's default 8 time segments. Now I've re-worked my code with a simple fft for a single block of time, generating a filter for that time period. And eureka, it seems to work quite nicely!
Looking at the frequency response of the filter created, it's bang on! I'm still having an issue, though. I apply the filter with the coefficients from invfreqz (which I viewed the output of using freqz, with the above stated success) to a vector of white noise. I expect to see the same spectral response out as the filter, with the length of the input vector size. What I get, instead, is a string of zeros followed by a sharp cutoff about a third of the way through the vector. I can't even describe what I'm seeing, really; rather than filtering the signal (in the frequency domain) it just seems to have multiplied by zero and truncated it.
I'm starting to wonder of I'm barking up the wrong tree with invfreqz; all I'm trying to do is impose the frequency response of an input signal (an impulse response, in fact) onto a noise signal with a flat spectrum. And here I was thinking this was going to be easy...
What order filter did you specify in invfreqz(). Can you provide your numerator and denominator coefficients (your B and A vectors)? When you say that you applied the filter, how exactly did you do that? Can you show some Matlab code?
Wayne
HTH,
Rajiv
"Brett " <brett....@mcgill.ca> wrote in message
news:hkqhgv$f5a$1...@fred.mathworks.com...
Ha, actually, after hours of looking for subtle things, changing coefficients, etc., it ended up being a missed operation in my output scaling... NOW we've got the whole thing working.
Thank you so much for you help! Finally I've got a working prototype for tweaking. Couldn't have done it without you!
Thanks,
Brett
Rajiv-
Thanks for the tips. I haven't touched the System ID Toolbox as of yet (I just got my full
liscence a few weeks ago). I'll check out the modeling tools, though, as they might be a
good alternative method for my processing, as we're looking at any and all options at this
point. The big problem has been trying work with frequency filtering without getting too
many temporal artifacts, as they become quite apparent in high-resolution audio
playback...
Thanks for the tips. I'll check them out and see if they work for my application!
Thanks,
Brett