# Ghost

This page is meant to track ideas about low-delay, high-quality audio coding. The work has just started, so don't expect anything in the near future (or at all for that matter).

## Contents

## Signal types

There are many signal types that can be found:

- Sinusoids
- A few pure (or nearly pure) tones

- Harmonic
- Periodic waveforms (e.g. voice)
- Many (sometimes closely spaced) harmonics

- Shapred noise
- Signals that are (or are indistinguishable) from filtered (coloured) white noise

- Transients
- Whatever does't fit above I guess

## Signal analysis

### Sinusoidal

Good when most of the energy is contained in a few sinusoids. May be problematic for very harmonic signals, e.g. a male voice may have close to a hundred harmonics in the full audio band.

### Pitch

Good for harmonic signals. Hard to estimate and code when extra sinusoids and noise are present. At 48 kHz, no need for fractional pitch or anything like that, but sub-band pitch analysis or multi-tap gain is a good idea. Also, there needs to be a way to remove the effect of sinusoids and noise. Even then removing the "noise" also means removing all excitation to the pitch predictor, so that's a problem.

### MDCT

Very general. Can code anything, but not very good at anything. High delay (2x frame size). Could put several "MDCT frames" in each codec frame to make latency smaller.

### Wavelets

Just a fancy name for sub-bands with non-uniform width. Probably similar to having an MDCT with few sub-bands, except that that the sub-bands could follow (roughly) the critical bands.

### LPC + stochastic cb

Like CELP with no pitch. Could be used to code the noisy part of the signal with low bit-rate. Would need to figure out how to preserve the energy of the noise when going with 1/2 bit per sample and less.

## Codec Structure Ideas

### Sinusoidal + wavelet

- Preemphasis
- Extract as many sinusoids as possible
- Wavelet transform
- Code wavelet coefs using VQ

### Sinusoidal, pitch and noise

- Preemphasis
- Joint pitch + sinusoidal estimation
- LPC analysis
- CELP-like coding of the residual (mainly noise)

## Estimation Ideas

### Sinusoid Estimation

Very hard to do properly, especially with reasonable complexity and low delay. Some ideas:

#### Least-square type matching

Step one: estimate sinusoid frequencies.

Tried so far:

- MUSIC fails on non-trivial signals and very complex, although there's an AES paper that recommends first whitening the noise part of the signal before applying the algo. Haven't tried that so far.
- ESPRIT fails on non-trivial signals and very complex (see above for possible solution)
- LPC would probably work, but requires an insane order -> impractical, plus it tends to be numerically unstable anyway.
- FFT poor resolution, but that's all we have left so far. There's an AES paper that describes a sort of time-domain phase unwrapping that could help.

Step two: what to match

Step three: solving

Looks like it's possible to solve an NxM least square problem in O(N*M) time using an iterative algorithm as long as the system matrix is near-orthogonal. If we want to solve **Ax**=**b** and **A**^h***A** ~= I, then we start with **x**(0)=**A**^h***b** and then:

**x**(N+1) =**x**(N) +**A**^h*(**b**-**A*****x**(N))