Visuals with SCAMP?

What would be the best way to make visuals based on the same math that’s using to make notes? I’m particularly thinking of the Circle Music video and the Fibonacci music box, but don’t know how the visuals that accompany the music are actually being made

Hi! So my approach tends to be to use something like pygame or pyglet (I’ve tried both), and run SCAMP on a separate thread. You can then either use the state of the music (either global variables or class attributes) to affect the visuals or vice-versa.

I’m actually planning to do a seminar on this topic, and on the circle music specifically, in a few weeks. It’ll probably be paid and/or free for Patrons. So stay tuned – I’ll definitely post about it here!

1 Like

Marc, re your reply above (from May 2024). You said that you run SCAMP on a separate thread. Do you mean that you use threading for scamp and a different thread for pygame/pyglet?If so, within the SCAMP thread, can you still use fork?

Yes, I use threading for Scamp, and allow the GUI framework to run on the main thread. The one thing that’s really important is that on the main Scamp function which is forked, you need to establish that your session is the clock for that thread. That will happen automatically if you create the session within the forked Scamp function, but if you want to create the session in the main body of the script, you have to do it explicitly. I’ve waffled a lot over the years on the best, most natural way of doing that, but my current approach is:

# create a new thread to run the main scamp function on
scamp_thread = threading.Thread(target=scamp_main)
# set it to use s as a clock
scamp_thread.__clock__ = s
# start the scamp
scamp_thread.start()

So, this is assuming that you’ve defined your session s in the global scope, and also defined a function called scamp_main which is kind of like your top level scamp script. From inside that main Scamp function you can Fork other functions as you normally would.