[vorbis] Ogg Vorbis crossfading

Paul Martin pm at nowster.zetnet.co.uk
Sun Nov 30 04:57:19 PST 2003



On Sat, Nov 29, 2003 at 04:25:32AM +1000, Ian Rutherford wrote:

> Does anyone know if cross-fading has been successfully implemented in
> Vorbis? I need to implement it in a project I'm working on and if it's
> already been done, a finger pointing in the right direction would be
> awesome.

You don't really do cross-fading with a codec stream, you do it with
the decoded audio...

One good crossfade formula (amplitude multiplier) is:

Aa(t) = (1+cos(t*pi))/2
Ab(t) = 1-Aa(t) = (1+cos((1-t)*pi))/2

where t goes from 0 to 1 through the fade, and pi is the ratio of the
circumference of a circle to its diameter.

Aa is the value to multiply the outgoing audio with, and Ab is the
value to multiply the incoming audio with.

Useful properties of this formula:

 * At all points, Aa(t)+Ab(t) = 1

 * The two fade curves are mirror images of one another.

 * The curves asymptotically approach and depart from 0 and 1. Linear
   fades can sound unnatural.

If you want a quicker fade up:

Ab(t) = (1+cos((1-x)*(1-x)*pi))/2
Aa(t) = 1 - Ab(t)


-- 
Paul Martin <pm at zetnet.net> (work)
  <pm at nowster.zetnet.co.uk> (home)
--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.




More information about the Vorbis mailing list