iiwusynth-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iiwusynth-devel] Recent CVS changes


From: Josh Green
Subject: Re: [iiwusynth-devel] Recent CVS changes
Date: 03 Dec 2002 11:25:46 -0800

On Tue, 2002-12-03 at 04:53, Peter Hanappe wrote:
> > A good system I have seen of being able to set a lot of settings in a
> > backward compatible manner (when not using GObject properties and
> > ParamSpecs :) would be to make iiwu_settings_t opaque (no direct access
> > by library users, make it a void *) and then provide accessor functions
> > to it. [cut]
> 
> I agree almost completely. The reason I didn't do it this way
> was to avoid a tediously long list of setting parameters and testing
> for error results. Something you get with a lot of libraries (ALSA
> is one of them):
> 
>    if (settings_init(settings) != 0) {
>      printf("failed to initialize settings");
>      goto error_recovery;
>    }
>    if (settings_set_xyz(settings, foo, bar) != 0) {
>      printf("error setting xyz");
>      goto error_recovery;
>    }
>    /* ... */
> 
> Creating an iiwusynth object was to be snappy:
> 
>    iiwu_settings_t settings = IIWU_DEFAULT_SETTING;
>    iiwu_synth_t* synth = new_iiwu_synth(&settings);
> 
> Two lines and you've got a running MIDI synthesizer!
> 
> Anyway, you're right, we should use accessor functions. API change
> coming soon!
> 

Well you could do the verification of settings when they are applied to
the FluidSynth context (or when the context is activated if the settings
are applied directly to the context instead of a separate settings
context) so it might look like:

fluid_settings_t *settings;

settings = new_fluid_settings ();   /* initialized to default values */
fluid_set_xyz (settings, foo, bar);

if (!(synth = new_fluid_synth (settings))) {
  printf ("Error creating FluidSynth context");
  return (FALSE);
}


Which is pretty much how things are anyways (all settings are verified
when the synth context is created). If the settings were applied
directly to the synth context it might look like:


fluid_synth_t *synth;

/* create inactive synth context with default settings */
synth = new_fluid_synth ();

fluid_set_xyz (synth, foo, bar);

if (fluid_synth_activate (synth) != 0) {
   printf ("Error activating FluidSynth: %s",
           fluid_synth_error_str (synth));
   fluid_synth_free (synth);
   return (FALSE);
}

> 
> > This brings me to realize another thing missing from the current way of
> > dealing with settings. Ways to determine min/max/default values for
> > different parameters.
> 
> Completely agree. It's the modern way to do things.
> 
> Since we have quite a big number of settings, I'll try to think of
> an organized way to do this to avoid an API explosion.
> 

Yeah, the GObject API for dealing with this is quite large, since it has
an extendable type system and deals with many fundamental types (ints,
chars, floats, bools, boxed types, etc). Even if restricting parameter
types to the basics (ints, floats, strings) it might be a lot of work to
implement from scratch.

> 
> Cheers,
> Peter
> 

Lates.
        Josh Green





reply via email to

[Prev in Thread] Current Thread [Next in Thread]