keeping gui in sync with data

View: New views
11 Messages — Rating Filter:   Alert me  

keeping gui in sync with data

by Josh Mattoon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm writing a little app with an optional GUI.  I've written one
custom view that uses the data directly, but with standard GUI.slider
and whatnot I need to update them manually.  Is there an elegant way
to make the GUI reflect the underlying data?

Bonus question:  I just got a BCR2000.  This unit has endless faders
that you can update via midi.  I'd like keep this in sync with my data
as well.

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: keeping gui in sync with data

by Jascha Narveson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Check out Ron Kuivila's class CV (short for "control value") - it  
stores data in accordance with a user-defined ControlSpec, and they  
can be linked to GUIs very easily.  changing the value of the CV  
automatically changes the GUIs, and vice-versa.

It's included in the Wesleyan build (link below), in a folder called  
Preset in the SCClassLibrary.  Preset is the name of his first auto-
GUI-creation system, which is really handy for people who just want  
quick GUIs to control things.  The Preset folder also contains  
Conductor, which is the new version of same, and which is built  
around Events. Conductor is a totally useful class to have around.  
There are helpfiles included.

cheers,

jascha


On Jul 5, 2008, at 3:54 PM, Josh Mattoon wrote:

> I'm writing a little app with an optional GUI.  I've written one
> custom view that uses the data directly, but with standard GUI.slider
> and whatnot I need to update them manually.  Is there an elegant way
> to make the GUI reflect the underlying data?
>
> Bonus question:  I just got a BCR2000.  This unit has endless faders
> that you can update via midi.  I'd like keep this in sync with my data
> as well.
>
> _______________________________________________
> sc-users mailing list
>
>
> info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/ 
> MusicTechnology/880
> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>


_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: keeping gui in sync with data

by andrea valle-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 5 Jul 2008, at 21:54, Josh Mattoon wrote:

I'm writing a little app with an optional GUI.  I've written one
custom view that uses the data directly, but with standard GUI.slider
and whatnot I need to update them manually.  Is there an elegant way
to make the GUI reflect the underlying data?

If I have understood, you need  the Observer Pattern

typically used for MVC

SC implements it natively. See Object under Dependency

The idea is that the you have a model, i.e. all the data manipulation object, which works autonomously.
The model has an array (which can be void) of possible dependants.
A dependant is just another object which "observes" the model.

Each time something relevant happens in the model, the model sends a change message to all its dependants.
If there are no dependants, nothing happens.
Otherwise, a dependant must implement a updated message which is called each time the changed arrives.
To summarize, the model changes, and the change triggers an update in all the dependants.

Dependants can be what you want, typically a GUI which is two functionally  two things: a view (it displays data to the user) and a controller (it allows to input data from the user).
For the midi controller, conceptually it's just the same: it is a view if it is updated from SC, it is a controller if it updates the model.

I'm using it all the time for GUI.

HTH

-a- 


Bonus question:  I just got a BCR2000.  This unit has endless faders
that you can update via midi.  I'd like keep this in sync with my data
as well.

_______________________________________________
sc-users mailing list



--------------------------------------------------
Andrea Valle
--------------------------------------------------
CIRMA - DAMS
Università degli Studi di Torino
--------------------------------------------------


"
Think of it as seasoning
. noise [salt] is boring
. F(blah) [food without salt] can be boring
. F(noise, blah) can be really tasty
"
(Ken Perlin on noise)






Re: keeping gui in sync with data

by Josh Mattoon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is perfect.  I figured SC had support for something along these
lines but I can never find what I'm looking for in the docs.  And yes
I'm trying to use MVC :)

On Sat, Jul 5, 2008 at 1:41 PM, Andrea Valle <valle@...> wrote:

>
> On 5 Jul 2008, at 21:54, Josh Mattoon wrote:
>
> I'm writing a little app with an optional GUI.  I've written one
> custom view that uses the data directly, but with standard GUI.slider
> and whatnot I need to update them manually.  Is there an elegant way
> to make the GUI reflect the underlying data?
>
> If I have understood, you need  the Observer Pattern
> http://en.wikipedia.org/wiki/Observer_pattern
> typically used for MVC
> http://en.wikipedia.org/wiki/Model-view-controller
> SC implements it natively. See Object under Dependency
> The idea is that the you have a model, i.e. all the data manipulation
> object, which works autonomously.
> The model has an array (which can be void) of possible dependants.
> A dependant is just another object which "observes" the model.
> Each time something relevant happens in the model, the model sends a change
> message to all its dependants.
> If there are no dependants, nothing happens.
> Otherwise, a dependant must implement a updated message which is called each
> time the changed arrives.
> To summarize, the model changes, and the change triggers an update in all
> the dependants.
> Dependants can be what you want, typically a GUI which is two functionally
>  two things: a view (it displays data to the user) and a controller (it
> allows to input data from the user).
> For the midi controller, conceptually it's just the same: it is a view if it
> is updated from SC, it is a controller if it updates the model.
> I'm using it all the time for GUI.
> HTH
> -a-
>
> Bonus question:  I just got a BCR2000.  This unit has endless faders
> that you can update via midi.  I'd like keep this in sync with my data
> as well.
> _______________________________________________
> sc-users mailing list
>
> info (subscribe and unsubscribe):
> http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>
> --------------------------------------------------
> Andrea Valle
> --------------------------------------------------
> CIRMA - DAMS
> Università degli Studi di Torino
> --> http://www.cirma.unito.it/andrea/
> --> http://www.myspace.com/andreavalle
> --> andrea.valle@...
> --------------------------------------------------
>
> "
> Think of it as seasoning
> . noise [salt] is boring
> . F(blah) [food without salt] can be boring
> . F(noise, blah) can be really tasty
> "
> (Ken Perlin on noise)
>
>
>
>
>

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: keeping gui in sync with data

