debuging

21 views
Skip to first unread message

Hairi Vogel (airi)

unread,
Nov 20, 2022, 5:50:19 PM11/20/22
to PraxisLIVE discussion group
Hi.
i cannot figure out why statements like System.out.println(...) , processing.println(...) and log(...,...) sometimes print in the output tab , sometimes not at all
it is nagging me as I am learning by debugging :-)
h

Neil C Smith

unread,
Nov 21, 2022, 4:44:09 AM11/21/22
to praxi...@googlegroups.com
Hi,

On Sun, 20 Nov 2022 at 22:50, Hairi Vogel (airi) <hairi...@gmail.com> wrote:
> i cannot figure out why statements like System.out.println(...) , processing.println(...) and log(...,...) sometimes print in the output tab , sometimes not at all
> it is nagging me as I am learning by debugging :-)

Yes, this is slightly confusing! And will be a little simpler in v6.

As mentioned previously, PraxisLIVE uses multiple processes - so by
default your video pipeline will be running in a different Java
Virtual Machine to the IDE itself. System out is the output from the
child process, log will send it in a message to the parent process.

You should see multiple output tabs, one for each child process named
after the project, and others named for the root (eg. video). System
out should appear in the child process tab, log messages will appear
in the root named tab.

If you have a root that's running in the IDE process, so anything not
audio or video (by default), then the NetBeans code also suppresses
system out, so you'll never see it.

Short answer! Use log(), with log(INFO, "message");

And in v6 the aim is to consolidate all of this into a single output
tab per project.

Other good tip for debugging is to use a temporary property, possibly
with Config.Preferred, and just set the value - this will show on the
graph.

eg.

@P(1000)
@Config.Preferred
String debug;

Best wishes,

Neil

Hairi Vogel

unread,
Nov 21, 2022, 10:13:13 AM11/21/22
to praxi...@googlegroups.com
Il giorno lun 21 nov 2022 alle ore 10:44 Neil C Smith <ne...@neilcsmith.net> ha scritto:
Hi,

On Sun, 20 Nov 2022 at 22:50, Hairi Vogel (airi) <hairi...@gmail.com> wrote:
> i cannot figure out why statements like System.out.println(...) , processing.println(...) and log(...,...) sometimes print in the output tab , sometimes not at all
> it is nagging me as I am learning by debugging :-)
 
Short answer!  Use log(), with log(INFO, "message");

Hooray, that's all I need. I also started saving data to textfiles for debug

And in v6 the aim is to consolidate all of this into a single output
tab per project.
This sounds like a lot of work for .... if ever:

I prefer to overlay the debug data onto video.
 
Question (may be Dummies):
I am used to write classes to group data and specific ways to interpret and process it.
How can I do that in the IDE. I write the classes as normal Java xxx.java textfiles. They shall
be compiled and it shall be possible to access them from the component code.
(import or so).
It should be possible to import packages of your code.
 
Other good tip for debugging is to use a temporary property, possibly
with Config.Preferred, and just set the value - this will show on the
graph.

eg.

 
@P(1000)
@Config.Preferred
String debug;
Thanks. Where the heck should I have read what @Config.Preferred means ??

best whishes
hairi



 

Neil C Smith

unread,
Nov 21, 2022, 11:24:14 AM11/21/22
to praxi...@googlegroups.com
On Mon, 21 Nov 2022 at 15:13, Hairi Vogel <hairi...@gmail.com> wrote:
> Il giorno lun 21 nov 2022 alle ore 10:44 Neil C Smith <ne...@neilcsmith.net> ha scritto:
>> Short answer! Use log(), with log(INFO, "message");
>>
> Hooray, that's all I need. I also started saving data to textfiles for debug

Great!

>> And in v6 the aim is to consolidate all of this into a single output
>> tab per project.
>
> This sounds like a lot of work for .... if ever:

Not really, in fact it's half removing code, and it's necessary for
some other changes.

> Question (may be Dummies):
> I am used to write classes to group data and specific ways to interpret and process it.
> How can I do that in the IDE. I write the classes as normal Java xxx.java textfiles. They shall
> be compiled and it shall be possible to access them from the component code.
> (import or so).

