Cross-Platform GUI Syntax; WAS: Creating a SynthDef that only lasts a certain amount of time

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

Cross-Platform GUI Syntax; WAS: Creating a SynthDef that only lasts a certain amount of time

by Michael G. Cox :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Speaking of which...

Although I appreciate the cross-platform syntax,
as a mac coder I find it a total pain it the ass to use Button
over SCButton for the simple reason that I habitually 
cmd-J for interface reference. 

Cmd-J on Button yields: 

Button : ViewRedirect { *key { ^\button }}

which I can't Cmd-J on
to get to my platform's unique Button class.

Is there some startup code that I can run so that
when I Cmd-J on 'Button' it opens my platform's
version of 'Button' instead of the above?

mgc


On Apr 19, 2009, at 1:33 AM, thor wrote:

Neels the GUI. syntax is old style now.

this would work :


(

SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store

var synth;

w = Window.new.front;

Button(w, Rect(20, 20, 200, 30))
.states_([["Boot Local Server", Color.black, Color.rand]])
.action_({Server.local.boot});

Button(w, Rect(20, 60, 200, 30))
.states_([
["Play", Color.black, Color.green],
["Stop", Color.black, Color.red]
])
.action_({arg button;
if (button.value == 1)
{ synth = Synth("Instrument") };
if(button.value == 0)
{ synth.free };
});

)

On 19 Apr 2009, at 02:34, Neels Janosch Hofmeyr wrote:

And if you use the GUI wrapper instead of the direct class names, your code
is also runnable on non-OSX machines, as they use e.g. JSCButton instead of
SCButton:

(

SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store

var synth;

w = GUI.window.new.front;

GUI.button.new(w, Rect(20, 20, 200, 30))
.states_([["Boot Local Server", Color.black, Color.rand]])
.action_({Server.local.boot});

GUI.button.new(w, Rect(20, 60, 200, 30))
.states_([
["Play", Color.black, Color.green],
["Stop", Color.black, Color.red]
])
.action_({arg button;
if (button.value == 1)
{ synth = Synth("Instrument") };
if(button.value == 0)
{ synth.free };
});

)



Michael G. Cox wrote:
or if you don't want to use an envelope you can
stop and start the synth with the same button:

(

SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store

var synth;

w = Window.new.front;

SCButton(w, Rect(20, 20, 200, 30))
.states_([["Boot Local Server", Color.black, Color.rand]])
.action_({Server.local.boot});

SCButton(w, Rect(20, 60, 200, 30))
.states_([
["Play", Color.black, Color.green],
["Stop", Color.black, Color.red]
])
.action_({arg button;
if (button.value == 1)
{ synth = Synth("Instrument") };
if(button.value == 0)
{ synth.free };
});

)




_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/


Re: Cross-Platform GUI Syntax; WAS: Creating a SynthDef that only lasts a certain amount of time

by jostM-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I agree that this is a pain. It takes many successive cmd-j's before you
actually have the class. I hope we can add a cmd-j redirection to the
redirect class at some point, so that it leads you to the correct
referred to class.  If it helps at all for now, the gui docs are now
complete enough that you can get the interface using cmd-d, which will
take you to the redirect stub, which has a link to the class docs. That
still means two steps, but is clearly better than cmd-J.

Jost

Michael Cox wrote:

