Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RgbScript make stage colors available to scripts #1422

Draft
wants to merge 54 commits into
base: master
Choose a base branch
from

Conversation

hjtappe
Copy link
Contributor

@hjtappe hjtappe commented Apr 19, 2023

Hello @mcallegari, this pull request extends the rgbScript API by the raw colors as set in the UI in addition to the step color.

Effectively, this allows synchronization of RGB script colors to stage colors, also for multicolor scripts and specifically extends the available colors from a list of predefined colors to the complete RGB space as used on stage:

  • alternate.js can now make direct use of the stage colors
  • ballscolors.js can now have balls which follow the stage color
  • plasmacolors.js can now display plasma following the stage color

It also introduces error evaluation on the QJSEngine::call calls, so script errors would not only be while loading the scripts (::evaluate / static analysis, missing brackets etc.) but also in dynamic evaluation (::call / undefined indices etc.).

There is more potential in this approach, like adding more (up to five) colors in the UI, but I did not yet want to interfere with your UI thoughts before presenting the general concept.

Please evaluate if this could be a useful extension to QLCplus and let me know your thoughts.

to prepare potential extension for e.g. 5 colors as used in color scripts
- Handle script errors which occur only in .call(), not just parse errors from .evaluate().
- Hand over an array, not just a variable arguments list.
The algorithm prefers the inner colors (1-2-3-4-5) over the outer colors as the
noise function output is a Gauss distribution. To make the colors set from thr
outside more persent, shift them from 1 and 2 to 2 and 3.

Also, format the algorithms.
- Set default ramp value to center (20) as in plasma.js
- Add and improve code comments and their formatting
- Make value calculation explicit to make them available for debugging
- Keep plasma and plasmacolors in sync for comparability.
and add documentation in template empty.js
@mcallegari
Copy link
Owner

Preliminary question: what do you mean by "stage colors"?

@coveralls
Copy link

coveralls commented Apr 19, 2023

Coverage Status

coverage: 31.62% (-0.4%) from 32.027%
when pulling 05fd4b3 on hjtappe:rgbScript-colorArray
into aeab64e on mcallegari:master.

@hjtappe
Copy link
Contributor Author

hjtappe commented Apr 19, 2023

Preliminary question: what do you mean by "stage colors"?

In stage scene productions, often two or three colors are used consistently across the stage elements at a time. Changing the color dropdowns is tedious in RGB matrix controls, so binding the startcolor and stopscolor to the colors used on stage anyway in sequences or through color control buttons would automate the consistency.

The alternative is to prepare these scripts once for every color combination that you foresee to have them quickly accessible, but that leads to an unnecessarily crowded workspace.

Please find attached an example workspace which shows the effect of stage colors changing every 7 seconds and the matrix colors following them, visible in the 2D view and the Virtual Console. It runs on compile-qt5-AppImage / qlcplus-qt5-4.12.7_GIT-20230419-db0090d.AppImage.

stageColors.qxw.zip

(it also runs on the qt5qml build, but I am still faster in building the space quickly in the old UI)

@yestalgia
Copy link
Sponsor Contributor

Forgive me if I'm wrong, but how is this different to using the custom controls?

@hjtappe
Copy link
Contributor Author

hjtappe commented Apr 21, 2023

Forgive me if I'm wrong, but how is this different to using the custom controls?

You mean the script properties?

The differences are:

  • the properties contain only 30 colors (plus black and white) and are missing some well-used colors which cannot be set unless you create a custom version of the script. --> The direct colors can follow all colors that are used on stage and set through color controls.
  • the properties cannot be synchronized to other colors on stage. Unless you have fixed scenes and duplicate the scripts instances per scene or you click multiple times to set other stage colors and choose the matching color names in the script, colors will not synchronize in time and value. --> The direct colors can be configured to automatically follow other stage light RGB channels through the VC matrix widget and will instantly take over the color selected through a scene or collection.

The latter one is a real pain to me in dynamic productions which rely on the lights to dynamically follow the stage emotions (from improvization theatre to freestyle music jam sessions). For the first one it is just inconvenient to think about a good color name - but it becomes a pain when it does not change in the rhythm of music due to the additional thoughts and clicks.

Is that what you were asking?

Also fix several off-by-one errors, such as the edges being out of sync and evaluation of integer properties.
Also let the marquee color take effect and not just add to the existing RGB values.
@hjtappe
Copy link
Contributor Author

hjtappe commented Apr 27, 2023

Hello @mcallegari,

