Reply by Rune Allnor November 28, 20062006-11-28
scoubi skrev:
> Hi Rune, > > Thanks a lot for looking into my problem. > > I'm gonna go over your two previous messages. > > >... The issue is that there are very strong relations between > > the real and imaginary parts of the spectrum in causal > > real-valued sequences. To get this right requires > > that you to solve a system of two complex-valued integral equations, > > which is not something one attempts unless one absolutely has to > > (and most likely, not even then). > > Do you mean that I should deal with this system of integral equations > since the decimation-like process I mentioned ? Does the term > ''integral'' mean that only the continuous-time issue is dealt with in > the reference you gave ? Are these equations anywhere written for the > discrete-time issue (DFT) ?
If you want to implement time-domain re-sampling in the form of frequency domain interpolation, you *have* to deal with the integral equations. That does NOT mean you *should* deal with them. In fact, those integral equations are very compelling reasons for solving your task by other means than spectrum interpolation. As for the integral equations, they are formulated in z domain. The z transform of a discrete-time sequence is continuous in z domain, and these equations represent z transforms of a certain representation of the discrete-time causal signal.
> > Let's see if I have understood: > > > > - You have some structure where you have done acoustic > > measurements > > - You have some computer model for the same structure, > > that works in frequency domain but has certain limitations > > - You want to compare the measured and modeled data > > - Your efforts are motivated by the need to get the model > > data with the correct sampling frequency > > You've all well understood... > > > - Run the computer model with parameters that are acceptable > > for the model code, and get whatever sampling frequency > > pop out > > - Interpolate the modeled data in time domain (splines?) > > and re-sample to 44.1 kHz in time domain. > > ... but, actually, one of the parameters I have to set is precisely the > frequency step. The value I opt for will notably have an effect on the > resolution of the computed frequency responses (and e.g. its peaks).
I know, but my point is that it is better for you to accept whatever pops out of that model, provided the data are good, and treat the resampling as a separate issue. Frequency-domain models are difficult enough as it is, even whithout trying to force them into a particular time domain representation. Handle the modeling and the resampling as two separate stages: First make data that you are happy with, that have arbitrary sampling parameters; then resample to 44.1 kHz.
> The subjective evaluation of the recorded sounds I modify according to > the entire process I described in my first post precisely aims at > checking whether the adopted value of frequency step is ''acceptable'' > from a perceptual point of view. That's why I was thinking about acting > in the frequency domain.
Again, these are separate issues. The model may be specified in frequency domain, but that doesn't mean you have to do all your computations in frequency domain.
> In addition, the time-domain resampling may > involve additional operations such as low-pass filtering in the > frequency domain (doesn't it?), which is not necessarily desirable.
Time domain *decimation* requires LP filtering. That's a non-issue here, since you want a denser spectrum. Implicitly, this means that you want a data sequence with the same duration but denser samples in time domain. This is not decimation, it is up-sampling. Model your data and then do an up-sampling. As long as the bandwidth of your modeled data is lower than 22 kHz, your only consideration is to model good data of the correct duration. Once you have the time series, you use a time domain method to resample. Rune
Reply by scoubi November 28, 20062006-11-28
Hi Rune,

Thanks a lot for looking into my problem.

I'm gonna go over your two previous messages.

>... The issue is that there are very strong relations between > the real and imaginary parts of the spectrum in causal > real-valued sequences. To get this right requires > that you to solve a system of two complex-valued integral equations, > which is not something one attempts unless one absolutely has to > (and most likely, not even then).
Do you mean that I should deal with this system of integral equations since the decimation-like process I mentioned ? Does the term ''integral'' mean that only the continuous-time issue is dealt with in the reference you gave ? Are these equations anywhere written for the discrete-time issue (DFT) ?
> Let's see if I have understood: > > - You have some structure where you have done acoustic > measurements > - You have some computer model for the same structure, > that works in frequency domain but has certain limitations > - You want to compare the measured and modeled data > - Your efforts are motivated by the need to get the model > data with the correct sampling frequency
You've all well understood...
> - Run the computer model with parameters that are acceptable > for the model code, and get whatever sampling frequency > pop out > - Interpolate the modeled data in time domain (splines?) > and re-sample to 44.1 kHz in time domain.
... but, actually, one of the parameters I have to set is precisely the frequency step. The value I opt for will notably have an effect on the resolution of the computed frequency responses (and e.g. its peaks). The subjective evaluation of the recorded sounds I modify according to the entire process I described in my first post precisely aims at checking whether the adopted value of frequency step is ''acceptable'' from a perceptual point of view. That's why I was thinking about acting in the frequency domain. In addition, the time-domain resampling may involve additional operations such as low-pass filtering in the frequency domain (doesn't it?), which is not necessarily desirable. Does this help to clarify the problem or rather make it more obscur ? Scoubi.
Reply by scoubi November 28, 20062006-11-28
Hi Jason,

