Storing values from a slider

I’d like to store the values from a slider, every 4 seconds, in an array. Creating a routine to do this returns an error:
ERROR: Qt: You can not use this Qt functionality in the current thread. Try scheduling on AppClock instead.
ERROR: Primitive ‘_QObject_GetProperty’ failed.

Looking at the help file for AppClock, however, leaves me a little bit in the dark. The description suggest I look at Clock for an explanation of how clocks operate, but looking at Clock has no particular information about AppClock.

I’m hoping someone, specifically, might have a solution for how to progressively read and store values from a GUI element. But I’m also interested, generally, about how the AppClock operates. Thanks!

I would make the slider’s action write its value to a control bus and then write the routine to get the bus’s value.

Take a look at the EZSlider help file. Here is a modified example from the helpfile.

var val;
b = Bus.control(s, 1);
g = EZSlider(label:" test ");
g.action_({ |ez| val = ez.value });
r = Routine{
	loop {

b.get // get the value of the control bus
r.stop // stop the routine

Understanding errors | SuperCollider 3.12.2 Help.


use the .defer method to schedule on app clock.

any gui operations inside a routine need to be wrapped in a function with .defer like…

fork {
  { w = }.defer;

Thanks semiquaver - but what about GUI operations in a Task? Is it the same?

The fact that it’s a Routine isn’t important.

The relevant factor is that it’s scheduled on any clock other than AppClock. Routine, Task, patterns, functions, anything on a clock would require defer to touch a GUI object.


1 Like