Using the new feature for generating lissajous figures in SP5 here is a doodle pattern. You can have fun by altering timings, frequencies. phase offsets, even sliding them.
#lissajous doodles on Sonic-Pi 5 by Robin Nwman
use_synth :sine
use_random_seed Time.now.to_i#resets seed hence choices each time run.
live_loop :start_new do
#start two sines panned +/- 1
p1=play :a3, pan: -1, sustain: 1.8 #you can play with sustain times.
p2=play :e4, pan: 1, sustain: 3.6 #they are regenerated each time start_new repeats
live_loop :c1 do
control p1,note: [:a2,:a3,:a4,:a5].choose #change frequency of p1 every second
sleep 1
end
live_loop :c2 do
control p2,note: [:a5,:d4,:e4,:a3,:d5,:e5].choose,phase_offset: [0.25,0.5,0.75].choose,phase_offset_slide: [0,0.25,0.5].choose
sleep 0.25 #this loop runs at 4 times the speed of :c1 loop
end
sleep 2 #time before p1,p2 regenerate
end
Perhaps I should say select lissajous from the scope options and adjust the size of the scope window to give a reoughoy square shape. Also, you can turn the exteranlal sound volume down (not the built in volume control in prefs) if you find the sound output too loud.
4 Likes
Great sound. Reminds me of the Monome era 
Very interesting sound, but in my case, with V5 I get a
Timing Exception: thread got too far behind time error
in the sleep of live_loop :c2 (although it still plays correctly). This doesn’t happen with V4 (although the resulting sound isn’t exactly the same).
Not sure why that should be. What hardware are you using to run SP5.0?
I have it running on a mac-mini, but it also runs perfectly on my raspberry pi5
you are using the final release version of version 5.0.0?
Yes, I’m using the final release (the AppImage) on Ubuntu 22.04 with an i7-1260P processor. I’m not experiencing any CPU performance issues. I also don’t know what the problem could be, but despite the error, the sound is still being generated correctly.
Values equal to or greater than sleep 0.35 don’t seem to produce the error. Values below this value do cause the error (the smaller the wait, the sooner the error appears).
Don’t worry, if I find out the cause, I’ll let you know.
These two options will fix the error:
Thanks for the heads up. This is definitely a bug and I’ll have a fix ready in a couple of weeks when I’m back from my holiday.
Lovely little patch. One thing that might help anyone else hitting the timing exception in the meantime: the :c2 loop is doing a control plus a choose every 0.25s, which is a fairly tight budget for per-iteration work, so it’s the loop most likely to report falling behind even when the audio still sounds fine. As a workaround while the fix lands, pre-computing the note list outside the loop (a ring, and index it with tick) instead of calling choose each pass shaves off a bit of per-iteration work, and bumping the c2 sleep to 0.5 with two controls per pass gets the same rhythm with half the scheduling overhead.
Worth remembering that “thread got too far behind time” is about the scheduler’s ability to send messages ahead of the deadline, not about the sound itself - so hearing it play correctly while still getting the warning is exactly the expected symptom, and nothing in the audio is being dropped.
On the musical side: since phase_offset is being chosen from a list, the figure only settles into a stable shape when the two frequencies land on a simple ratio. If you want the shape to visibly rotate rather than jump, sliding the offset with control … phase_offset_slide: over a beat or two gives a continuous morph between figures, and matches the “even sliding them” idea nicely. Detuning one voice by a hair also makes the figure drift slowly instead of standing still, which is very satisfying to watch.
2 Likes
I deliberately moved the phase becuase I liked watching the resolution into the stable figure, but nothing is proscribed. It is a great thing to play with and there are many possibilities. Similarly with the refreshing of the loops. you can adjust this so that the sustained note is finishing before the refresh which allows the pattern to collapse inwards.
Previously I played with lissajous figures quite a lot using the modified ssynth defiintiions produced by @emlyn I did some work using TouchOSC to control the synths producing a wide range of patterns. see the thread here
I hope to do something similar with SP5 now that Sam has added the facility to have sine waves with a fixed (although variable) phase difference.
1 Like