There are two options. Write a library outside of the IDE
(currently), compile it and use it.

Or, use the shared code functionality documented at
https://docs.praxislive.org/coding-shared/ You can only share code
across components in the same graph. You can of course copy the
source file into another graph.

> Thanks. Where the heck should I have read what @Config.Preferred means ??

It appears you can't because I forgot to document it when it was
added! :-\ It is meant to be listed at
https://docs.praxislive.org/coding-annotations-extra/

Basically, by default, only properties marked with that will show on
the graph component.

You can also right-click on the graph and choose Properties -> Show all.

Best wishes,

Neil

Hans Heinrich Vogel

unread,
Nov 22, 2022, 5:50:53 AM11/22/22
to praxi...@googlegroups.com
Hi Neil.
I am getting somewhere and enjoying it.
Thanks for your marvellous support.

I got a Preset System functioning that requires standard code in every component that
wants to use it. Some Property, methods and fields.

To make that as simple as possible I define some classes.
I am using shared code now for proof of concept and debug.
I tried making a simple library (a .class file in a .jar) and was able to import it
in project properties and use it from the component code. GOOD.
I can use eclipse for writing and compiling the code. Or text editor and command line.

In both cases I should know what classpath to use in order to access your types in my classes. (import )

AM I SEEING THIS CORRECTLY ??

Another, small but quirky: As every good beginner I made a mess in the components palette and exported
components with silly names and put them in silly places. I thought when I move the components from their folder,
they might disappear in the palette. NO way.
So, where are they ? How can I reset or manage the palette ??
A well set palette is a small item but very useful in live programming as it gives me ideas and makes me make mistakes.

Thanks.
Have a nice time
Hairi
> --
> You received this message because you are subscribed to the Google Groups "PraxisLIVE discussion group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to praxis-live...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/praxis-live/CAMYaZEuhw6_UgTmxghQkgRSGE3SN7QijCO0OPxJ_vbwxnio2MA%40mail.gmail.com.

Neil C Smith

unread,
Nov 22, 2022, 8:48:31 AM11/22/22
to praxi...@googlegroups.com
On Tue, 22 Nov 2022 at 10:50, Hans Heinrich Vogel <hairi...@gmail.com> wrote:
> I am getting somewhere and enjoying it.
> Thanks for your marvellous support.

Great to hear! :-) And, you're welcome.

> To make that as simple as possible I define some classes.
> I am using shared code now for proof of concept and debug.
> I tried making a simple library (a .class file in a .jar) and was able to import it
> in project properties and use it from the component code. GOOD.
> I can use eclipse for writing and compiling the code. Or text editor and command line.

Either way should work for you - depends if you want to be able to
recode any of the shared code.

And of course, you could always use NetBeans for this too! ;-) I'm
biased, given that PraxisLIVE is built on top of it, and it's another
open source project I'm actively involved in.

Actually, we should consider whether some of this ability to export to
a JAR should be in PraxisLIVE, given it's supported by the underlying
NetBeans platform.

> In both cases I should know what classpath to use in order to access your types in my classes. (import )
>
> AM I SEEING THIS CORRECTLY ??

You need to add import lines between the Default Imports and Class
Declaration collapsed sections.

The easiest way is usually to start typing the name of the class,
click CTRL-SPACE for code completion, then CTRL-SPACE again to search
for non-imported classes. The import should usually be added
automatically.

Any code in the shared code section is always in a package called
SHARED, so you can also use `import SHARED.*:` for all shared code
classes.

The text SHARED in the code actually changes how things are compiled -
if you're interested at all the technical side of how this works it's
at https://www.praxislive.org/blog/classloader-trees/

> Another, small but quirky: As every good beginner I made a mess in the components palette and exported
> components with silly names and put them in silly places. I thought when I move the components from their folder,
> they might disappear in the palette. NO way.
> So, where are they ? How can I reset or manage the palette ??
> A well set palette is a small item but very useful in live programming as it gives me ideas and makes me make mistakes.

