Re: [AD] proposed changes to sound API

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Tue, Dec 16, 2008 at 4:39 PM, Matthew Leverton <meffer@xxxxxxxxxx> wrote:
> Before I submit any smaller patches, I'd like to propose some bigger
> changes to the sound API.
>

I've made most of the changes and updated the examples to work. I'm
still not quite sure of the best way to handle the default mixer.

ex_saw now looks something like:

--
al_install_audio(ALLEGRO_AUDIO_DRIVER_AUTODETECT);
al_reserve_samples(8);
stream = al_create_stream(8, SAMPLES_PER_BUFFER, 22050,
ALLEGRO_AUDIO_DEPTH_UINT8, ALLEGRO_CHANNEL_CONF_1);
al_attach_stream_to_mixer(al_get_default_mixer(), stream);
--

It uses a stream to play some noise. Like most Allegro apps, it can
get by quite easily with the api formerly known as simple. In fact, it
doesn't ever use al_play_sample(), and thus doesn't really need to
reserve any samples. However, it does need to use the default mixer
(to prevent creating its own), thus a call to al_reserve_samples() is
needed, and that bugs me a little bit.

Some alternatives:

A) setup a default mixer (and voice) at the time of
al_install_audio(). Then the call to al_reserve_samples() could be
removed entirely for this example. It would still be needed for apps
that used al_play_sample().

B) same as A, except add parameters to al_install_audio(). eg.
al_install_audio(ALLEGRO_AUDIO_DRIVER_AUTODETECT,
ALLEGRO_DEFAULT_MIXER)

C) rename al_reserve_samples() to al_setup_default_mixer()


I prefer A because 99% of the time, nobody is going to want to create
his own voice and mixer, and would be quite happy to use Allegro's
default one. Obviously the downside is that if you don't want to use
Allegro's, then it would be created automatically for no reason. (You
could override it via al_set_default_mixer(), which would cause
Allegro's to be destroyed.)

My second choice would be C. I don't really like verbose parameters in
install() functions, as they are hard to remember.

--
Matthew Leverton




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/