# Aliasing in MDCT

Started by January 15, 2009
```casper.ptrsn@gmail.com wrote:
(snip on symmetry and transforms)

> So what you're saying with the symmetry condition is that if I input X
> samples, the symmetry condition applies only to the X/2 samples, and
> thereby the X/2 + 1 ... X samples can be either symmetric or
> asymmetric or zero or... whatever?

If you are used to the symmetry of the DFT (exponential
transform) then the symmetry of the DST and DCT can be
confusing.  In all cases, N input points should result
in N output points.

For the exponential transform, the basis functions
have frequencies that are integer multiples
of the fundamental, where the fundamental
has one cycle over the length of the transform.

For DST and DCT the fundamental has one half cycle
over the length of the transform.  The DST with
boundary conditions of zero at the ends does not
have sample points at the ends.  Some forms of
DCT also don't have sample points at the ends.

> If that's correct, giving the alternating even and odd boundary
> conditions used in DCT Type-IV,  then I should be able to see:
> a) The other half of the input exactly mirrored / exactly symmetric to
> the first half ?
> and,

I am not sure what you mean by alternating even/odd boundary
conditions.  For DCT the derivative goes to zero at the
boundary.  (Which is not at a sample point for Type-IV.)

Consider the modes of an closed end tube or open end
transmission line.  They either reflect with inversion
(DST) or without inversion (DCT).

> b) The other half of the input exactly mirrored BUT with its sign
> changed (i.e. if X is my inputvector then X(1) could be 4, and X/2 + 1
> would be -4) ?

> I hope that made more sense.

-- glen
```
```On 2009-01-15 17:49:53 -0400, casper.ptrsn@gmail.com said:

> On 15 Jan., 22:10, Gordon Sande <g.sa...@worldnet.att.net> wrote:
>> M for Modified can mean many diferent things so has little information.
>> There are at least four common DCTs!
>>
>> The DCT will be determined by that portion of its input that
>> satisifies the symmetry condition. You can add as much non-symmetric
>> input with a zero symmetric portion as you like and it will not change
>> the output, assumming that your Modified is something rasonable. That
>> is a basic property of symmetry conditions.
>>
>> Perhaps what you are calling aliasing is really rejection of the
>> non-symmetric portion.
>
> So what you're saying with the symmetry condition is that if I input X
> samples, the symmetry condition applies only to the X/2 samples, and
> thereby the X/2 + 1 ... X samples can be either symmetric or
> asymmetric or zero or... whatever?

If there are 2M input values and there is symmetry then you can only specify
M independent values. Which ones depends on the details of the symmetry.
For that you will have to THINK about what the symmetry is. Perhaps
whatever source you are using will have an explanation of what form
the symmetry you are using takes.

You seem to think that symmetry means mirror symmetry about some central
point. That is one kind but there are others. Without further information
one can not tell what the form of your symmetry is. Symmetry is a property
of the whole input. Some symmetries may require particular pairs of inputs
to be equal, neagtives or conjugates. Which pairs and what relationship
is something that someone else can not guess until more information is
given.

Since you have the documentation for what your MDCT is you are the one who
has the information.

> If that's correct, giving the alternating even and odd boundary
> conditions used in DCT Type-IV,  then I should be able to see:
> a) The other half of the input exactly mirrored / exactly symmetric to
> the first half ?
> and,
> b) The other half of the input exactly mirrored BUT with its sign
> changed (i.e. if X is my inputvector then X(1) could be 4, and X/2 + 1
> would be -4) ?
>
> I hope that made more sense.

```
```Gordon Sande wrote:
> On 2009-01-15 16:25:46 -0400, casper.ptrsn@gmail.com said:
>
>> The MDCT is the Modified Discrete Cosine Transform. And yes as you say
>> the (M)DCT indeed has an symmetric assumption about the signal or
>> block of a signal. So if I'm reading what you're saying correctly, the
>> IMDCT will return 2M samples that are symmetric even though the
>> original samples that was transformed with MDCT are not, and that this
>> is the cause of the aliasing?
>
> M for Modified can mean many diferent things so has little information.
> There are at least four common DCTs!

This one is based on a Type IV.  But different.
http://en.wikipedia.org/wiki/Modified_discrete_cosine_transform
```
```casper.ptrsn@gmail.com wrote:
> That actually makes sense to me. At least more than what I had. Just
> two more things: When you say phase numbers, and frequency numbers,
> what exactly do you mean?

Sorry, "frequency numbers" should have been "magnitude numbers".

In a regular DFT, from N real points, you get N complex "frequency bins"
with a real and "imaginary" part, or you can look at it as magnitude and
phase parts.

In any DCT (or sine version), there will only be the real numbers for
output, so only a sort of magnitude info (not quite that, though), and
no phase info.
```
```Thank you all for your responses. I will re-read them as well as
getting my hands on some more books.
Once again, thanks you.
```
```>casper.ptrsn@gmail.com wrote:
>> That actually makes sense to me. At least more than what I had. Just
>> two more things: When you say phase numbers, and frequency numbers,
>> what exactly do you mean?
>
>Sorry, "frequency numbers" should have been "magnitude numbers".
>
>In a regular DFT, from N real points, you get N complex "frequency bins"

>with a real and "imaginary" part, or you can look at it as magnitude and

>phase parts.
>
>In any DCT (or sine version), there will only be the real numbers for
>output, so only a sort of magnitude info (not quite that, though), and
>no phase info.
>

From what I understand, the MDCT is a DCT type IV (wikipedia) implemented
using overlap-add with a 50% overlap. Thus phase information is still
preserved.  Each new block is 90 degrees out of phase with the previous
block, again because of 50% overlap.

```
```>Why exactly does MDCT introduce time-domain aliasing? From the 2M
>samples, the MDCT transforms to M samples, before the IMDCT transform
>back to 2M samples. From my understanding going from the frequency
>domain to the time domain using IMDCT, the original 2M samples are now
>only represented by M samples.
>But where exactly does the time-domain aliasing occur in the
>reconstructed signal, and why?
>

Time Domain Aliasing Cancellation (TDAC) in  MDCT/IMDCT works as follows:

time block index (each M/2 points) :
...j-4  j-3  j-2  j-1  j+0  j+1  j+2  j+3   ...
original time signal:    ......    B+C  B-C  D+E  D-E     ......

after MDCT/IMDCT:
frame i-1:     A    -A   B    B
frame i+0:               C    -C   D    D
frame i+1:                         E    -E   F    F
B+C  B-C  D+E  D-E

The points are,
(0) every signal can be split into even and odd symmtric parts, i.e. for
time block (j-2 j-1), signal (B+C B-C) = (B B) + (C -C);

(1) for time block (j-2 j-1 j+0 j+1), MDCT effectively picks odd-symmetric
part of (j-2 j-1), that is (C -C), and even-symmetric part of (j+0 j+1),
that is (D D), then transforms (C D) using DCT-IV into M spectral lines;

(2) IMDCT simply transforms back to (C D) using inverse DCT-IV from the M
spectral lines, then expands them to (C  -C   D   D);

(3) when concatenated, even-symmetric part of (j-2 j-1) from IMDCT of the
last frame, that is (B B), and odd-symmetric from IMDCT of the current
frame, that is (C -C), add up to the original signal (B+C B-C); on time
block (j+0 j+1), this works essentially the same to recover (D+E D-E).

There is a good explanation of MDCT in chapter 5 of Introduction to Audio
Coding and Standards by M. Bosi and R. Goldberg, available from Google
Book.

```