canvas_refresh() not working like described

Canvas specific discussion
Post Reply
ClarkyCat
Newbie
Posts: 6
Joined: 22 May 2019 20:36

canvas_refresh() not working like described

Post by ClarkyCat »

Why doesn't canvas_refresh() doesn't work on its own from within a script?

I am trying to make a Canvas object template and a foundation starting point for canvas objects.
When trying to initialise the canvas via canvas_refresh(), the script does not compile.

But when I declare a variable inside the script and make the canvas_refresh() refer to the declaration variable, it works?

So,

Create script > Manual Execution > Touch - Multitouch > Redraw - On demand

Inside Canvas object create a script called 'Test'

Inside script write:
canvas_refresh();

This does not work.

But when you write,

decl this = getobject();
canvas_refresh(this);

The script compiles fine. Why does this happen?

Why is it not possible to manually call canvas_refresh() from it's own script?
--Beatbox Loop Artist--

2 x KP3+, RC-505, Behringer FCB1010, Turnado, Looperator, The Mouth,The Finger, Lemur, i5 Mid-2012 Macbook Pro
midikinetics
Regular
Posts: 66
Joined: 15 May 2015 17:46
Contact:

Re: canvas_refresh() not working like described

Post by midikinetics »

Great question, OP. It sounds like you might be coming from an object-oriented programming (OOP) background.

In OOP, an object exposes a set of methods that you call directly on it, for example:

Code: Select all

canvas.refresh();
canvas.fill();
canvas.stroke();
However, Lemur’s scripting language is not object-oriented: It is more like the C programming language. Objects do not define the set of operations available on them. Instead, functions are defined globally, and you must pass the object to be operated on. The runtime then checks whether the operation is valid for the object you passed.

So the reason your script didn’t compile is that there is no method canvas_refresh() that takes no arguments. There is only the global function canvas_refresh(canvas) that expects you to pass the canvas object as an argument.

Code: Select all

canvas_refresh(canvas)
Cheers
ClarkyCat
Newbie
Posts: 6
Joined: 22 May 2019 20:36

Re: canvas_refresh() not working like described

Post by ClarkyCat »

Ahh I see! Thankyou for the explanation. I am indeed coming from an OOP background, Lemur is what got me into this style of scripting. I'm trying to improve my understanding so I can make more fun/complex templates.

Currently trying to somehow get Lemur to render a real-time audio waveform without throttling the memory limits and frame rate.
I love the limitations of Lemur, especially when first learning, because it forces you to truly understand the syntax and encourages efficient scripting. Which I'm learning is a life long journey lol

I have tried the Lemur Waveform canvas template from the old User Library but I can't seem to be able to present to Lemur the right data in the right form. I'm using OSC to send data from an audio envelope follower in Ableton to Lemur. The old waveform template comes with it's own max for live patch which is too old to run on up to date systems.

So I've decided to try and make Lemur render a scrolling horizontal waveform display, similar to the Signal Scope object, just with a higher resolution and x,y,z touch elements to interact with.

I'm finding it a real challenge to figure it out, I'll get there one day, just chipping away at each mini hurdle one after another...
--Beatbox Loop Artist--

2 x KP3+, RC-505, Behringer FCB1010, Turnado, Looperator, The Mouth,The Finger, Lemur, i5 Mid-2012 Macbook Pro
Post Reply