How to implement a "Run" button

This forum is for developers of Rack Extensions to discuss the RE SDK, share code, and offer tips to other developers.
User avatar
pongasoft
RE Developer
Posts: 459
Joined: 21 Apr 2016
Location: Las Vegas

Post 08 Apr 2023

This is a repost from the internal Reason dev forum, in case somebody here knows the answer...

I want to implement a button that behaves exactly like the Run button found in devices like Dr Rex or Chord Sequencer:

Screen Shot 2023-04-08 at 10.30.27.png


1) the user can press the Run button, to toggle play/stop
2) the user can use the transport Play/Stop button to also toggle the Run button


I just don't know how to implement such a behavior:


If the user can interact with the button directly, then it has to be tied to a document_owner property (and for the rendering, a toggle_button widget should do the trick)
But because the transport can dictate the state as well, that means the real time code, which is the one receiving the transport information, needs to update the property. Which means the property needs to be rt_owner property.

Since a property cannot belong to 2 different owners, I am not sure how to do this. Can somebody explain the trick to make it work?


Thank you
You do not have the required permissions to view the files attached to this post.

User avatar
buddard
RE Developer
Posts: 1182
Joined: 17 Jan 2015
Location: Stockholm

Post 08 Apr 2023

The trick is to implement the Run button as a custom display.
You can hide that fact either by drawing fairly realistic display graphics (the RS approach) or by covering up the display with static decorations that change based on visibility switches (the Robotic Bean approach).

As you've already concluded, you have to use a realtime property to keep track of the "is_running" state, which is calculated in the realtime code by looking at the transport state in combination with various other internal states depending on the requirements of the device.

For the player devices that I wrote (Euclidean, Sequences, Beatmap, Pattern Mutator and Bassline Generator), I have a custom boolean property to indicate whether the Run button is being pressed. When that property turns true it means that the user wants to toggle whatever playback state is active right now, and the realtime code acts accordingly.

Apart from the Reason transport and pressing the Run button, some devices also trigger Run on note on or a pulse on a CV input, so the logic can get pretty complicated. :-)
I created a Transport class that manages all these inputs and either follows the Reason song clock, or generates its own clock, depending on the situation.

I hope this helps!

User avatar
pongasoft
RE Developer
Posts: 459
Joined: 21 Apr 2016
Location: Las Vegas

Post 09 Apr 2023

Thank you @buddard. The description makes a lot of sense. I wished we didn't have to jump through hoops to implement what seems to be a trivial behavior.

Reading your description, I realized I ended up doing something similar for my AB12 switch (I guess I am getting old, not even remembering what I did a few years ago), in particular for the A and B button and I used your approach.

  • Information
  • Who is online

    Users browsing this forum: CommonCrawl [Bot] and 0 guests