Memory problems with Image
Hello.
I have a JSUI object that is 500 pixels wide and is used to draw a waveform. The waveform data comes from an MXJ object as a list of 500 points.
My JSUI is also capable of displaying markers on top of the waveform.
Currently markers and waveform are drawn in a separate sketch to avoid redrawing the whole waveform each time a marker is moved.
In order to see the waveform I need to copy the markers sketch as an image and perform an alphachroma on the white pixels. I then copy both the waveform sketch and marker sketch in the main sketch using copypixels.
The problem is that each time I add a marker my RAM usage increments by about 1 meg ! This makes the object unusable beyond 40 markers ! This seems to happen only with the new Image method, if I draw my markers as a normal sketch the memory usage is fine. But the problem is that I need transparency for my marker sketch to see the waveform, is there a way using the sketch object to do the same thing ?
Thanks a lot.
the freepeer() method did the trick.
I'd still be curious to know if there's a way to do the same thing using a sketch instead of image though.
Thanks,
Nat
The main thing is that I want to be able to draw the markers without having to redraw the waveform each time (example, if I want to move a marker I'd like to redraw only the marker sketch, not the waveform) I'd have to do some performance tests though, it might not be as intensive as I think.
Precisely, just cache the waveform in a Sketch or Image, and then
when drawing for display, copy the cached waveform pixels to the
output sketch, and draw the markers on top. Or am I missing something?
-Joshua
I guess it makes sense,
My brain gets slower as the end of the semester and deadlines approach :)
The real speed issue I have is with calculating the peaks of the waveform to draw. I do it in Java now instead of JSUI but it gets really slow with longer sounds. I divide the buffer into 500 regions (because the JSUI window is 500 pixels wide) and find the max for each region. I did not try to use jitter yet as there would be a lot of re-learning to do but will eventually get to it unless there is a more clever way in Java (which I'm sure there is)
Thanks for the help !