Previous topic • Next topic

Globals that aren't so global: scene locals, folders and sharing

Suggestions for new features for Magic.
Post Reply
Sadler
Posts: 1402
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Globals that aren't so global: scene locals, folders and sharing

Post by Sadler »

In my Globals panel in any project I've used for a while you'll find a long list: Iterator counts, timers, audio bands, expression intermediates, alongside lots of repeats, each one created for a single scene, and all of them sitting side by side with just a handful of values that really do belong to the whole project. Crazy Dave put it most succinctly:
CrazyDave303 wrote:I want to have Globals that aren't so Global.
t3179, Sep 2024

Globals have come a long way (Expressions in 2.11, faster handling of "large numbers of globals" in 2.32, renames that follow through to expressions in 3.0). The 2.32 note is evidence that people use a lot of them. What follows is about making globals more accessible, manageable and intuitive as projects grow.

Globals are already the answer

When someone asks how to drive many parameters from one value, the answer on this forum, devs included, is a Global ("it might be best to use a Global", t2233; "Create one global that is your main 'switch'", t1321). I give the same advice. Globals keep values in sync, document the numbers that matter, and feed expressions. That success is exactly why the list gets long.

Locals

Most entries in a big project's Globals panel only matter inside one scene. Sorting them out roughly:
  • Truly global: constants ExprTk doesn't provide (phi, tau), master BPM and beat phase, master brightness, a show-wide intensity level, the show's colour palette.
  • Really scene-specific: Iterator and other counts and indexes (such as the line index into a TextFile of lyrics), values shared by linked parameters within the scene, intermediate expression calculations, scene timers, and the audio bands the scene responds to.
Iterator counts are the clearest case. The count is used in expressions to normalise the Iteration #: spreading hue across the copies, dividing a full rotation between them, setting spacing and falloff, and much more. So every Iterator wants its count in a global, where the modules and expressions that depend on it can all read it. But the Iterator does a different job in each scene (12 bars here, 64 particles there, 5 rings somewhere else), so the panel fills up with IterCount_Tunnel, IterCount_Rings and so on. The clutter puts people off using globals for exactly what they're best at.

You'd already named the solution:
Magic wrote:I was planning on having a new category called "Locals", which are Globals but only for one scene
t1693, Aug 2018

It has come up repeatedly since Jojo's "(global and local) variables" in 2015 (t261), including my own t1130 in 2017, which you called "a pretty good idea".

Locals could also follow the life of their scene. An Increase modifier on a single parameter already restarts with the scene. A scene timer held as a local could do the same, and could also be linked from any number of parameters and used in expressions. Two users have run into exactly this: artnik found that globals "kept counting their input from frame 1, as opposed to scene start" (GD, 2017), and mcornholio built a project-wide "time" global so his expressions could know "the time passed since scene started" (GD, 2018).

Folders

Even with locals, a project's globals deserve some order. Folders in the Globals panel, as in the Scene Group panel, were asked for in t1751, where you mentioned "related things in our pipeline", and reGeneraTed added: "I have quite a few globals and having a way to keep them bunched-up and organized would help a lot!!"

Just this week, rdrt asked for the Globals panel to be resizable because most of the names can't be read at its fixed width (t3599). A wider panel would help straight away. Folders and locals would help further: much of a global's name is there only to say where it belongs. With the folder or scene carrying that context, "Tunnel_Iterator_Count" can simply be "Count" inside Tunnel.

Global Folders.png
Global Folders.png (97.14 KiB) Viewed 736 times

A scene's own controls

In most scenes there are many modules and even more parameters, but only a few are important to the scene's development and look. It's a challenge remembering which ones they are, and then finding them, especially live. I already work round this by linking those parameters to globals so I can reach them from the Globals panel, but that puts every scene's key controls into one project-wide list.

Exposed locals would gather those few values per scene: mark a local as exposed and it appears with the scene's other key controls in one place. That's useful in every scene, whether or not it's ever used inside another.

This is a different thing from the live status display discussed in t1110 (FPS, playback time, BPM, memory, MIDI assignments), which you described as "very useful" alongside your own idea of a "Console" window. That shows what Magic is doing; this gathers what I want to change. The two could meet, though: a scene's controls showing their live values would cover some of the same ground.

When the scene is used as a Scene module, its exposed locals become per-instance parameters, so one scene can appear several times with different settings. Terry described the split:
Terry Payman wrote:I see benefit in a distinction between Scene parameters and Scene locals. Only the parameters would be exposed at the higher module level (with their defaults defined at scene level).
t1130, Sep 2017