by Julian Rohrhuber :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
>SC implements it natively. See Object under Dependency
>
>The idea is that the you have a model, i.e. all the data
>manipulation object, which works autonomously.
>The model has an array (which can be void) of possible dependants.
>A dependant is just another object which "observes" the model.

Polling the value from the GUI, and leaving the rest of the system
completely uncoupled, has sometimes proven to be most useful. This
has been considered bad design sometimes, but is mostly just a blind
belief in MVC. Systems that use communicating streams often use
polling as a basic principle, too.
--





.

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: keeping gui in sync with data

by Josh Mattoon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Jascha,  this looks good but I prefer to work without
extensions. The Object Dependency stuff should work for me.

On Sat, Jul 5, 2008 at 1:36 PM, Jascha Narveson <jnarveson@...> wrote:

>
> Check out Ron Kuivila's class CV (short for "control value") - it stores
> data in accordance with a user-defined ControlSpec, and they can be linked
> to GUIs very easily.  changing the value of the CV automatically changes the
> GUIs, and vice-versa.
>
> It's included in the Wesleyan build (link below), in a folder called Preset
> in the SCClassLibrary.  Preset is the name of his first auto-GUI-creation
> system, which is really handy for people who just want quick GUIs to control
> things.  The Preset folder also contains Conductor, which is the new version
> of same, and which is built around Events. Conductor is a totally useful
> class to have around. There are helpfiles included.
>
> cheers,
>
> jascha
>
>
> On Jul 5, 2008, at 3:54 PM, Josh Mattoon wrote:
>
>> I'm writing a little app with an optional GUI.  I've written one
>> custom view that uses the data directly, but with standard GUI.slider
>> and whatnot I need to update them manually.  Is there an elegant way
>> to make the GUI reflect the underlying data?
>>
>> Bonus question:  I just got a BCR2000.  This unit has endless faders
>> that you can update via midi.  I'd like keep this in sync with my data
>> as well.
>>
>> _______________________________________________
>> sc-users mailing list
>>
>>
>> info (subscribe and unsubscribe):
>> http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
>> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
>> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>>
>
>
> _______________________________________________
> sc-users mailing list
>
>
> info (subscribe and unsubscribe):
> http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: keeping gui in sync with data

by andrea valle-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Interesting. Do you mean by scheduling a routine?

-a-


On 5 Jul 2008, at 22:52, Julian Rohrhuber wrote:


SC implements it natively. See Object under Dependency

The idea is that the you have a model, i.e. all the data manipulation object, which works autonomously.
The model has an array (which can be void) of possible dependants.
A dependant is just another object which "observes" the model.

Polling the value from the GUI, and leaving the rest of the system completely uncoupled, has sometimes proven to be most useful. This has been considered bad design sometimes, but is mostly just a blind belief in MVC. Systems that use communicating streams often use polling as a basic principle, too.
-- 





.

_______________________________________________
sc-users mailing list



--------------------------------------------------
Andrea Valle
--------------------------------------------------
CIRMA - DAMS
Università degli Studi di Torino
--------------------------------------------------


"
Think of it as seasoning
. noise [salt] is boring
. F(blah) [food without salt] can be boring
. F(noise, blah) can be really tasty
"
(Ken Perlin on noise)






Re: keeping gui in sync with data

by andrea valle-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Maybe you save some time

BabaPatcher {

*new { arg name ; 
^super.new.initBabaPatcher(name) 
}

initBabaPatcher { arg aName ;
name = aName.asSymbol ;
this.changed(this, [\init]) ;  // all the dependants receive this
}


}




BabaPatcherGui {

var <>patcher ;


*new { arg patcher ;

^super.new.initBabaPatcherGui(patcher) 
}

initBabaPatcherGui { arg aPatcher ;
     patcher = aPatcher ;
    patcher.addDependant(this) ;
}

// etc

// each dependant implements this

update { arg theChanged, theChanger, more ;
var argDict, guiArr ;
var val, min, max ;
case 
// discriminating by argument
{ more[0] == \init }
this.doSomething
}
}
}


Best

-a-


On 5 Jul 2008, at 22:50, Josh Mattoon wrote:

This is perfect.  I figured SC had support for something along these
lines but I can never find what I'm looking for in the docs.  And yes
I'm trying to use MVC :)

