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.
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: