I can sometimes describe a way of using certain tools – such as in this case, one of the Discrete Cosine Transforms – which is correct in principle, but which has an underlying flaw, that needs to be corrected, from my first approximation of how it can be applied.

One of the things which I had said was possible was, to take a series of frequency-domain ‘equalizer settings’, which be at one per unit of frequency, not, at so many per octave, compute whichever DCT was relevant, such that the result had the lowest frequency as its first element, and then to apply that result as a convolution, in order finally to apply the computed equalizer to a signal.

One of the facts which I’m only realizing recently is, that if the DCT is computed in a one-sided way, the results are ‘completely non-ideal’, because it gives no control over what the phase-shifts will be, at any frequency! Similarly, such a one-sided convolution can also not be applied as the sinc function, because the amount of sine-wave output, in response to a cosine-wave input, will approach infinity, when the frequency is actually at the cutoff frequency.

What I have found instead is, that if such a cosine transform is mirrored around a centre-point, the amount of sine response, to an input cosine-wave, will cancel out and become zero, thus giving phase-shifts of zero.

But a result which some people might like is, to be able to apply controlled phase-shifts, differently for each frequency, such that those people specify a cosine as well as a sine component, for an assumed input cosine-wave.

The way to accomplish that is, to add-in the corresponding (normalized) sine-transform, of the series of phase-shifted response values, and to observe that the sine-transform will actually be zero at the centre-point. Then, the thing to do is, to apply the results negatively on the other side of the centre-point, which were to be applied positively on one side.

I have carried out a certain experiment with the Computer Algebra System named “wxMaxima”, in order first to observe what happens if a set of equal, discrete frequency-coefficients belonging to a series is summed. And then, I plotted the result of the *definite* integral, of the sine function, over a short interval. Just as with the sinc function, The integral of the cosine function was (sin(x) – sin(0)) / x, the definite integral of the sine function will be (1 – cos(x)) / x, and, Because the derivative of cos(x) is zero at (x = 0), the limit equation based on the divide by zero, will actually approach zero, and be well-behaved.

(Update 1/31/2021, 13h35: )

There is an underlying truth about Integral Equations in general, which people who studied Calculus 2 generally know, but, I have no right just to assume that any reader of my blog did so. There exist certain standard Integrals, which behave in the reverse way of how the standard Derivatives behave, just because ‘Integrals’ are ‘Antiderivatives’…

When one solves the Derivatives of certain trig functions repeatedly, one obtains the sequence:

sin(x) -> cos(x) -> -sin(x) -> -cos(x) -> sin(x)

Solving the Indefinite Integrals of the same trig functions yields the result:

sin(x) -> -cos(x) -> -sin(x) -> cos(x) -> sin(x)

Hence, the Indefinite Integral of sin(x) is in fact -cos(x), and:

( -(-cos(0)) = +1 )

(End of Update, 1/31/2021, 13h35.)

(Updated 2/04/2021, 17h10…)

(As of 1/30/2021: )

I achieved the desired result, that both plots are similar, and find that doing so supports my conjecture, even though it does not constitute Mathematical proof that will stand up to any rigour… The reader will need to enable JavaScript from my blog, as well as from ‘mathjax.org’, in order to be able to view the following work-sheet:

Notes:

*If the sample-rate for the continuous functions plotted above was changed to 16kHz, consistently with over-sampled telephone frequencies, then they should be effective down to 500Hz*. And, over-sampling is required for 90⁰ phase-shifting at the initial Nyquist Frequencies.

If this concept was indeed used to implement some sort of equalizer, and not just, ‘a universal phase-shifter’, then there is an additional caveat. The *continuous* functions above are plotted such, that their nominal gain will be 2. With discrete transforms, a question will inevitably come up, as to whether the Type 1 or the Type 2 transforms should be used. The Type 2 transforms will apply a half-sample shift, that corresponds to an offset of a quarter-wave, to the input, even though in this case, the input was in the frequency domain and the output in the time-domain (resulting in an arbitrary convolution as already stated).

One property that the Type 1 DCT has is, non-zero values at both endpoints, which also assures that any signal can be reconstructed. The Type 2 DCT will have as property, that it starts with a non-zero value at the origin of the output, but that because all the indices have odd products of quarter-wave frequencies, they will naturally tend to have zero, as the value of the last (output) element.

This would be ideal for equalizers and filters, because it would mean that no windowing function needs to be applied, to avoid spikes in the output, due to spikes in the input, entering the window.

Well, with ‘Discrete Sine Transforms’, this set of properties is reversed. The Type 2 will have as property, a value of zero at the origin, and non-zero values at the endpoints. Yet, presumably, the coefficients of both cosine and sine transforms, applied simultaneously, are supposed to define the same set of frequencies. What this means is that, If the Type 2 are to be applied, then some sort of windowing function should also be applied *to the sine* transform.

(Update 2/04/2021, 17h10: )

After pondering this question more closely, I find that the type of windowing function best-suited would be, ‘a half-sine wave’ that begins and ends with multipliers of zero, at the beginning and end of the entire interval of the convolution. This should preserve the way equalizers and filters are supposed to behave, best.

(End of Update, 2/04/2021, 17h10.)

An idea which was once voiced was that, because a system of representation already exists, in which the real part of a complex number states a cosine-wave, and the imaginary part states a sine-wave, it should be possible just to apply the Discrete Fourier Transform to a set of ‘phasors’, and end up with a usable result. But one fact which can be overlooked in this way of thinking is that, outside this system of representation, the instantaneous voltage or current through a wire can only be a real number, at least as far as circuit theory goes.

What will happen though is that, wherever the phasors have *positive* imaginary parts, the corresponding *real* parts of the Discrete Fourier Transform will be phase-*advanced* 90⁰. Therefore, if one just ignores the imaginary parts of the DFT, one should also obtain the results stated above. Further, if one additionally only states ‘~~phasors~~‘ with imaginary parts equal to zero, then one is back to computing a DCT.

(Update 1/31/2021, 23h25: )

One question which a reader could have would be concerning the way I proposed to normalize the (custom) Discrete Transform, as this snip repeats:

```
for k: 0 thru 159 do
for n: 0 thru 67 do block (
conv[160 + k]: conv[160 + k] + (sin((n*k*%pi)/160) / 160),
conv[160 - k]: conv[160 - k] - (sin((n*k*%pi)/160) / 160)
);
```

I clearly divided the individual products by 160, even though the array has 320 elements. The way I justified that was, to observe that when two (synchronous) sine-waves are multiplied, or more correctly, if a sine-wave is squared, the product will average as *half* the maximum amplitude (effectively, with a frequency twice that of the non-multiplied sine-waves). Thus, a single frequency-coefficient will result in a sine-wave within the computed convolution, the peak amplitude of which is equal to the value of the coefficient. But then, when this wavelet is multiplied by a stream, because the convolution is being applied as an equalizer, half that amplitude will naturally result and oscillate, at the desired frequency.

What this would lead me to do as a first approximation is, to double the amplitudes generated by the transform, as part of its normalization. However, since the wavelet has two halves, each of which is the same transform, no doubling should be necessary. Given 160 coefficients, each product should indeed be divided by 160, that’s all.

It would be no different for a centre output coefficient, which would only occur once, but which would be the *cosine* zero product with all the frequency coefficients. In that case, *it* would already contain the average of the frequency coefficients, with no concept of getting halved, when applied as part of the wavelet.

Enjoy,

Dirk