[vorbis-dev] Re: Suggestion for libvorbisfile: scaling

Paul Martin pm at nowster.zetnet.co.uk
Sat Jan 5 16:59:43 PST 2002



On Thu, Jan 03, 2002 at 01:03:11PM +0000, pm wrote:
> I've been experimenting with the ideas of Replay Gain[1] and find that
> ogg123 doesn't have a way of specifying the scaling applied to
> replayed samples (like -f in mpg123).

> ov_read() scales by either 128 (byte output) or 32768 (word output),
> but there's nothing in between.
> 
> ov_read_float() outputs floats, which is OK, but means more work in the
> frontend program.

Further to this I've "used the source" and made an ogg-to-raw pipeline,
with scaling. A suggestion for if anyone's considering making an
ov_read_scale(), make the scaling factor a float, with unity gain being
1.0. Then you can calculate scale=32768.f*scale_factor (or
scale=128.f*scale_factor) and use that instead of the constants in a
copy of ov_read.

Something like:

float scale = (word==1?128.f:32768.f)*scale_factor;

Or if you want to use decibels,

float scale = (word==1?128.f:32768.f)*pow(10.0,decibel/20.0);

I also made another program to calculate the replaygain directly from
an ogg stream using ov_read_float(), which has the advantage that it
calculates correctly even for streams that would go into clipping using
ov_read. I have one produced by "libVorbis I 20010813" which peaks at
35226 (1.075021 * FS, or +0.628 dBFS).

Why am I doing all this? I've written a playout system for a volunteer
FM radio station which is likely to be on for 14 days in mid February.
If I couldn't get some sort of level equalisation between tracks, I'd
have had to be encoding everything to mp3 (mpg123 has the -f option).


-- 
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-dev-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-dev mailing list