Right click in the Palette window, and choose Palette Manager. Or
just right-click on an added component and click remove.

If you're adding new categories, be aware that only categories
starting with core: or video: will show up in the palette or menu in a
video graph.

Best wishes,

Neil

Hairi Vogel

unread,
Nov 28, 2022, 1:53:29 PM11/28/22
to praxi...@googlegroups.com
Hi Neil.
Just stuck with this:
how to load a Folder of .jpg (or any image format) files into a List of PImages ???
it is the strange loadImage(path) in Processing

I am working on the video-delay, i need a video-looper type thing that can scratch
for now i am hardcoding dozens of @OffScreen PGraphics b1.....
mimicking what the frame-delay component does.
i actually only need max 2 seconds for now. RAM is not an issue I got 64GB.

any clue ??

thanks
h


--
You received this message because you are subscribed to the Google Groups "PraxisLIVE discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to praxis-live...@googlegroups.com.

Neil C Smith

unread,
Nov 29, 2022, 4:35:11 AM11/29/22
to praxi...@googlegroups.com
Hi,

On Mon, 28 Nov 2022 at 18:53, Hairi Vogel <hairi...@gmail.com> wrote:
> Just stuck with this:
> how to load a Folder of .jpg (or any image format) files into a List of PImages ???
> it is the strange loadImage(path) in Processing
>
> I am working on the video-delay, i need a video-looper type thing that can scratch
> for now i am hardcoding dozens of @OffScreen PGraphics b1.....
> mimicking what the frame-delay component does.
> i actually only need max 2 seconds for now. RAM is not an issue I got 64GB.
>
> any clue ??

OK, this is a fun one. Some of the resource loading is a little
hidden, so I needed to come up with a utility class that you can add
into the shared code space.

You then need to use an advanced feature on Ref types to async compute
(ie. background load) the list of images in the component.

Code for both below - hope it makes some sense. Note the glob pattern
in the image loader for *.jpg - change that if you need something
else.

Incidentally, the other possible way to do this might be to adapt a
video:capture component to use the GStreamer multifilesrc -
https://gstreamer.freedesktop.org/documentation/multifile/multifilesrc.html?gi-language=c

Best wishes,

Neil


#### SHARED.ImageFolderLoader class

package SHARED;

import java.util.ArrayList;
import java.util.List;
import org.praxislive.core.types.PResource;
import org.praxislive.video.pgl.PGLContext;
import org.praxislive.video.pgl.code.userapi.PImage;
import org.praxislive.video.render.Surface;
import org.praxislive.video.render.utils.BufferedImageSurface;
import java.nio.file.Files;
import java.nio.file.Path;

public class ImageFolderLoader {

public static List<PImage> loadImages(PResource folder) {
List<PImage> list = new ArrayList<>();
try (var files =
Files.newDirectoryStream(Path.of(folder.value()), "*.jpg")) {
for (var file : files) {
list.add(new
PImageImpl(BufferedImageSurface.load(file.toUri())));
}
} catch (Exception ex) {}
return list;
}

private static class PImageImpl extends PImage {

private final Surface surface;

private PImageImpl(Surface surface) {
super(surface.getWidth(), surface.getHeight());
this.surface = surface;
}

@Override
protected processing.core.PImage unwrap(PGLContext context) {
return context.asImage(surface);
}

}

}

#####################################


#### Example component code

@P(1) @OnChange("loadImages") PResource folder;
@T(1) boolean next;

@Inject Ref<List<PImage>> images;
@Inject int index;

@Override
public void setup() {
images.init(ArrayList::new);
loadImages();
}

@Override
public void draw() {
if (next) {
index++;
next = false;
}
List<PImage> list = images.get();
if (list.isEmpty()) {
index = 0;
} else {
index %= list.size();
image(list.get(index), 0, 0, width, height);
}
}

private void loadImages() {
if (folder != null) {
images.asyncCompute(folder, SHARED.ImageFolderLoader::loadImages);
} else {
images.ifPresent(List::clear);
}
}

########################################

Hans Heinrich Vogel

