Re: [Freeciv-Dev] adding sound
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Thu, May 20, 1999 at 11:16:20AM +0200, Bastian Hecht was heard to say:
> With "running parallel", I meant to fork a process. It was annoying, when you
> can't
> continue
> playing while the sound was played.
That's true. But this isn't necessarily the best long-term solution
(although it's a lot simpler than the alternatives!)...in the snippet below I
was just suggesting that you keep the interface fairly abstract so that
programmer X can hypothetically go in and write a new sound system (esd, win32
(I believe someone's porting there?), etc... ) that honors the same interface
and then flip between them with configure tests. In fact,
we could deal with turning sound off at compile time by writing a dummy module
with empty functions..
Anyway, it looks like you've done that. If I get some time next week I might
start writing a esd backend (which requires me to read up on libesd's
interface...)
> I'll add a option to turn on/off the sounds in "game/options". So, a bool
> variable
> will be set.
> Everywhere where a sound is appreciated a function < sound(SOUND_NO); > will
> be
> called.
Ok. That sounds pretty good I guess. I think I thought of a problem with
that but I don't remember--oh yeah. Is it extensible from configuration files?
Now that I think about that again it shouldn't be too hard to add, but please
remember to keep that in mind :-) Actually, a 'better' possibility would be
for that to be in the global config area so that any sound backend can use it.
That is...create a table of the samples and then assign the samples to different
events. eg, (please excuse me, I'm ignorant about rulesets :-/ )
sound elephant elephant.wav
sound nuke /home/foo/.freeciv-sounds/nuke.wav
sound explosion boom.wav
...
unit missile {
attack=explosion
...
}
unit cannon {
attack=explosion
...
}
[wavfiles for the sake of argument, .au is perfectly ok...]
It should be fairly easy to generate the numbers automagically from a config
file like this (if a config file like this is allowed :-) )
> There is checked, if the variable is set. If it's disabled, the funtion
> returns
> immediatly, else
> the program tries to open the /dev/audio device and closes it after the sound
> was
> played.
> So it's always free when there's no sound.
That's a good start and probably not too hard to do. Please be sure that
it's possible to plug some other interface in, though :-)
> Well, if the /dev/audio is installed must be checked in configure (no idea
> how,
> remember, I'm
> really new to it, I've never programmed for a project).
I'd suggest reading the configure info pages and..lesse..I think there's a
tutorial on the Web somewhere, maybe linked off of the Gnome pages.
> basti
Good luck!
Daniel
> >
> > Actually a better method would be to write a generic set of calls to play
> > sounds..eg.. (warning: silly interface coming up, please make the real
> > thing
> > much more sophisticated than this)
> >
> > sounds.h:
> > #define ELEPHANT_NOISE 12
> > ..
> >
> > void sound_activate(int sound_num);
> >
> > someotherfile.c:
> > /* Elephant is attacking */
> > sound_activate(ELEPHANT_NOISE);
> >
> > and then use configure checks to enable/disable various sound backends.
> > ...he
> > says without writing a line of code...
> >
> > Daniel
> >
> > --
> > It is hard to think of anything less sentient than a pumpkin.
> >
> > -- Terry Pratchett, _Witches Abroad_
>
>
>
--
Wisdom is one of the few things that looks bigger the farther away it is.
-- Terry Pratchett
|
|