I integrated the new marquee.js into the QLCplus workspace (there seems to be use for the feature to have the raw colors available in the scripts ;-) ), but I also found off-by-one and update errors, which I fixed along the way. Please let me know if I should create another marquee.js pull request with just these changes:

  • Changing / Fading colors (color-1) were not taken over into the background
  • The integer in properties "16" + "3" + 1 were interpreted as string (1631) - added parseInt a few times
  • The edges of the marquee were set twice, each edge had it's own way to start over. This leads to each edge having an inconsistent marquee pattern.
  • The selected marquee color is not applied but added (merged) with the background color. This significantly reduces the reachable color space for the marquee. It could be made an option, but if the user needs merged another on the marquee, he could select the marquee color right away.

The VC and 2D view now look like this:
screenshot

This is the QLCplus workspace file:
stageColors.qxw.zip
created, tested and run with this build:
https://github.com/mcallegari/qlcplus/suites/12515946079/artifacts/667974953

@hjtappe
Copy link
Contributor Author

hjtappe commented Mar 26, 2024

I have now created copies of the matrix scripts which were in need for the direct color access and merged the master back into this branch.

So with this, the QLC+ users will be able to synchronize the plasma and alternate, marquee, balls etc. colors on two panels on the same stage with changing only one set of leading color channel which the matrix can sync it's colors on.

So while it was previously possible to create matrix effects

  • for single color patterns
  • for mask patterns
  • for color patterns fading between two colors
  • for multi-color patterns which needed a dropdown to select the color
    this patch will add the possibility to create matrix effects
  • for multi-color matrices with direct access to color scene changes
  • for multi-color matrices with synchronized color selections
    without the need to duplicate the matrices and all its setting to integrate them into collections for each color scheme.

@yestalgia
Copy link
Sponsor Contributor

Being able to fade colours of the rgbmatrix would be a super interesting way to perform live. I'm keeping a close eye on this.

Appreciate the effort @hjtappe

@hjtappe
Copy link
Contributor Author

hjtappe commented Mar 27, 2024

The file matching the renamed algorithms got lost in upload (probably rejected), so here it is:
stageColors-5.qxw.zip

About 90% of the shows I volunteer for are freestyle where I react on what I hear. Only 10% is somehow predictable or theater style. So having direct access (e.g. in alternate.js) to the colors will help me putting colors and patterns on stage consistently and instantly. :-)

@yestalgia
Copy link
Sponsor Contributor

@hjtappe I'm doing some tests on my windows machine based on the last build.

Can you please merge master into this branch so I can check it with the latest changes?

@yestalgia
Copy link
Sponsor Contributor

I've done some testing on Windows and there are things I LOVE about this. Also some things which I think could be improved.

The good:

As a heavy user of the Animation widget, I've always wanted to be able to send input to change the colour of the start and end colours. But this is even better! We can now control up to 5 colors within the matrix which is ace. This is really forward-thinking stuff which will allow many possibilities for those developing RGB matrix scripts.

Suggestion:

This said, I don't see a reason to have both "Add Color 1" and "Add Color 1 Knobs" cluttering up the animation widget properties dialogue. If controlling the colour of the matrix should be done externally through RGB values sent via loopback, then I think we should commit to it.

For this reason, I believe we should make the Knobs controllable via loopback and remove the preset colors (as in "Add Color 1")

However I'm open to discussion on this. One way I think you could still have presets (and not break anyone's showfile) is an "Add Color" button. Then you could select which color this applies to (1,2,3,4,)

image

Excellent work.

Tested using Windows 11

@yestalgia
Copy link
Sponsor Contributor

Hey guys,

Here's a video showing my testing:
https://youtu.be/VChztAg9Xxc

This is SERIOUSLY cool.

@yestalgia
Copy link
Sponsor Contributor

@hjtappe I did some further testing. Just an aesthetic point:

Can you please make sure there is a nice grid of buttons for the colour selection? This can be done by adding whitespace or a disabled X button instead of the first colour being larger.

image

@hjtappe
Copy link
Contributor Author

hjtappe commented May 24, 2024

@yestalgia, thanks for your review and nice video. As you mention, this will enable us to connect the colors used in light animations (rgbscripts) to sync, fade and follow.

I have merged master, so you will be able to give it a try after the build has finished.

Regarding the knobs, there are two reasons why I would not change them: I would not change the v4 UI concepts any more. And the users will want to set the colors with multiple knobs per color "channel" (one for each color preset they define) when they use the VC in a light-scheme kiosk terminal. In that use-case, you want to add pre-defined buttons to switch between color presets.
For the simple user - the more experienced user would actually apply a scene on a VC button...

I would be happy to see this merged into master because then I can use rgbScript animations (including "plain color") all over the place and use those to manage the show in a more consistent color style.

@mcallegari
Copy link
Owner

mcallegari commented May 25, 2024

