Running v4.4.0 on Windows
Summary: Sonic Pi seems to crash, without any error messages, upon reaching a certain amount of text in the editor window
My code is pretty simple: there is a draw function which takes arrays of numbers to light up LEDs via sysex messages. There is a sleep
command inside the draw function. I was using one large case
within a live_loop
to store and switch between lighting patterns, like so:
case animation
when 0
draw [104, 11, 12, 4, 5], [99, 21, 19, 20, 18, 30, 25, 31, 24, 27, 28, 37, 32, 38, 33, 34, 39, 35, 36, 41, 40, 46, 47, 52, 53, 51, 50, 54, 58, 49, 61, 60, 59, 17, 22]
draw [13, 26], [104, 12, 4, 5, 11], [99, 17, 18, 19, 20, 21, 22, 28, 27, 30, 31, 24, 25, 35, 36, 33, 32, 38, 39, 34, 37, 46, 40, 41, 47, 51, 52, 49, 50, 53, 54, 58, 59, 60, 61]
draw [15, 26], [104, 11, 12, 4, 5], [99, 19, 17, 20, 21, 18, 22, 27, 25, 24, 28, 31, 30, 33, 36, 39, 32, 35, 34, 37, 38, 40, 46, 47, 41, 49, 50, 54, 53, 52, 51, 59, 60, 58, 61]
draw [13, 26], [104, 12, 4, 5, 11], [99, 17, 18, 19, 20, 21, 22, 28, 27, 30, 31, 24, 25, 35, 36, 33, 32, 38, 39, 34, 37, 46, 40, 41, 47, 51, 52, 49, 50, 53, 54, 58, 59, 60, 61]
draw [104, 11, 12, 4, 5], [99, 21, 19, 20, 18, 30, 25, 31, 24, 27, 28, 37, 32, 38, 33, 34, 39, 35, 36, 41, 40, 46, 47, 52, 53, 51, 50, 54, 58, 49, 61, 60, 59, 17, 22]
draw [13, 29], [104, 11, 12, 4, 5], [99, 19, 20, 22, 21, 18, 17, 31, 24, 28, 27, 25, 30, 33, 32, 39, 36, 34, 35, 37, 38, 40, 46, 47, 41, 52, 51, 53, 50, 49, 54, 59, 60, 58, 61]
draw [15, 29], [104, 11, 12, 4, 5], [99, 18, 21, 20, 19, 22, 17, 25, 27, 28, 30, 31, 24, 39, 36, 33, 32, 37, 38, 35, 34, 41, 46, 40, 47, 50, 53, 51, 52, 49, 54, 59, 58, 60, 61]
draw [13, 29], [104, 11, 12, 4, 5], [99, 19, 20, 22, 21, 18, 17, 31, 24, 28, 27, 25, 30, 33, 32, 39, 36, 34, 35, 37, 38, 40, 46, 47, 41, 52, 51, 53, 50, 49, 54, 59, 60, 58, 61]
when 1
draw [104, 11, 12, 4, 5], [99, 19, 20, 18, 21, 24, 31, 28, 27, 25, 30, 32, 38, 37, 34, 35, 39, 33, 36, 40, 41, 46, 47, 49, 52, 51, 53, 50, 54, 60, 58, 59, 61, 22, 17]
draw [104, 11, 12, 4, 5], [99, 17, 18, 19, 20, 21, 22, 24, 31, 30, 33, 32, 39, 36, 35, 37, 38, 34, 46, 40, 47, 51, 50, 52, 53, 59, 49, 54, 58, 61, 60, 29, 26, 45, 44, 28]
draw [104, 11, 12, 4], [99, 17, 19, 18, 20, 21, 22, 30, 29, 28, 33, 35, 36, 38, 37, 34, 44, 45, 46, 49, 51, 52, 54, 53, 50, 58, 61, 59, 60, 27, 43, 25, 39, 47, 31]
draw [104, 11, 12, 3], [99, 17, 19, 20, 18, 21, 22, 25, 28, 27, 30, 26, 36, 35, 33, 37, 34, 38, 29, 42, 41, 44, 46, 45, 43, 53, 51, 50, 52, 58, 60, 59, 61, 49, 54, 47, 31, 39]
draw [104, 11, 12, 3, 2], [99, 22, 20, 18, 17, 19, 21, 25, 24, 28, 30, 27, 26, 29, 32, 35, 36, 33, 39, 37, 38, 34, 31, 47, 43, 44, 45, 41, 46, 40, 42, 51, 50, 53, 52, 49, 54, 58, 59, 60, 61]
draw [104, 11, 12, 3], [99, 17, 18, 19, 20, 22, 21, 28, 30, 27, 25, 29, 24, 26, 33, 32, 36, 35, 37, 38, 34, 40, 41, 44, 45, 43, 42, 46, 49, 50, 51, 52, 53, 54, 59, 58, 60, 61]
draw [104, 11, 12, 4], [99, 17, 19, 18, 20, 22, 21, 24, 25, 28, 27, 26, 30, 33, 36, 35, 32, 37, 38, 34, 40, 41, 43, 44, 42, 49, 51, 52, 50, 53, 54, 58, 59, 60, 61]
draw [104, 11, 12, 4, 5], [99, 17, 19, 18, 20, 21, 22, 24, 25, 31, 27, 29, 26, 35, 36, 33, 34, 32, 37, 38, 39, 43, 40, 41, 47, 42, 49, 52, 54, 50, 51, 53, 61, 59, 60, 58]
when 2
...
This all worked just fine - no problems, errors or inconsistencies whatsoever. So I set about writing more patterns, placing each within a new when
condition. I was pasting them in from outside Sonic Pi or copying/pasting and modifying text from the previous when
section.
After pasting the 5th pattern or so, the editor just hanged and I had to quit. There were no error messages or anything. Upon re-opening, the code was missing the most recent text pasted in. It seems to crash without even running the code in question. I combed the text, made sure there were no problems, weird characters, or unusual formatting, and still the editor became unresponsive whenever I reached a certain threshold of text.
The code isn’t huge or anything: about 150 lines - half of which are like the above array lists.
I thought I was pasting too much text at once, so I did it line by line, but it still froze after a point.
I thought maybe the blocks of text were too much for a single case
to contain, and I completely rewrote the section with the different animations stored in their own define
like this:
define :pattern_1 do
draw [104, 11, 12, 4, 5], [99, 21, 19, 20, 18, 30, 25, 31, 24, 27, 28, 37, 32, 38, 33, 34, 39, 35, 36, 41, 40, 46, 47, 52, 53, 51, 50, 54, 58, 49, 61, 60, 59, 17, 22]
draw [13, 26], [104, 12, 4, 5, 11], [99, 17, 18, 19, 20, 21, 22, 28, 27, 30, 31, 24, 25, 35, 36, 33, 32, 38, 39, 34, 37, 46, 40, 41, 47, 51, 52, 49, 50, 53, 54, 58, 59, 60, 61]
draw [15, 26], [104, 11, 12, 4, 5], [99, 19, 17, 20, 21, 18, 22, 27, 25, 24, 28, 31, 30, 33, 36, 39, 32, 35, 34, 37, 38, 40, 46, 47, 41, 49, 50, 54, 53, 52, 51, 59, 60, 58, 61]
draw [13, 26], [104, 12, 4, 5, 11], [99, 17, 18, 19, 20, 21, 22, 28, 27, 30, 31, 24, 25, 35, 36, 33, 32, 38, 39, 34, 37, 46, 40, 41, 47, 51, 52, 49, 50, 53, 54, 58, 59, 60, 61]
draw [104, 11, 12, 4, 5], [99, 21, 19, 20, 18, 30, 25, 31, 24, 27, 28, 37, 32, 38, 33, 34, 39, 35, 36, 41, 40, 46, 47, 52, 53, 51, 50, 54, 58, 49, 61, 60, 59, 17, 22]
draw [13, 29], [104, 11, 12, 4, 5], [99, 19, 20, 22, 21, 18, 17, 31, 24, 28, 27, 25, 30, 33, 32, 39, 36, 34, 35, 37, 38, 40, 46, 47, 41, 52, 51, 53, 50, 49, 54, 59, 60, 58, 61]
draw [15, 29], [104, 11, 12, 4, 5], [99, 18, 21, 20, 19, 22, 17, 25, 27, 28, 30, 31, 24, 39, 36, 33, 32, 37, 38, 35, 34, 41, 46, 40, 47, 50, 53, 51, 52, 49, 54, 59, 58, 60, 61]
draw [13, 29], [104, 11, 12, 4, 5], [99, 19, 20, 22, 21, 18, 17, 31, 24, 28, 27, 25, 30, 33, 32, 39, 36, 34, 35, 37, 38, 40, 46, 47, 41, 52, 51, 53, 50, 49, 54, 59, 60, 58, 61]
end
define :pattern_2 do
draw [104, 11, 12, 4, 5], [99, 19, 20, 18, 21, 24, 31, 28, 27, 25, 30, 32, 38, 37, 34, 35, 39, 33, 36, 40, 41, 46, 47, 49, 52, 51, 53, 50, 54, 60, 58, 59, 61, 22, 17]
draw [104, 11, 12, 4, 5], [99, 17, 18, 19, 20, 21, 22, 24, 31, 30, 33, 32, 39, 36, 35, 37, 38, 34, 46, 40, 47, 51, 50, 52, 53, 59, 49, 54, 58, 61, 60, 29, 26, 45, 44, 28]
draw [104, 11, 12, 4], [99, 17, 19, 18, 20, 21, 22, 30, 29, 28, 33, 35, 36, 38, 37, 34, 44, 45, 46, 49, 51, 52, 54, 53, 50, 58, 61, 59, 60, 27, 43, 25, 39, 47, 31]
draw [104, 11, 12, 3], [99, 17, 19, 20, 18, 21, 22, 25, 28, 27, 30, 26, 36, 35, 33, 37, 34, 38, 29, 42, 41, 44, 46, 45, 43, 53, 51, 50, 52, 58, 60, 59, 61, 49, 54, 47, 31, 39]
draw [104, 11, 12, 3, 2], [99, 22, 20, 18, 17, 19, 21, 25, 24, 28, 30, 27, 26, 29, 32, 35, 36, 33, 39, 37, 38, 34, 31, 47, 43, 44, 45, 41, 46, 40, 42, 51, 50, 53, 52, 49, 54, 58, 59, 60, 61]
draw [104, 11, 12, 3], [99, 17, 18, 19, 20, 22, 21, 28, 30, 27, 25, 29, 24, 26, 33, 32, 36, 35, 37, 38, 34, 40, 41, 44, 45, 43, 42, 46, 49, 50, 51, 52, 53, 54, 59, 58, 60, 61]
draw [104, 11, 12, 4], [99, 17, 19, 18, 20, 22, 21, 24, 25, 28, 27, 26, 30, 33, 36, 35, 32, 37, 38, 34, 40, 41, 43, 44, 42, 49, 51, 52, 50, 53, 54, 58, 59, 60, 61]
draw [104, 11, 12, 4, 5], [99, 17, 19, 18, 20, 21, 22, 24, 25, 31, 27, 29, 26, 35, 36, 33, 34, 32, 37, 38, 39, 43, 40, 41, 47, 42, 49, 52, 54, 50, 51, 53, 61, 59, 60, 58]
end
This worked perfectly, when I just called the patterns like I would any other synth, but once I added in the equivalent amount of text, the editor just crashed. It seems to have nothing to do with running the code.
Can anyone shed any light on this? This is for a project that I am under pressure to complete and it’s really baffling me.
EDIT: Further information: after a certain point - the enter/return key stops working in the text editor, as does the standard Windows ctrl+c/v shortcuts for copy/paste. I can still type into the editor, and paste in using alt+c/v, or right-clicking, but I can’t run the code or anything. If I try to do that, the log window just clears and hangs there.