window.refresh problem with MIDI

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

window.refresh problem with MIDI

by rags música :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi list,

following to the solution Sam gave me to the MIDI Toggle question I made yesterday (the code is below, thanks a lot!), while making my GUI I came across to a problem.
I made a window the shows me the status of my Synths. I want that every time I start one Synth, a circle (using Pen) appears in the window showing that the synth is running.
Since I call the synths by using a midi keyboard, I call to the drawHook operation inside the function of NoteOnResponder.
I put window.refresh inside that function brackets, and I get error message, while the behavior of the window is strange: it only updates the circle when I activate any other window.... (uh?) What am I doing wrong?
here is the code and the error message.
Thanks!

Code:
(

var window, texto1;
window = SCWindow('loop machine', Rect(200, 1000, 492, 500));
window.view.background_(Color.black);
window.alpha = 0.95;
window.front.decorate;// <- wslib shortcut
SCStaticText(window, 117@20).string_("PLAY LOOP 1").stringColor_(Color.white);
window.refresh;


~seqPlay1 = Pseq(#[1,0], inf).asStream;
~midiOn1 = NoteOnResponder({|src, chan, num, value|
                    if(~seqPlay1.next == 1, {
                           ~reader1 = Synth(\bufReader, [\bufnum, 0]); [ src, chan, num, value].postln;
                           window.drawHook = {
                                Pen.translate(10, 10);
                                    Pen.color = Color.red;
                                    Pen.addWedge(40@50, 30, 0, 2pi);
                                    Pen.perform(\fill);
                                    };

                        },{
                           ~reader1.release(0.25); [src, chan, num, value].postln;
                           window.drawHook = {
                                Pen.translate(10, 10);
                                    Pen.color = Color.green;
                                    Pen.addWedge(40@50, 30, 0, 2pi);
                                    Pen.perform(\fill);
                                    };
                          
                        });window.refresh;
                    },nil, nil, {|val| val == 43}, nil);


)


Error message:

ERROR: Primitive '_SCWindow_Refresh' failed.
operation cannot be called from this Process.
RECEIVER:
Instance of SCWindow {    (12B79C70, gc=34, fmt=00, flg=00, set=04)
  instance variables [14]
    dataptr : nil
    name : "loop machine"
    onClose : nil
    view : instance of SCTopView (15B3A270, size=19, set=5)
    userCanClose : true
    alwaysOnTop : false
    drawHook : instance of Function (12D28BC0, size=2, set=1)
    acceptsMouseOver : false
    isClosed : true
    acceptsClickThrough : true
    toFrontAction : nil
    endFrontAction : nil
    editable : false
    constructionView : nil
}
CALL STACK:
    MethodError:reportError   15A6BBD0
        arg this = <instance of PrimitiveFailedError>
    Nil:handleError   15A78290
        arg this = nil
        arg error = <instance of PrimitiveFailedError>
    Thread:handleError   15A6E4B0
        arg this = <instance of Thread>
        arg error = <instance of PrimitiveFailedError>
    Object:throw   159A8AB0
        arg this = <instance of PrimitiveFailedError>
    Object:primitiveFailed   15A1ECF0
        arg this = <instance of SCWindow>
    MIDIResponder:value   15965180
        arg this = <instance of NoteOnResponder>
        arg src = 83677427
        arg chan = 0
        arg a = 43
        arg b = 101
    MIDIResponder:respond   15B67950
        arg this = <instance of NoteOnResponder>
        arg src = 83677427
        arg chan = 0
        arg num = 43
        arg value = 101
    < FunctionDef in Method Collection:any >   15BA48F0
        arg elem = <instance of NoteOnResponder>
        arg i = 0
    ArrayedCollection:do   15AFAF00
        arg this = [*1]
        arg function = <instance of Function>
        var i = 0
    Collection:any   15AA3FB0
        arg this = [*1]
        arg function = <instance of Function>
    Meta_MIDIIn:doNoteOnAction   152A7070
        arg this = class MIDIIn
        arg src = 83677427
        arg chan = 0
        arg num = 43
        arg veloc = 101


Re: window.refresh problem with MIDI

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Understanding Errors" helpfile...
hjh

On Wed, Aug 20, 2008 at 12:17 PM, rags música <ragsmusica@...> wrote:
> Hi list,
>
> following to the solution Sam gave me to the MIDI Toggle question I made
> yesterday (the code is below, thanks a lot!), while making my GUI I came
> across to a problem.


--
James Harkins /// dewdrop world
jamshark70@...
http://www.dewdrop-world.net

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman

_______________________________________________
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: window.refresh problem with MIDI

by rags música :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

found it.. of course .defer
thanks

2008/8/20 James Harkins <jamshark70@...>
"Understanding Errors" helpfile...
hjh

On Wed, Aug 20, 2008 at 12:17 PM, rags música <ragsmusica@...> wrote:
> Hi list,
>
> following to the solution Sam gave me to the MIDI Toggle question I made
> yesterday (the code is below, thanks a lot!), while making my GUI I came
> across to a problem.


--
James Harkins /// dewdrop world
jamshark70@...
http://www.dewdrop-world.net

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman

_______________________________________________
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/

LightInTheBox - Buy quality products at wholesale price!