2nd: lower max voice count (or parameterize)
engine.maxVoices(10)

i can fix the inconstistency of the klang- and noise- type algos upstream. (mapping the mod range, and mixdown before the application of pan.) but these are not crashing the main process.
(as an aside, the ‘klang’ algos also produce more noticeable artifacts when attack time = 0. this is because they do not engage a lowpass filter after the amplitude envelope, like most others do; instead the spectral range is limited explicitly in the additive synthesis spec.)

as far as your script performance, it is hard to ask us to review 4k lines in one file with few comments. (wheras the engine code i provided is only a couple hundred LOC and i made it as clear as i could, so i hope it can be understood well enough to allow you to modify it yourself.)

re: memory leaks: in general, memory leaks are not likely from the lua layer, which is garbage-collected. however, excessive allocation means the GC can’t keep up and this is the biggest cause of performance hits in lua; in extreme cases it can crash with an allocation failure.

at a glance i can see quite a few ways your script could be refactored to do less work on the main clock tick, but i don’t think this is a show stopping issue based on the core usage reported by top. (instead, i am seeing high usage not just in the DSP on scsynth process, but in sclang process which is marshalling the large amount of OSC traffic generated by the script. [we are also being rather rude by asking it to dynamically recompile a synth graph specification on every note; this would be an obvious place for optimizing the engine but would also limit / complexify the kinds of decisions that can be made at note creation time.] when usage for these processes creeps above 50-60%, one is likely to encounter audible artfiacts and possibly strange behavior like dropped events.)

specifically, i’d strongly recommend putting all screen drawing calls in one function and making sure this is called at a sustainable pace and ultimately all from the redraw function, which is specially managed by the system.

memory leaks in the C layer are of course a possibility. i regularly stress-test the system with valgrind/massif and timing-heavy scripts, and the C layer is not really that complicated, but the platform can do many things so it is always possible.


i should say that the most common cause of “mysterious” crashes i have seen, is running out of battery with the screen dimmed. in performance contexts we always recommend booting norns without the wifi peripheral: saving power, reducing CPU load and reducing noise. (i have found that heavy scripts, especially with lots of screen activity [or driving hungry peripherals] can induce some constant drain on the battery even when connected to wall power.)


in the situation shown by @sademik, the supercollider processes are still running and are not the problem. either the UI is in an unresponsive state for whatever reason (the structure of the drawing calls is a likely culprit), or the matron process has crashed.

if holding down K1+K2+K3 for >10s induces a soft-reset, then matron is not crashed and the problem is that the UI is just stuck. if the combo doesn’t work then it is likely a crash.

3 Likes

i’ll replicate the crash and then give the K1+K2+K3 for >10s combo a shot to see whether or not matron has crashed; will report back with results.

i’ve now encountered a crash within 30m or so of running the script. matron process is gone, so it’s a crash indeed. other processes seem fine. we’ll investigate

2 Likes

out of curiosity, since i couldn’t find any when using sftp to comb through /home/we, are there any sort of logs generated upon a system related crash? information that wouldn’t be reported by matron?

not really. a more robust watchdog process would be helpful and i may add it to GH issue list

(

  • this isn’t a “system crash” in the sense of a kernel panic, so we don’t have that kind of log. a userspace executable exited. a wizard could get the backtrace from a core dump but i’m definitely too tired to figure that out; maybe good feature for that watchdog issue.
  • i’m actually having trouble this moment with getting anything useful from the matron service logs etc, b/c stdout is being redirected to websocket. i may be forgetting the workaround for this.
  • so, trying to repro again without the websocket, and might try again with gdb.
    )

that debug life

1 Like

Thanks for thorough response. I’ll work on getting all of the screen updates into the redraw loop. I’ve also rolled my Norns back to 201115 out of curiosity as I don’t recall having this issue before. Could be that I just never triggered it perhaps. My script ran for an hour and fifteen minutes last night with no issues on 201115. I’ll see how it does today.

EDIT:
Well … my third attempt at crashing pixels on 201115 was successful. This time, it froze and the UI became unresponsive. Matron wouldn’t connect, but I could see the norns via ssh and htop.

@zebra traced a crash to a bad value fed into screen.level

i’ve pushed a fix to clamp values (to prevent crashing) in the screen drawing library

in the mean time (before the next norns update) i’d suggest your script makes sure any values passed to screen.level are certainly 0-15


there may be other problems, of course

3 Likes

Thanks for the support! I’ve been working on moving all of the screen calls into the redraw loop. I should be able to push out a fix for that today.

… and of course there could be other problems.

My first test corralling all of the screen calls into the redraw loop has been promising. Pixels has been running for several hours now without hanging. Part of this was consolidating all of the the “note to screen.level” math. This could have been where a pixel had a nil or non 0-15 value before. It’s all clamped 0-15 now.

1 Like

Version 1.1.1 is released!

This release is mostly a bug fix that moves all screen activity into the redraw loop where it belongs. Incorrect values for the display level seem to be the culprit for the “I’ve been droning on this for more than 20 minutes” freeze people have been experiencing.

Let’s hope we’re past it now.

Many thanks to @zebra, @tehn, @sademik and @spike for bringing this to my attention and helping me through this.

8 Likes

Version 1.1.2 - sneak update.

Found and corrected additional areas of screen.level clamping.

2 Likes

will give it a shot on my system when i get home from work!

1 Like

good news! problem seems to be solved. i’ve had pixels droning for ~2 hours now with no hiccups. great job! thanks for the fix :relieved:

1 Like

I was not expecting to like this as much as I do. Like? More like love! Pixels is fantastic! The built-in synths sound really good!

Here’s a fun jam I recorded using the Digitone for effects.

5 Likes

This is a lovely script. I let it play in the background for a few hours this morning, looking forward to try it with MIDI tonight.

I was thinking about custom-made maps. Would be cool if they could be specified as ASCII maps/art, but it is not simple to sort 127 characters based on their luminosity, depends on the font and so on. However, since PNG to ASCII art converters do exist, that might be one angle to tackle your initial challenge @distropolis.

1 Like

@Quixotic7 - nice! Are you only using the built in synths? Sounds like the rez engine doing some percussion there. @zebra did a great job with the synth engines I’m using in the script!

@vehka It’s a blast with external gear for sure! I had originally intended to have the script be able to import PNG data and convert it into a “music map” but I couldn’t get any of the image libraries running on the norns. I ended up just using some math to create the maps -> filling a 2D array with values from 0-127. There is a SECRET MODE which allows for some additional (experimental) functionality … but it hasn’t been announced or discovered. It won’t fulfill your ASCII desires but it will open some new possibilities.

:]

1 Like

@distropolis I was using the built in synths and also 1 Digitone synth. I think two tracks used the Rez engine.

1 Like

Here’s a clip of a small jam I had with Pixels and a Digitone last night.

https://www.instagram.com/p/CIpnJ8gBtqhlw1bFFzfwO92lJImo1LvEfvFemA0/

2 Likes

Nice! Are all of the sounds coming from the Digi?

1 Like

Digitone and Pixels go so nicely together!

3 Likes