>
> Speaking of which...
>
> Although I appreciate the cross-platform syntax,
> as a mac coder I find it a total pain it the ass to use Button
> over SCButton for the simple reason that I habitually
> cmd-J for interface reference.
>
> Cmd-J on Button yields:
>
> Button : ViewRedirect { *key { ^\button }}
>
> which I can't Cmd-J on
> to get to my platform's unique Button class.
>
> Is there some startup code that I can run so that
> when I Cmd-J on 'Button' it opens my platform's
> version of 'Button' instead of the above?
>
> mgc
>
>
> On Apr 19, 2009, at 1:33 AM, thor wrote:
>>
>> Neels the GUI. syntax is old style now.
>>
>> this would work :
>>
>>
>> (
>>
>> SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store
>>
>> var synth;
>>
>> w = Window.new.front;
>>
>> Button(w, Rect(20, 20, 200, 30))
>> .states_([["Boot Local Server", Color.black, Color.rand]])
>> .action_({Server.local.boot});
>>
>> Button(w, Rect(20, 60, 200, 30))
>> .states_([
>> ["Play", Color.black, Color.green],
>> ["Stop", Color.black, Color.red]
>> ])
>> .action_({arg button;
>> if (button.value == 1)
>> { synth = Synth("Instrument") };
>> if(button.value == 0)
>> { synth.free };
>> });
>>
>> )
>>
>> On 19 Apr 2009, at 02:34, Neels Janosch Hofmeyr wrote:
>>
>>> And if you use the GUI wrapper instead of the direct class names,
>>> your code
>>> is also runnable on non-OSX machines, as they use e.g. JSCButton
>>> instead of
>>> SCButton:
>>>
>>> (
>>>
>>> SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store
>>>
>>> var synth;
>>>
>>> w = GUI.window.new.front;
>>>
>>> GUI.button.new(w, Rect(20, 20, 200, 30))
>>> .states_([["Boot Local Server", Color.black, Color.rand]])
>>> .action_({Server.local.boot});
>>>
>>> GUI.button.new(w, Rect(20, 60, 200, 30))
>>> .states_([
>>> ["Play", Color.black, Color.green],
>>> ["Stop", Color.black, Color.red]
>>> ])
>>> .action_({arg button;
>>> if (button.value == 1)
>>> { synth = Synth("Instrument") };
>>> if(button.value == 0)
>>> { synth.free };
>>> });
>>>
>>> )
>>>
>>>
>>>
>>> Michael G. Cox wrote:
>>>> or if you don't want to use an envelope you can
>>>> stop and start the synth with the same button:
>>>>
>>>> (
>>>>
>>>> SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store
>>>>
>>>> var synth;
>>>>
>>>> w = Window.new.front;
>>>>
>>>> SCButton(w, Rect(20, 20, 200, 30))
>>>> .states_([["Boot Local Server", Color.black, Color.rand]])
>>>> .action_({Server.local.boot});
>>>>
>>>> SCButton(w, Rect(20, 60, 200, 30))
>>>> .states_([
>>>> ["Play", Color.black, Color.green],
>>>> ["Stop", Color.black, Color.red]
>>>> ])
>>>> .action_({arg button;
>>>> if (button.value == 1)
>>>> { synth = Synth("Instrument") };
>>>> if(button.value == 0)
>>>> { synth.free };
>>>> });
>>>>
>>>> )
>>>>
>>>
>>
>>
>> _______________________________________________
>> sc-users mailing list
>>
>> info (subscription, etc.):
>> http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>> 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 (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Cross-Platform GUI Syntax; WAS: Creating a SynthDef that only lasts a certain amount of time

by Scott Wilson-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This could be solved pretty easily by changing Process:openCodeFile  
and openWinCodeFile. The only issue is scel, as I don't know if it  
goes through this method. (marije?)

Maybe the thing to do would be have a Dictionary in Process where  
classes could register an openCodeFile redirect and then check there.  
Need to be careful about kit changes of course.

S.

On 19 Apr 2009, at 10:59, jostM wrote:

> I agree that this is a pain. It takes many successive cmd-j's before  
> you
> actually have the class. I hope we can add a cmd-j redirection to the
> redirect class at some point, so that it leads you to the correct
> referred to class.  If it helps at all for now, the gui docs are now
> complete enough that you can get the interface using cmd-d, which will
> take you to the redirect stub, which has a link to the class docs.  
> That
> still means two steps, but is clearly better than cmd-J.
>
> Jost
>
> Michael Cox wrote:
>>
>> Speaking of which...
>>
>> Although I appreciate the cross-platform syntax,
>> as a mac coder I find it a total pain it the ass to use Button
>> over SCButton for the simple reason that I habitually
>> cmd-J for interface reference.
>>
>> Cmd-J on Button yields:
>>
>> Button : ViewRedirect { *key { ^\button }}
>>
>> which I can't Cmd-J on
>> to get to my platform's unique Button class.
>>
>> Is there some startup code that I can run so that
>> when I Cmd-J on 'Button' it opens my platform's
>> version of 'Button' instead of the above?
>>
>> mgc
>>
>>
>> On Apr 19, 2009, at 1:33 AM, thor wrote:
>>>
>>> Neels the GUI. syntax is old style now.
>>>
>>> this would work :
>>>
>>>
>>> (
>>>
>>> SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store
>>>
>>> var synth;
>>>
>>> w = Window.new.front;
>>>
>>> Button(w, Rect(20, 20, 200, 30))
>>> .states_([["Boot Local Server", Color.black, Color.rand]])
>>> .action_({Server.local.boot});
>>>
>>> Button(w, Rect(20, 60, 200, 30))
>>> .states_([
>>> ["Play", Color.black, Color.green],
>>> ["Stop", Color.black, Color.red]
>>> ])
>>> .action_({arg button;
>>> if (button.value == 1)
>>> { synth = Synth("Instrument") };
>>> if(button.value == 0)
>>> { synth.free };
>>> });
>>>
>>> )
>>>
>>> On 19 Apr 2009, at 02:34, Neels Janosch Hofmeyr wrote:
>>>
>>>> And if you use the GUI wrapper instead of the direct class names,
>>>> your code
>>>> is also runnable on non-OSX machines, as they use e.g. JSCButton
>>>> instead of
>>>> SCButton:
>>>>
>>>> (
>>>>
>>>> SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store
>>>>
>>>> var synth;
>>>>
>>>> w = GUI.window.new.front;
>>>>
>>>> GUI.button.new(w, Rect(20, 20, 200, 30))
>>>> .states_([["Boot Local Server", Color.black, Color.rand]])
>>>> .action_({Server.local.boot});
>>>>
>>>> GUI.button.new(w, Rect(20, 60, 200, 30))
>>>> .states_([
>>>> ["Play", Color.black, Color.green],
>>>> ["Stop", Color.black, Color.red]
>>>> ])
>>>> .action_({arg button;
>>>> if (button.value == 1)
>>>> { synth = Synth("Instrument") };
>>>> if(button.value == 0)
>>>> { synth.free };
>>>> });
>>>>
>>>> )
>>>>
>>>>
>>>>
>>>> Michael G. Cox wrote:
>>>>> or if you don't want to use an envelope you can
>>>>> stop and start the synth with the same button:
>>>>>
>>>>> (
>>>>>
>>>>> SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store
>>>>>
>>>>> var synth;
>>>>>
>>>>> w = Window.new.front;
>>>>>
>>>>> SCButton(w, Rect(20, 20, 200, 30))
>>>>> .states_([["Boot Local Server", Color.black, Color.rand]])
>>>>> .action_({Server.local.boot});
>>>>>
>>>>> SCButton(w, Rect(20, 60, 200, 30))
>>>>> .states_([
>>>>> ["Play", Color.black, Color.green],
>>>>> ["Stop", Color.black, Color.red]
>>>>> ])
>>>>> .action_({arg button;
>>>>> if (button.value == 1)
>>>>> { synth = Synth("Instrument") };
>>>>> if(button.value == 0)
>>>>> { synth.free };
>>>>> });
>>>>>
>>>>> )
>>>>>
>>>>
>>>
>>>
>>> _______________________________________________
>>> sc-users mailing list
>>>
>>> info (subscription, etc.):
>>> http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>>> 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 (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
> 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 (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Cross-Platform GUI Syntax; WAS: Creating a SynthDef that only lasts a certain amount of time

by Scott Wilson-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Or maybe better just a *classRedirect method which does nothing in the  
default case, but which ViewRedirects could check a switch.

S.

On 19 Apr 2009, at 11:58, Scott Wilson wrote:

> This could be solved pretty easily by changing Process:openCodeFile  
> and openWinCodeFile. The only issue is scel, as I don't know if it  
> goes through this method. (marije?)
>
> Maybe the thing to do would be have a Dictionary in Process where  
> classes could register an openCodeFile redirect and then check  
> there. Need to be careful about kit changes of course.
>
> S.
>
> On 19 Apr 2009, at 10:59, jostM wrote:
>
>> I agree that this is a pain. It takes many successive cmd-j's  
>> before you
>> actually have the class. I hope we can add a cmd-j redirection to the
>> redirect class at some point, so that it leads you to the correct
>> referred to class.  If it helps at all for now, the gui docs are now
>> complete enough that you can get the interface using cmd-d, which  
>> will
>> take you to the redirect stub, which has a link to the class docs.  
>> That
>> still means two steps, but is clearly better than cmd-J.
>>
>> Jost
>>
>> Michael Cox wrote:
>>>
>>> Speaking of which...
>>>
>>> Although I appreciate the cross-platform syntax,
>>> as a mac coder I find it a total pain it the ass to use Button
>>> over SCButton for the simple reason that I habitually
>>> cmd-J for interface reference.
>>>
>>> Cmd-J on Button yields:
>>>
>>> Button : ViewRedirect { *key { ^\button }}
>>>
>>> which I can't Cmd-J on
>>> to get to my platform's unique Button class.
>>>
>>> Is there some startup code that I can run so that
>>> when I Cmd-J on 'Button' it opens my platform's
>>> version of 'Button' instead of the above?
>>>
>>> mgc
>>>
>>>
>>> On Apr 19, 2009, at 1:33 AM, thor wrote:
>>>>
>>>> Neels the GUI. syntax is old style now.
>>>>
>>>> this would work :
>>>>
>>>>
>>>> (
>>>>
>>>> SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store
>>>>
>>>> var synth;
>>>>
>>>> w = Window.new.front;
>>>>
>>>> Button(w, Rect(20, 20, 200, 30))
>>>> .states_([["Boot Local Server", Color.black, Color.rand]])
>>>> .action_({Server.local.boot});
>>>>
>>>> Button(w, Rect(20, 60, 200, 30))
>>>> .states_([
>>>> ["Play", Color.black, Color.green],
>>>> ["Stop", Color.black, Color.red]
>>>> ])
>>>> .action_({arg button;
>>>> if (button.value == 1)
>>>> { synth = Synth("Instrument") };
>>>> if(button.value == 0)
>>>> { synth.free };
>>>> });
>>>>
>>>> )
>>>>
>>>> On 19 Apr 2009, at 02:34, Neels Janosch Hofmeyr wrote:
>>>>
>>>>> And if you use the GUI wrapper instead of the direct class names,
>>>>> your code
>>>>> is also runnable on non-OSX machines, as they use e.g. JSCButton
>>>>> instead of
>>>>> SCButton:
>>>>>
>>>>> (
>>>>>
>>>>> SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store
>>>>>
>>>>> var synth;
>>>>>
>>>>> w = GUI.window.new.front;
>>>>>
>>>>> GUI.button.new(w, Rect(20, 20, 200, 30))
>>>>> .states_([["Boot Local Server", Color.black, Color.rand]])
>>>>> .action_({Server.local.boot});
>>>>>
>>>>> GUI.button.new(w, Rect(20, 60, 200, 30))
>>>>> .states_([
>>>>> ["Play", Color.black, Color.green],
>>>>> ["Stop", Color.black, Color.red]
>>>>> ])
>>>>> .action_({arg button;
>>>>> if (button.value == 1)
>>>>> { synth = Synth("Instrument") };
>>>>> if(button.value == 0)
>>>>> { synth.free };
>>>>> });
>>>>>
>>>>> )
>>>>>
>>>>>
>>>>>
>>>>> Michael G. Cox wrote:
>>>>>> or if you don't want to use an envelope you can
>>>>>> stop and start the synth with the same button:
>>>>>>
>>>>>> (
>>>>>>
>>>>>> SynthDef("Instrument", { Out.ar(0, SinOsc.ar(400, 0, 1)) }).store
>>>>>>
>>>>>> var synth;
>>>>>>
>>>>>> w = Window.new.front;
>>>>>>
>>>>>> SCButton(w, Rect(20, 20, 200, 30))
>>>>>> .states_([["Boot Local Server", Color.black, Color.rand]])
>>>>>> .action_({Server.local.boot});
>>>>>>
>>>>>> SCButton(w, Rect(20, 60, 200, 30))
>>>>>> .states_([
>>>>>> ["Play", Color.black, Color.green],
>>>>>> ["Stop", Color.black, Color.red]
>>>>>> ])
>>>>>> .action_({arg button;
>>>>>> if (button.value == 1)
>>>>>> { synth = Synth("Instrument") };
>>>>>> if(button.value == 0)
>>>>>> { synth.free };
>>>>>> });
>>>>>>
>>>>>> )
>>>>>>
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> sc-users mailing list
>>>>
>>>> info (subscription, etc.):
>>>> http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>>>> 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 (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>> 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 (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
> 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 (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/