On Sat, Jul 5, 2008 at 1:41 PM, Andrea Valle <valle@...> wrote:

On 5 Jul 2008, at 21:54, Josh Mattoon wrote:

I'm writing a little app with an optional GUI.  I've written one
custom view that uses the data directly, but with standard GUI.slider
and whatnot I need to update them manually.  Is there an elegant way
to make the GUI reflect the underlying data?

If I have understood, you need  the Observer Pattern
typically used for MVC
SC implements it natively. See Object under Dependency
The idea is that the you have a model, i.e. all the data manipulation
object, which works autonomously.
The model has an array (which can be void) of possible dependants.
A dependant is just another object which "observes" the model.
Each time something relevant happens in the model, the model sends a change
message to all its dependants.
If there are no dependants, nothing happens.
Otherwise, a dependant must implement a updated message which is called each
time the changed arrives.
To summarize, the model changes, and the change triggers an update in all
the dependants.
Dependants can be what you want, typically a GUI which is two functionally
 two things: a view (it displays data to the user) and a controller (it
allows to input data from the user).
For the midi controller, conceptually it's just the same: it is a view if it
is updated from SC, it is a controller if it updates the model.
I'm using it all the time for GUI.
HTH
-a-

Bonus question:  I just got a BCR2000.  This unit has endless faders
that you can update via midi.  I'd like keep this in sync with my data
as well.
_______________________________________________
sc-users mailing list

info (subscribe and unsubscribe):

--------------------------------------------------
Andrea Valle
--------------------------------------------------
CIRMA - DAMS
Università degli Studi di Torino
--------------------------------------------------

"
Think of it as seasoning
. noise [salt] is boring
. F(blah) [food without salt] can be boring
. F(noise, blah) can be really tasty
"
(Ken Perlin on noise)






_______________________________________________
sc-users mailing list



--------------------------------------------------
Andrea Valle
--------------------------------------------------
CIRMA - DAMS
Università degli Studi di Torino
--------------------------------------------------


"
Think of it as seasoning
. noise [salt] is boring
. F(blah) [food without salt] can be boring
. F(noise, blah) can be really tasty
"
(Ken Perlin on noise)






Re: keeping gui in sync with data

by Julian Rohrhuber :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>Interesting. Do you mean by scheduling a routine?

yes, you just use a SkipJack to keep up a task
running as long as the GUI is open. You may
compare if anything has changed before you update
the GUI.



>-a-
>
>
>On 5 Jul 2008, at 22:52, Julian Rohrhuber wrote:
>
>>>
>>>SC implements it natively. See Object under Dependency
>>>
>>>The idea is that the you have a model, i.e.
>>>all the data manipulation object, which works
>>>autonomously.
>>>The model has an array (which can be void) of possible dependants.
>>>A dependant is just another object which "observes" the model.
>>>
>>
>>Polling the value from the GUI, and leaving the
>>rest of the system completely uncoupled, has
>>sometimes proven to be most useful. This has
>>been considered bad design sometimes, but is
>>mostly just a blind belief in MVC. Systems that
>>use communicating streams often use polling as
>>a basic principle, too.
>>--
>>
>>
>>
>>
>>
>>.
>>
>>_______________________________________________
>>sc-users mailing list
>>
>>
>>info (subscribe and unsubscribe):
>><http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880>http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
>>archive:
>><http://www.listarc.bham.ac.uk/marchives/sc-users/>http://www.listarc.bham.ac.uk/marchives/sc-users/
>>search:
>><http://www.listarc.bham.ac.uk/lists/sc-users/search/>http://www.listarc.bham.ac.uk/lists/sc-users/search/
>>
>
>--------------------------------------------------
>Andrea Valle
>--------------------------------------------------
>CIRMA - DAMS
>Università degli Studi di Torino
>--> <http://www.cirma.unito.it/andrea/>http://www.cirma.unito.it/andrea/
>--> <http://www.myspace.com/andreavalle>http://www.myspace.com/andreavalle
>--> <mailto:andrea.valle@...>andrea.valle@...
>--------------------------------------------------
>
>
>"
>Think of it as seasoning
>. noise [salt] is boring
>. F(blah) [food without salt] can be boring
>. F(noise, blah) can be really tasty
>"
>(Ken Perlin on noise)


--





.

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: keeping gui in sync with data

by Alberto de Campo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>>Interesting. Do you mean by scheduling a routine?
>
>yes, you just use a SkipJack to keep up a task running as long as
>the GUI is open. You may compare if anything has changed before you
>update the GUI.
>

The SkipJack help file has a simple example, and JITLib guis like
TaskProxyEditor, HistoryGui, NodeProxyEditor and ProxyMixer use this
scheme.

best, a
--
--
Alberto de Campo
Bergstrasse 59/33
A-8020 Graz, Austria
e-mail : adc@...
--

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: keeping gui in sync with data

by andrea valle-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok, but this means you loose the idea of triggering event in favor of sampling, no?
 

-a-



On 5 Jul 2008, at 23:24, Julian Rohrhuber wrote:

Interesting. Do you mean by scheduling a routine?