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

Re: [sc-users] callback



Take a look at Server:doWhenBooted:

Server.doWhenBooted {
     "I'm booted!".postln;
}

On Thu, Mar 14, 2019 at 4:37 PM <meunier.fabien@xxxxxxxxx> wrote:
Hello list,

Is there a way in sc to use a callback (like in js for example) for
asynchronous execution ?
I'd like to have only one file open with calls to other files like that:
this.executeFile(PathName(thisProcess.nowExecutingPath).parentPath ++
"SetUp.scd"); // set ServerOptions and boot it
this.executeFile(PathName(thisProcess.nowExecutingPath).parentPath ++
"SynthDef.scd"); // add SynthDef on the server

If I execute these two lines at the same time, in this order, I have the
following error:
ERROR: Message 'uid' not understood.
RECEIVER:
    nil
ARGS:
PATH: D:/SuperCollider/ORBM/ORBM_Start.scd

PROTECTED CALL STACK:
        Meta_MethodError:new    000000004388AAC0
                arg this = DoesNotUnderstandError
                arg what = nil
                arg receiver = nil
        Meta_DoesNotUnderstandError:new 000000004388CA80
                arg this = DoesNotUnderstandError
                arg receiver = nil
                arg selector = uid
                arg args = [  ]
        Object:doesNotUnderstand        0000000043122A00
                arg this = nil
                arg selector = uid
                arg args = nil
        Meta_MIDIOut:new        0000000044D5F380
                arg this = MIDIOut
                arg port = 2
                arg uid = nil
        a FunctionDef   000000004868BBC8
                sourceCode = "{
        ~cleanup.value;
});
) "
        a FunctionDef   0000000043743040
                sourceCode = "<an open Function>"
        Function:prTry  0000000043B70D40
                arg this = a Function
                var result = nil
                var thread = a Thread
                var next = nil
                var wasInProtectedFunc = false

CALL STACK:
        DoesNotUnderstandError:reportError
                arg this = <instance of DoesNotUnderstandError>
        Nil:handleError
                arg this = nil
                arg error = <instance of DoesNotUnderstandError>
        Thread:handleError
                arg this = <instance of Thread>
                arg error = <instance of DoesNotUnderstandError>
        Object:throw
                arg this = <instance of DoesNotUnderstandError>
        Function:protect
                arg this = <instance of Function>
                arg handler = <instance of Function>
                var result = <instance of DoesNotUnderstandError>
        Interpreter:executeFile
                arg this = <instance of Interpreter>
                arg pathName = "D:/SuperCollider/ORBM/ORBM_S..."
                arg args = [*0]
                var result = nil
                var saveExecutingPath = "D:/SuperCollider/ORBM/ORBM_S..."
        < closed FunctionDef >  (no arguments or variables)
        Interpreter:interpretPrintCmdLine
                arg this = <instance of Interpreter>
                var res = nil
                var func = <instance of Function>
                var code = "(
this.executeFile(PathName(..."
                var doc = nil
                var ideClass = <instance of Meta_ScIDE>
        Process:interpretPrintCmdLine
                arg this = <instance of Main>
^^ The preceding error dump is for ERROR: Message 'uid' not understood.
RECEIVER: nil


If I execute those two lines one after the other:
this.executeFile(PathName(thisProcess.nowExecutingPath).parentPath ++
"SetUp.scd"); // this one first
this.executeFile(PathName(thisProcess.nowExecutingPath).parentPath ++
"SynthDef.scd"); // then this one after the boot is completed

I have no error
so I presume the problem is that I try to add SynthDef on a server which
is not totaly booted
That's why I though a callback could make sense here to recreate
something like this:

this.executeFile(PathName(thisProcess.nowExecutingPath).parentPath ++
"SetUp.scd"); // this one first
s.serverRunning.if({
     this.executeFile(PathName(thisProcess.nowExecutingPath).parentPath
++ "SynthDef.scd");
});

I thank you in advance for your help
Fabien

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/