How to compress sound?

We are going to add sound support to eounicorn soon. However - I am afraid
about game download size. Which library should I use to read sound samples
saved in mp3 [1] ? Is it possible with SDL_Mixer? Is it other way to save space
used by sound samples?

[1] or maybe ogg?

libvorbis, the lib by the ogg guys, is a pretty good lib to use if you
want to store your sounds/music in ogg. granted ogg’s designed for
music, so storing voices might not sound as great as an uncompressed
wav.

anyway, if you’re talking music/sound effects, i’d try libvorbis. you
can pass it a file pointer to an ogg and it will return uncompressed
samples as raw pcm data, which most audio libs can use. sdl_mixer
probably can do that (i’ve never tried) but i know openal can.On Sat, 2002-05-18 at 16:17, Jacek Pop?awski wrote:

We are going to add sound support to eounicorn soon. However - I am afraid
about game download size. Which library should I use to read sound samples
saved in mp3 [1] ? Is it possible with SDL_Mixer? Is it other way to save space
used by sound samples?

[1] or maybe ogg?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Chris
@Christopher_Thielen

Jacek Pop?awski wrote:

We are going to add sound support to eounicorn soon. However - I am afraid
about game download size. Which library should I use to read sound samples
saved in mp3 [1] ? Is it possible with SDL_Mixer? Is it other way to save space
used by sound samples?

[1] or maybe ogg?

SDL_mixer and SDL_sound can both use mp3 and ogg…
though SDL_sound has a better mp3 decoder…
this isn’t hard to find info! comon…–
-==-
Jon Atkins
http://jcatki.2y.net/

For a recent project I’ve just used bonk, an audio compressor that achieves
around 14:1 compression on wavs with no perceptible loss of quality. This
was on both loud sounds like crowd noises, and sharp sounds like whistles…
pretty good IMO, and I’ve not tried the lossless mode. The code which
implements it is tiny, though its distribution license may make it unsuitable
for embedding into your game. What I did was compile the supplied .exe for
Windows and have the installer execute ‘bonk.exe decode
resources\sounds*.bonk’ during the installation. The link you want is here:

http://yoyo.cc.monash.edu.au/~pfh/bonk/On Sunday 19 May 2002 00:17, you wrote:

We are going to add sound support to eounicorn soon. However - I am afraid
about game download size. Which library should I use to read sound samples
saved in mp3 [1] ? Is it possible with SDL_Mixer? Is it other way to save
space used by sound samples?


Matthew > http://www.soup-kitchen.net/
> ICQ 19482073

We are going to add sound support to eounicorn soon. However - I am
afraid about game download size. Which library should I use to read
sound samples saved in mp3 [1] ? Is it possible with SDL_Mixer?

SDL_sound might be more appropriate, but I don’t know how useful that is
for sound effects with SDL_Mixer right now. The problem is that SDL_Mixer
treats sound and music as two different things, which means that you
cannot use mp3, ogg, modules, MIDIs etc as sound effects.

The idea seems to be that SDL_Mixer should eventually use SDL_sound for
loading and/or streaming, which would probably do what you want.

[1] or maybe ogg?

SDL_sound again, I think.

Is it
other way to save space used by sound samples?

Well… Don’t store samples on disk at all. :slight_smile:

Below is one of the two new sound effects I added to Kobo Deluxe in the
later snapshots; launch.agw (played when ships are launched from bases):

—8<------------------------------------------------------
/////////////////////////////////////////////
// Turbine howl + acceleration stall noise
// Copyright © David Olofson, 2002
/////////////////////////////////////////////

w_format target, MONO16, 16000;
w_blank target, 12800, 0;

//noise
w_env FREQUENCY, 0, 8000;
w_env AMPLITUDE,
.05, .03,
.05, .07,
.1, .13,
.5, 0;
w_env RATIO, 0, 1;
w_add target, NOISE;

//low turbine
w_env AMPLITUDE,
0, 0,
.2, .025,
.6, 0;

w_env FREQUENCY,
0, 700,
.3, 1400,
.5, 1500;
w_env RATIO, 0, 0.5;
w_add target, TRIANGLE;

w_env FREQUENCY,
0, 800,
.3, 1600,
.5, 1750;
w_add target, TRIANGLE;

//high turbine
w_env AMPLITUDE,
0, 0,
.5, .03,
.3, 0;
w_env FREQUENCY,
0, 2200,
.3, 3300,
.5, 3540;
w_env RATIO, 0, 0;
w_add target, SINE;

//bp filter sweep
w_env FREQUENCY,
0, 3000,
.15, 2000,
.05, 1000,
.6, 800;
w_env AMPLITUDE,
0, 1.5,
.02, 1.5,
.01, 10,
.17, 8,
.6, 5;
w_env RATIO, 0, 0;
w_filter target, BANDPASS_12;
------------------------------------------------------>8—
(995 bytes, comments and formatting included)

This script is executed by the engine at load time, and results in a 16
bit 16 kHz mono waveform of ~25 kB. (You could render it at any sample
rate you like, though.)

Times are in seconds, frequencies in Hz, amplitude 1.0 <==> peak
regardless of sample format etc. It’s all based on more or less
traditional synthesis methods, such as additive (various forms of
spectra), oscillators with “morphable” geometric waveforms, subtractive
(resonant filters), FM, AM, ring modulation, distortion etc.

Most kinds of sounds can be generated with just a few lines of code,
including rather realistic acoustic instruments. A full “CD quality”
(whatever that means…) song with MIDI + instruments can be squeezed
into some 3-5 kB compressed. (Similar to IXS in size. No comment on
quality - I’ll let others judge.)

Of course, you’ll need some synth programming experience to get any
sensible sounds out of this engine (well, it can load WAVs, but that’s
cheating… ;-), but OTOH, you can create any kind of sound from
scratch, and edit all aspects of it in any way you like.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Sunday 19 May 2002 01:17, Jacek Pop?awski wrote: