< Back to IRCAM Forum

Code equivalent of pressing "v" to evaluate an instance?

Is there an easy functional, written code equivalent to pressing “v” to evaluate an instance in OM? In other words, if I somehow knew the name of an instance, is there an easy way to write a function that looks something like
(defun push-v (name-of-instance) (something that does the same thing as pushing v on name-of-instance)) ?
Or , put another way, bypassing the visual interface. (As you might guess, I’m dealing with a dynamic instance, an unlocked box, linked to code, that renders differently upon successive evaluations) In this case, I see that the picture is always called “PICTURE 2” when I examine the lisp file of the patch, but of course the Listener shows the different renderings when I evaluate.

OM => #<picture 200AF35F>
OM => #<picture 200B7ABF>
OM => #<picture 2980B09F>
etc

Thanks in advance!

evaluating-a-box.png

Hi, I beleive you spotted a bug in OM here.

But first, you’re possibly confusing instances, viz. the result of evaluating a function (patch), and the function itself, viz. the whole graph connected to the inputs of whatever you’re asking to evaluate?

I’m dealing with a dynamic instance, an unlocked box, linked to code

Which, when you hit ‘v’ makes up a function, and evaluates this, returning the result at the bottom.

Functions in OM are visual, and not coupled to symbols, as in CL. They don’t have a name.

And here’s the bug (possible, it might be a design choice). In lack of symbols you could store an anonymous function (in lambda mode) in a list or somewhere, and call it using #'funcall. However, this doesn’t work in OM as it would in Lisp. When i #'funcall the stored function in OM, it hasn’t encapsulated the connected call graph, only the return-values from the connected inputs.

In lisp, this is ok:

(setf foo (list  
	   #'(lambda ()  
	       (om+ 100 (om-random 10 30)))))  

(funcall (first foo))

but the same thing in OM (screenshot) doesn’t work, om-random isn’t encapsulated, only it’s return value.

Skjermdump-fra-2019-02-19-15-52-54.png

Hi there! I don’t think I understood the original question, but maybe can say something about @anders’ last point on lambda:
=> when you put a box in lambda mode, you sort of wrap a lambda around it, and include the values of connected boxes in it (unconnected inputs are the variables/arguments of the lambda expression). If you want to include the random and more functions in the lambda, then you shoulnd first embed them all in a patch and set the patch to lambda.
Jean

Right. I’m sure you’ve explained this to me before, i’ll try to remember… :slight_smile:

To OP, i don’t know if you find it ‘an easy way’, but if you do something like this:

(defvar *cur-panel* nil)  

(defmethod handle-key-event :before ((self patchPanel) char)  
  (setf *cur-panel* self))

Then, after first evaluating once in the normal way, ie. using “v” in your patch, you can call
(handle-key-event cur-panel #\v)
in your code, which should do the same thing as pushing “v” did in the first place.

Anders and Jean, thanks much for the responses! I’m going to study this, play around with Anders’ solution , and also try to reformulate my original post with more accurate language. Will check back in soon… Again, much appreciated!

Anders, tried your code and it worked great! Thanks!