New users meet the need quickly: WoodlandSpirit found that to use a scene twice with small differences, "the only feasible way is to duplicate the scene" (t2541). Duplicates drift apart; a parameterised scene stays one scene.


Taking globals to another project

Today, reusing a scene and its globals elsewhere goes like this:
  1. Save the scene to its own project.
  2. Open that project and delete or rename the globals you don't want to bring across.
  3. Import it into the target project.
  4. Tidy up any names that clashed and arrived with a "1" suffix.
It works, and it's what I've recommended since 2018, but it's a lot of steps for "bring my LFO globals with me". gregRocksSoHard saw no way "to re-use my globals besides using 'save as' for the project and starting over" (t3196), and They Said They Saw described the suffix problem in detail (t3179).

With folders, a set of globals (BPM and LFOs, a palette, controller mappings) could be exported and imported as one item. When a name clashes, a choice to keep the existing global, replace it or keep both would avoid the suffixes, and the same choice would help Import Project generally. Folder names could also act as namespaces in expressions (Palette.Hue, Strobe.Hue), so clashes become rarer to begin with.


Where is it used?

Finding where a global is used is part of a wider need: finding where a piece of media is used, which scenes have errors, or where that well-configured ISF lives so it can be reused. Parts of this have been asked for in t1809, t1851, t2949, t2658 and t3222, and it probably deserves a post of its own. For globals, a "Used by" list with jump-to is the piece that belongs here, along with a "Remove unused globals" to match Remove Unused Inputs.

So, another mega bump which, fingers crossed might make it into version 3 at some stage and in some form.

Sadler
Terry Payman
Posts: 832
Joined: Sun Sep 14, 2014 8:15 am
Location: UK
Contact:

Re: Globals that aren't so global: scene locals, folders and sharing

Post by Terry Payman »

+1 to Sadler's valuable suggestions, and some modest additions - with apologies to Sadler if I've overlooked any points he already covered.

Add extra checks when importing globals

I believe there are two additional cases to consider
  • An Imported global has the same name as an existing global but a different purpose.
  • An Imported global has a different name to an existing global but the same purpose.
Magic could compare incoming and existing globals on more than name (source or expression, range, uses). It could then flag both cases and let the user keep both, rename, or map to an existing global.

Add a "Merge" command into the Globals panel

A "Merge into…" command in the Globals panel would help users clear duplicates they already know about, such as the "1" suffix ones left by past imports.

A survey of the project's globals

As well as supporting checks on import, knowing what drives each global and where it is used could feed Sadler's "Used by" and "Remove unused", and help the selection of candidate locals, suggested folders and a "Find duplicate globals" command.

Terry
Sadler
Posts: 1402
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Globals that aren't so global: scene locals, folders and sharing

Post by Sadler »

Thanks, Terry. There's no overlap at all. These fill the gaps that I hadn't covered.

Thinking about your two cases (same name/different purpose and different name/same purpose), they fit together neatly with the locals and folders.
  • The scope shrinks the problem. Locals travel inside their scene, so two scenes can each have a 'Count' without clashing. Conflicts are confined to a handful of true globals, and folder names reduce them further.
  • Identical definitions can be matched exactly. The same name and definition (source, modifiers, expression or range) can simply use the existing global, which would eliminate most of today's "1" suffixes.
  • The rest is up to the user. For the same name with a different definition, you can use the existing one, the incoming one, or keep both. Different name with the same definition: Magic suggests mapping; the user decides. Your 'Merge into…' option covers duplicates that are already in a project.
So, rather than just tidying the panel, locals and folders turn merging from a regular chore into an occasional decision.
Sadler
Posts: 1402
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Globals that aren't so global: scene locals, folders and sharing

Post by Sadler »

After more consideration, using group names to qualify globals and locals won’t work with a dot separator: expressions read a dot as part of a number and give an error (“Invalid numeric token”).

Screenshot 2026-11-14 082303.png
Screenshot 2026-11-14 082303.png (29.48 KiB) Viewed 573 times

So either Magic would need its own group separator, translated before the expression is evaluated, or names must be unique within their scope (within a scene for locals, within the project for globals), with groups used purely for organising the panel. The second option keeps things as they work today, and scope alone already keeps names short. That also replaces the “Palette.Hue” example in my first post.

On a related note: Magic accepts dots, spaces and arithmetic symbols in global names, but expressions can’t use them. A warning when naming would help.
Post Reply