Thanks for your help,

> What sort of data does your vibro-acoustic tool directly measure?.... >... or does it generate time-domain measurements which you then FFT to get to the > frequency domain?
Yes I've got the time-domain measurements, what I measured was the acoustic pressure (with a microphone), but...
> If you have the time-domain data and you would like > to get more detail in the frequency domain, it is as easy as > zero-padding the time signal before inputting it into the FFT; this > will give you an FFT evaluated at more points.
... actually, I'm not trying to get more detail in the frequency domain, I'm rather trying to ''reshape'' the FFT spectrum of my time-domain measurements.
>... If you only have frequency-domain values, then you can do the dual > of time-domain interpolation (upsample in frequency, inverse transform > to get the time-domain signal, then "chop" the signal in an analogous way to > lowpass-filtering the signal in the time-interpolation case) to get the > resolution you want.
At some point, I had looked for this possibility of proceeding, but found nothing quite explicit. Would you have a reference explicitly describing what you called the "choping" process and defining the dual of low-pass filtering for frequency interpolation (I don't manage to visualize what it could be) ?
> Also, are you doing this in real time? If real-time operation is not a > requirement, I would consider the possibility of just storing the > samples for later computation; if you're trying to impose real-time > operation when it's not really required, you can end up making > tradeoffs like what you're proposing when you really don't need to.
I'm not really sure about in what the real-time operation consists, but I would say no. Thanks in advance, Scoubi.
Reply by Rune Allnor November 27, 20062006-11-27
scoubi skrev:
> > What exactly are you trying to accomplish? > > Actually, I'm trying to make a parallel between the numerical and > experimental parts of my work that deals with the sound quality of > structures. > In short, I'm going in a future stage to calculate with a > vibro-acoustic tool (in the frequency domain) some sounds radiated by a > structure, from the knowledge of its vibratory velocities. But, owing > to computation limitations, I will not be able to calculate the > frequency responses (complex spectra of the noises) with a fine > frequency step (at best maybe 1 or 2 Hz), I will then have to linearly > interpolate the spectra to create additional "fictive" values and then > get a sufficient number of values (i.e. 176400) so that, when going > back to the time domain by IFFT, I can get a sound sample 4s in length > of quite good quality, i.e. involving a sampling rate compatible (i.e. > 44100 Hz) with the purpose of subjective evaluation I wanna run. > Thus, from the radiated sounds I have already recorded experimentally > (the same as the ones I will calculate), I'd like to collect some > useful information about the value of the maximum frequency step I > could later use in simulations without significantly modyfing the > perceptual trends I would get from an evaluation of the recorded > noises, modified following the procedure we are discussing (and thus > involving a first stage of "decimation" to simulate the future coarse > frequency step used under the vibro-acoustic tool). > > Sorry if I have dwelt too much, it may be a little boring or confuse ! > :-)) > But this is the why of the how :-)
Let's see if I have understood: - You have some structure where you have done acoustic measurements - You have some computer model for the same structure, that works in frequency domain but has certain limitations - You want to compare the measured and modeled data - Your efforts are motivated by the need to get the model data with the correct sampling frequency If the above is correct, this is what I would do: - Run the computer model with parameters that are acceptable for the model code, and get whatever sampling frequency pop out - Interpolate the modeled data in time domain (splines?) and re-sample to 44.1 kHz in time domain. Rune
Reply by Rune Allnor November 27, 20062006-11-27
scoubi skrev:
> Hi everyone ! > > I'm new in this group and quite intermediate in DSP applications. I'm > facing the following problem in the framework of my study. > > I've got some 4 seconds recorded sounds (44100Hz, 16bits) for which I'd > like to modify the FFT spectrum. Actually, I'd like to replace at a > constant rate (e.g. 3 values every four values, from the DC component) > some initial values with "new" values issued from the linear > interpolation between the remaining values, and get back the > corresponding modified sound, thus keeping the same sampling frequency, > i.e. 44100Hz.
This seems to be an interesting exercise, although a bit off "the beaten path". What do you hope to achieve by this?
> I've thought about the following steps for the process : > - first, applying FFT to get the original spectrum.
OK
> - then, retaining 1 value every 4 values from sample 0 to > sample N/2, amounting in a way to frequency decimation,
Yes...
> - Interpolating linearly the real and imaginary parts of the spectrum > to recover values at the decimated frequency bins.
This is the hard part, but leave it for now....
> - reconstituting the complete spectrum [0-Fe[ by flipping complex > numbers 1 to N/2 of the vector obtained at the previous step, taking > their conjugate and concatenating them with the above vector,
Some details to keep track of, but correct...
> - finally, recompute the time signal by processing an ifft on the > previous sequence and keeping the real part of the result.
Correct.
> I've tried this process but it seems it doesn't work : the obtained > time signal looks really distorted, probably owing to a phenomenon of > time aliasing.
No, the problems are not due to time aliasing. Not time aliasing alone, at least..
> I've read in the litterature about decimation / interpolation > especially in the time domain (and problems of frequency aliasing), but > I've found nothing about equivalent processes in the frequency domain.
Few, if any, such techniques are implemented in frequency domain.
> I'm really getting stuck on this problem; can anyone help me to detect > where my reasonning is erroneous and indicate me how to process in a > proper way to obtain the expected result ?
Well, it's hard to guide you to an expected result, for the simple reason that I don't know what results you expect. Indicating whiy you have problems is easier. The issue is that there are very strong relations between the real and imaginary parts of the spectrum in causal real-valued sequences. To get this right requires that you to solve a system of two complex-valued integral equations, which is not something one attempts unless one absolutely has to (and most likely, not even then). The theory is outlined in Oppenheim and Schafer's book from 1975. Rune
Reply by November 27, 20062006-11-27
> Could you help me further by providing me a small example in matlab > code, starting from the decimation of a complex spectrum, including the > convolution calculation and going until the correction of the time > signal obtained by ifft, in the case of the sinc interpolant ?
What sort of data does your vibro-acoustic tool directly measure? Does it generate frequency-domain values directly at its output, or does it generate time-domain measurements which you then FFT to get to the frequency domain? If you have the time-domain data and you would like to get more detail in the frequency domain, it is as easy as zero-padding the time signal before inputting it into the FFT; this will give you an FFT evaluated at more points. So, if you actually have access to the time-domain values, you can just zero-pad your sample to get more finely-grained FFT bins. If you only have frequency-domain values, then you can do the dual of time-domain interpolation (upsample in frequency, inverse transform to get the time-domain signal, then "chop" the signal in an analogous way to lowpass-filtering the signal in the time-interpolation case) to get the resolution you want. Also, are you doing this in real time? If real-time operation is not a requirement, I would consider the possibility of just storing the samples for later computation; if you're trying to impose real-time operation when it's not really required, you can end up making tradeoffs like what you're proposing when you really don't need to. Jason
Reply by scoubi November 21, 20062006-11-21
Hi Jason,

I've worked on what we told yesterday, but I don't still manage to get
any results for the moment; Actually, I'm getting stuck on the problem
of the interpolation.
I really have some difficulties in putting the theory into practice
(and certainly integrating all what the theory initially involves, a
task which may take several months).
Could you help me further by providing me a small example in matlab
code, starting from the decimation of a complex spectrum, including the
convolution calculation and going until the correction of the time
signal obtained by ifft, in the case of the sinc interpolant ?

Thank you very much in advance.

Scoubi

Reply by November 20, 20062006-11-20
> I don't manage to obtain the results of the interpolation I previously > observed, when now using the convolution of the "decimated" spectrum > (in the way you specified) with the triangular function, what should be > the parameters of the triangle function (width, delay, sequence > length...) so that it could work, e.g. for a decimation factor equal > to 4 ? Should I perform the convolution for the whole spectrum (i.e. > [0;Fe[) or the partial spectrum ([0; Fe/2], then reconstruction), on > the complex values or separately on real and imaginary parts ? > I don't manage to obtain the results of the interpolation I previously > observed, when now using the convolution of the "decimated" spectrum > (in the way you specified) with the triangular function, what should be > the parameters of the triangle function (width, delay, sequence > length...) so that it could work,
For this sort of interpolation, you want your triangle waveform to ramp from zero to one in 4 samples, so that when the triangle is at its maximum, the adjacent input samples (4 samples away at your increased sample rate) are zeroed out. So, the vector would look like: t = [0 0.25 0.5 0.75 1 0.75 0.5 0.25 0]; I haven't worked the math out fully, but you should be able to get the expected result by performing the convolution on the entire spectrum. It might be easier to do if you use fftshift() to put the frequencies in a more intuitive order beforehand (you will have to undo it before you ifft() though). If I get a chance, I'll try to work up this example in MATLAB. The zeros on the end are just for clarity and obviously can be omitted. As you pointed out, dividing the sinc^2 out at the end isn't really an option; you'll run into numerical stability issues when dividing by numbers close to zero. You might try a "smarter" interpolation method; since ideal interpolation uses sinc functions, you might use an approximation to sinc as your interpolant instead (sinc functions are non-causal and infinite length, so you can't do it exactly). Since you seem to have suggested that this isn't a real-time application, you could get away with non-causality and just truncate the sequence to a suitable length. Good luck. Jason
Reply by scoubi November 20, 20062006-11-20
> What exactly are you trying to accomplish?
Actually, I'm trying to make a parallel between the numerical and experimental parts of my work that deals with the sound quality of structures. In short, I'm going in a future stage to calculate with a vibro-acoustic tool (in the frequency domain) some sounds radiated by a structure, from the knowledge of its vibratory velocities. But, owing to computation limitations, I will not be able to calculate the frequency responses (complex spectra of the noises) with a fine frequency step (at best maybe 1 or 2 Hz), I will then have to linearly interpolate the spectra to create additional "fictive" values and then get a sufficient number of values (i.e. 176400) so that, when going back to the time domain by IFFT, I can get a sound sample 4s in length of quite good quality, i.e. involving a sampling rate compatible (i.e. 44100 Hz) with the purpose of subjective evaluation I wanna run. Thus, from the radiated sounds I have already recorded experimentally (the same as the ones I will calculate), I'd like to collect some useful information about the value of the maximum frequency step I could later use in simulations without significantly modyfing the perceptual trends I would get from an evaluation of the recorded noises, modified following the procedure we are discussing (and thus involving a first stage of "decimation" to simulate the future coarse frequency step used under the vibro-acoustic tool). Sorry if I have dwelt too much, it may be a little boring or confuse ! :-)) But this is the why of the how :-) Otherwise, I've started to implement what you mentioned in your post, I think you hold the good way, you exactly described what I had observed. Could you just advise me about some elements with which I do not feel very comfortable, so that I can converge more quickly to the solution. Notably:
>Convolving the resulting vector with a triangle function; this is > the actual interpolation. If you don't see how this works, draw it out > and you'll see.
I don't manage to obtain the results of the interpolation I previously observed, when now using the convolution of the "decimated" spectrum (in the way you specified) with the triangular function, what should be the parameters of the triangle function (width, delay, sequence length...) so that it could work, e.g. for a decimation factor equal to 4 ? Should I perform the convolution for the whole spectrum (i.e. [0;Fe[) or the partial spectrum ([0; Fe/2], then reconstruction), on the complex values or separately on real and imaginary parts ?
> Therefore, convolution of the frequency domain samples with the > triangle function yields a multiplication in the time domain between > your original signal and the inverse transform of the triangle > function, which happens to be a sinc^2. That's what gives you the > envelope that you see, which, as you stated previously, is related to > the decimation factor (the decimation factor affects the length of the > triangle function, which affects the mainlobe width of the sinc). >
To cancel afterwards the effects of multiplication in the time domain of the signal by the function sinc^2, would the appropriate correction consist in dividing the signal, that I've got by performing the IFFT on the transformed spectrum (e.g. interpolated using the convolution process), by this same function sinc^2 ? Nan values may occur for zeros values of the function, don't they ? Or must this correction be applied in another more appropriate way ? Once again thank you very much for your help and your patience, Scoubi.
Reply by November 20, 20062006-11-20
Now that I think about this some more I realize you're not doing
anything wrong. What you're doing (decimating in the frequency domain
followed by linear interpolation between the samples) is equivalent to
doing the following:

1. Setting 3 out of every 4 frequency samples to zero, but leaving them
in the vector (this differentiates this operation from decimation,
which would actually throw the samples away). This is actually
identical to a decimation step followed by an upsampling step (I'm
using upsampling to refer to the initial step in interpolation,
inserting extra zeros as needed). This performs the frequency domain
expansion/contraction operations that John talked about, so your
sampling rate could become an issue here.
2. Convolving the resulting vector with a triangle function; this is
the actual interpolation. If you don't see how this works, draw it out
and you'll see.

Therefore, convolution of the frequency domain samples with the
triangle function yields a multiplication in the time domain between
your original signal and the inverse transform of the triangle
function, which happens to be a sinc^2. That's what gives you the
envelope that you see, which, as you stated previously, is related to
the decimation factor (the decimation factor affects the length of the
triangle function, which affects the mainlobe width of the sinc).

What exactly are you trying to accomplish?

Jason