unread,
Nov 30, 2022, 3:38:02 AM11/30/22
to praxi...@googlegroups.com
flawless it is. :-)
for the record: it is possible (with < 20% sweat on the machine I use), to move and rotate and resize 2000 images simultaneously.
swarms.
i resisted the temptation to just add another zero to the number, out of respect for the art.

it is amazing when compared to processing or Isadora , it is 500 times better or more.
and it is much more fun to work under open-source live-programming conditions.

I used the ol´SuperCollider to help me write 120 @OffScreen PGraphics … and vector.add(… lines of code for a 2 seconds video looper.
it looks scary, but it works just fine.

as for debuggging:
the debug property trick is very valid. quick to apply.
the log(INFO,…) shows up under all conditions, good.
i made a onscreen data overlay component, smooth
i also made a 4 channel oscilloscope , i need that to understand my math.
btw, it shows the perfect sync of all operations in PraxisLive, impressive.


thanks
hairi
> --
> You received this message because you are subscribed to a topic in the Google Groups "PraxisLIVE discussion group" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/praxis-live/AgtFBSpShA0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to praxis-live...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/praxis-live/CAMYaZEte4tkvXV28ZdWqkW7zHfGZkaJQ8cfy26D2c9hj401QyQ%40mail.gmail.com.

Neil C Smith

unread,
Nov 30, 2022, 6:25:32 AM11/30/22
to praxi...@googlegroups.com
On Wed, 30 Nov 2022 at 08:38, Hans Heinrich Vogel <hairi...@gmail.com> wrote:
> flawless it is. :-)
> for the record: it is possible (with < 20% sweat on the machine I use), to move and rotate and resize 2000 images simultaneously.
> swarms.
> i resisted the temptation to just add another zero to the number, out of respect for the art.

Good to know.

> it is amazing when compared to processing or Isadora , it is 500 times better or more.
> and it is much more fun to work under open-source live-programming conditions.

There's some tricks under the hood, but it shouldn't be that much
better than Processing - it is using Processing code still, although
with different OpenGL binding.

> I used the ol´SuperCollider to help me write 120 @OffScreen PGraphics … and vector.add(… lines of code for a 2 seconds video looper.
> it looks scary, but it works just fine.

You know that the .code property on a component is just text? You can
also write the code generation in one component and send it as a
String to another one using tell(..)

https://javadoc.io/static/org.praxislive/praxiscore/5.4.0/org.praxislive.code/org/praxislive/code/CodeDelegate.html#tell(org.praxislive.core.ControlAddress,java.lang.String)

That can be fun!

> as for debuggging:
> the debug property trick is very valid. quick to apply.
> the log(INFO,…) shows up under all conditions, good.
> i made a onscreen data overlay component, smooth
> i also made a 4 channel oscilloscope , i need that to understand my math.
> btw, it shows the perfect sync of all operations in PraxisLive, impressive.

I would love to see what you're building some time! Do share some
videos, etc. somewhere if/when you can.

Best wishes,

Neil

Hans Heinrich Vogel

unread,
Nov 30, 2022, 2:10:05 PM11/30/22
to praxi...@googlegroups.com

>
> You know that the .code property on a component is just text? You can
> also write the code generation in one component and send it as a
> String to another one using tell(..)
>
> https://javadoc.io/static/org.praxislive/praxiscore/5.4.0/org.praxislive.code/org/praxislive/code/CodeDelegate.html#tell(org.praxislive.core.ControlAddress,java.lang.String)
>
> That can be fun!
>

i was already tempted to generate code, but then realized i have to go deeper in what is already there.

@OnScreen could allow (final?) arrays of PGraphics instances, as my example shows.


>
> I would love to see what you're building some time! Do share some
> videos, etc. somewhere if/when you can.
>
i will share results and all code sometime soonish

Be well
Hairi





> Best wishes,
>
> Neil
>
> --
> You received this message because you are subscribed to the Google Groups "PraxisLIVE discussion group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to praxis-live...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/praxis-live/CAMYaZEsw_k0cTQcbukB8ZJ0A-_VsJVpFBO%2B5_6TRKG7JckmN8g%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages