[CM] Scheduler and environment
taube at illinois.edu
Mon May 27 08:48:32 PDT 2013
> Now, the main problem was that sometimes the midi receiver would increase the step variable from 1 but the messages wouldn't be sent to Max/MSP - or wouldn't arrive : I'm also asking Max's experts about their end of my problem. One thing was pretty clear, it sent either every messages or none.\
if your step variable is always incrementing correctly then it would seem the problem would be not with midi per se but rather in (or under) the sendocs call. but just to make sure you might try turning on midi tracing using the menu item Audio>Midi In> Trace Input to make sure the midi code is always happening
so at this point its still hard for me to really understand exactly what the issue is here…the "(if (string? ((n 0) 0))" looks very odd to me -- is each "n" really a function that is called with a zero and returns another function that is called with another 0 to return a possible string?
or maybe this is just an email typo???…
midi and osc triggers are handled pretty much the same way: a callback node is registered with the scheduler and evaluated with the arriving data. when the scheduler pops that node and evals it the scheduler has to wait for the scheme code its calling to return before it can do anything else, but i don't *think* that would stop other processes from added more trigger nodes to the queue.
sigh. i wish you could add a few c++ trace calls to the 3.8.0 Grace code base and rebuild to trace/debug things but unfortunately i have no tar ball of S7 Scheme 1.105 (6-Feb-12) and i can't find one. so i can't really build that super-stable Grace from sources to debug. and you can't build the cm in the repo because I never got that running without some scheme code crashing that i didn't have the time the past months to really work on! i guess the shortest path might be for me to try get this going again, but i don't thing there is going to be a quick easy answer for you, I'm sorry!
> -Second question is about my midi receiver, it receives values from a midi-pedal.
> In order to make it short it looks like this :
> (define step 0)
> (define (trigger msg)
> (if (= (last msg) 127)
> (sendosc (cues step))
> (set! step (+ step 1)))))
> (mp:receive mm:ctrl trigger)
> Where cues is a list containing lists and closures and (sendosc) translates those lists and closures into processes that send osc messages. Typically (cues 0) would look like this '((("hi") (100))(("ho")(200))). (sendosc) looks also like this :
> (define (sendosc lst)
> (loop for n in lst
> (if (string? ((n 0) 0))
> (sprout (list->message n))
> (sendosc n))))
> Now, the main problem was that sometimes the midi receiver would increase the step variable from 1 but the messages wouldn't be sent to Max/MSP - or wouldn't arrive : I'm also asking Max's experts about their end of my problem. One thing was pretty clear, it sent either every messages or none.
> At first, I changed the condition of the receiver so that the first value of the controller greater than 0 would trigger the whole thing, but it didn't really changed anything. Because I also tried an osc receiver that took a single value whenever I hit the spacebar in Max, and that solution was rock solid - even though unpracticable for the piece - I thought that maybe the midi receiver wouldn't have always the time to fully evaluate (sendosc) if the incoming messages were to be very fast, like they are with most midi-pedal… but it is just a guess...
> Is it possible that the scheduler gives priority to the newest message and drops the task of evaluating what comes with the old ones?
> Would it be possible to filter the midi input before it gets to the receiver?
> Could it be something else?
> -My last question concern something else.
> I wanted to try the new environments example of s7 and after downloading the newest tarball for Grace I keep becoming those errors :
>>>> Error: environment-ref: unbound variable
>>>> Error: open-environment: unbound variable
> I don't use or need snd but it would be great to access those functions in Grace. Do you know how I could do that?
> Thank you very much for your time and your patience and even more for your software : I couldn't have done this piece without Grace!
> Best regards,
More information about the Cmdist