@hjtappe the idea is approved, no doubt about it. Thanks for this. I'm pretty sure many users will appreciate it.
However I would like to discuss with you a few decisions you took in the code.

  1. considering the size of this change, why 5 colors and not an arbitrary number of them? I would change
    QColor m_rgbColors[RGBAlgorithmRawColorCount];
    to
    QVector<QColor> m_rgbColors;
    Then when loading the script for the first time, the C++ code will resize the array to the size defined with algo.acceptColors. If version < 3 or no variable is defined, the array should be resized to 2 to handle start/end.
  2. I don't quite like the idea of passing the colors array at each rgbMap call. This affects performances (even if slightly...but still) and most likely colors won't change that much in time. Instead, I would add a method to v3 scripts to set colors by index, as you did in the C++ code.

I have mainly these 2 concerns for now. What do you think?

@hjtappe
Copy link
Contributor Author

hjtappe commented May 26, 2024

Hello @mcallegari, thanks for your positive inputs on this.

Yes, the number of 5 is arbitrary - but seems like a good statistical assumption these days:

  • I believe the number will not increase significantly because managing much more colors will become increasingly complex to manage for the operator and will create a confusing stage I believe.
  • One operational mode could be using a rainbow script to drive the "virtual" (loopback) colors and attach other scripts colors on the second logical level to the slots in the rainbow colors. In that case of color change automation, the number is running higher.
  • Much larger numbers will clutter the current color picker layout in the UI, so I would please need assistance to define and implement e.g. a new popup screen or a dynamic table and I wonder if we would do that step once v4 is no longer maintained.
  1. QVector: I can certainly rework the code, load and store and probably the script interface the to handle and work with a QVector. Unfortunately, I have no idea how the dynamic table in the UI and QML and Webaccess code would be implemented. If you have examples in the code, I can try to learn how to apply the implementation pattern to these colors.
  2. Script method to set colors by index: I can extend the v3 script API to initialize and handle color changes through a method. Instead of calling that function for each color (especially when not limiting the color count), I would implement one function to update the colors as an array. For some scripts, it might even be interesting to hand over the steps-timing to scale pattern movements to align smoothness of patterns with speed of movements. Thinking about performances, when putting that into each call, doesn't it mainly increase the memory footprint of that function? I fear that another method being called might have a much higher performance overhead due to the Layers of API between C++ and JS being involved.

So let me do the next moves:

  1. Look into how to modify the v3 script JS API with the additional method.
  2. Start implementing the dynamic QVector in the C++ code as well as load and store, so we are future-proof and unlimited on the data and business logic side.
  3. Leave the UI, QML and Webaccess limited to 5 for the moment, so we can take a look into how and when this can be extended for an unlimited range within an acceptable user experience.

One capacity note: I am quite busy throughout the summer, so it could take a while to the next commit, but I am happy for the guidance you provided for the next steps.

@hjtappe hjtappe marked this pull request as draft June 16, 2024 17:23
@yestalgia
Copy link
Sponsor Contributor

Hello gentlemen,

Just wanted to check in on this guy. @hjtappe are there any additional tests you want me to do on Windows?

I'm getting a lot of interest from the Resolume community here in Melbourne about the smooth colour transitions possible with this.

Thanks again

@hjtappe
Copy link
Contributor Author

hjtappe commented Jul 26, 2024

@yestalgia , thanks for your offering. I have been using the Github builds to check the functionality, so feel free to run it to check it from other perspectives if anything might break that I might have overlooked. But I have no Windows specific areas of test in my mind (might be a bind spot).

The current status is: the Qvector change is implemented. The API change is pending a measurement test which approach really saves compute time as well as my current lack of capacity during summer. The dynamic number of dials integration into the UI topic is still open and probably will remain limited until we have an idea on how it should look like.

@hjtappe
Copy link
Contributor Author

hjtappe commented Jul 26, 2024

On a side note, I have been peeking into the idea of screengrabbing to foster a TV backlight effect on large conference screen at https://github.com/hjtappe/qlcplus/tree/rgbMatrix-screenGrabber

Grabbing colors from a screen on the same desktop already works, but I failed so far on grabbing from an HDMI grabber or Camera device through the QMultimedia framework due to the asynchronous behavior.

That might be of interest for the community as well, @yestalgia
That's why is is not yet pushed as a draft pull request. But if there would be anyone to help taming the QT framework... 😀

@yestalgia
Copy link
Sponsor Contributor

On a side note, I have been peeking into the idea of screengrabbing to foster a TV backlight effect on large conference screen at https://github.com/hjtappe/qlcplus/tree/rgbMatrix-screenGrabber

[Off-topic] Dude absolutely! NDI is also something I'm looking at.

Happy to sponsor this feature if you'd be willing to accept a donation. Send me a DM on Instagram or the forums. Here is a link to current discussion:

https://www.qlcplus.org/forum/viewtopic.php?p=74017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants