[linux-audio-dev] MVC - multiple CV

Paul Davis paul at linuxaudiosystems.com
Mon Oct 3 23:59:59 UTC 2005


> It has been stated that the model should send updates to
> all clients except the one that originated a parameter change.

never seen that stated. i consider that the CV never considers changes
to have been carried out just because it asked. anything else is not
really MVC. maybe the change requested by CV is not possible for M at
this time.

so the real signal flow is (with time on the vertical axis, increasing
going down.

		request
	C(n)----------------> M
	.
	.
	.     notification
	M   ----------------> all V(n)

> Another approach would be have an originating client id in
> each message, and some mark to indicate the final request
> (upon release). Then, while dragging, ignore other clients,
> and always only act on marked messages from yourself.

ardour uses this approach, but i have been phasing it out slowly in
favor of the "pure" MVC model shown above. i use a generic void*
"src" argument for changes, so that any object requesting a change
passes "itself"; when changes occur, the "src" is passed along, and the
object that initiated can ignore "its own" changes.

but, as i said, i am trying to phase this out in favor of a model where
there are no changes to the View until the Model sends a notification.
this is not easy to do, especially not with most GUI toolkit control
widgets like faders/sliders/knobs. for them, the approach i use is:

    void handle_model_state_change()
    {
        change_my_view_state_value (the_model_state->value);
    }

    void change_my_view_state_value (float newval)
    {
        if (my_view_state->value != newval) {
    	   my_view_state->value = newval;
	   send_change_to_model (my_view_state->value);
        }
    }

this causes one extra "cycle" in any state change, but ensures absolute 
agreement between V(C) and M. notice that C and (indirectly) M can both
use change_my_view_state() to achieve their goals.

--p





More information about the Linux-audio-dev mailing list