Advanced Scene Switcher

Advanced Scene Switcher 1.28.1

AaronD

Active Member
Thank you. How about if I need to add a condition with an AND? So if it's in those specified time ranges AND it's on a certain scene. I'm not sure about the precedence, but applying what I know by AND usually taking precedence over OR, this would mean I'd need an AND for each time range, is that correct? And thus, so I don't need to create multiple ANDs, i just group all the time ranges in one macro like you said, then AND in another macro?
Normally, AND would take precedence, but there's also an argument for building up as you go. (I've seen C compilers do that, so that PEMDAS becomes PE-order-of-appearance - only because E is a formally-defined function and not a built-in operator - and code that uses it has parentheses *everywhere*!) I haven't used enough complex logic in here to figure out which it is for us. We don't have parentheses, so it's limited either way.

The build-up-as-you-go version requires less to keep track of under the hood, and is equivalent to having a big pile of open parens up front, and each expression closes one.



If you really don't want parentheses, you can look at Reverse Polish Notation. It has all the capabilities, without that requirement, but it does have a different requirement of loading each operand by itself, without an operator, and specifying each operator without operands. Each operand goes onto a stack, and each operator takes the last two items (sometimes one) off of the stack and puts its result back onto the stack. If you're not used to it, that gets confusing in a hurry!
For example, A B + C * D E / - in RPN is equivalent to ((A + B) * C) - (D / E) in the way that most of us are used to.
A bunch of the same associative operation could be A B + C + D + E + or A B C D E + + + + or any combination in between, though the first is probably easiest to read, and keeps the stack size down.
This is also easier under the hood than parentheses, because there's never a need to save your place in the expression and come back to it.

For error handling:
  • An operator that sees insufficient operands on the stack, could do nothing (don't even pop/push), and throw a warning.
  • When the expression is finished, take the top of the stack as the answer. If the stack is empty, call it false. If there are additional items, throw a warning, but only use the top one. Regardless, clear the stack before the next scan.
The side-effects are that a 2-input operator that only sees 1, will leave that 1 unchanged, and a too-full stack at the end will ignore some of what you told it to look at. Neither of which is probably what you had in mind, mostly because the expression *itself* is broken, and not what you had in mind. Take the warnings seriously!
 
Last edited:

iliketoDJ999

New Member
UGH. My backup was corrupted and I could not import my previous settings once I updated OBS to the lastest version. Now I have to redo over 200 scenes with of scene transitions. Which leads me to my post here....

... Can we PLEASE PLEASE PLEASE get an option to mass change settings in the different tabs: - like duration amount for all scenes before switching into another scene / micros / performing a different action, changing scene transition types, etc.

Or even allow us to copy / paste scenes.
Trying to redo hundreds of scenes manually by hand, one by one, is actually torture.
 

Warmuptill

Active Member
Thank you. How about if I need to add a condition with an AND? So if it's in those specified time ranges AND it's on a certain scene. I'm not sure about the precedence, but applying what I know by AND usually taking precedence over OR, this would mean I'd need an AND for each time range, is that correct? And thus, so I don't need to create multiple ANDs, i just group all the time ranges in one macro like you said, then AND in another macro?
The way macro conditions are evaluated is always from top to bottom within each macro.
So if you have macro with conditions...

IF A
OR B
AND C
OR NOT D

It will be evaluated as (((A OR B) AND C) OR NOT D).

In case of the "Macro" condition type, the value of whatever the conditions of the specified macro resulted in the last time the macro was checked is simply reused (and not re-evaluted in place).

To give an example, let's call the example above "Macro 1" and reuse in this setup:

IF X
AND Y
AND NOT "conditions of 'Macro 1' are true"
OR Z

This would effectively result in:

(((X AND Y) AND NOT (((A OR B) AND C) OR NOT D)) OR Z)

I hope this is somewhat clear.
If not please let me know :)
 

Warmuptill

Active Member
UGH. My backup was corrupted and I could not import my previous settings once I updated OBS to the lastest version. Now I have to redo over 200 scenes with of scene transitions.
Is the backup lost completely or can it maybe be salvaged?
I can try to give it a show if there is still something left over.

... Can we PLEASE PLEASE PLEASE get an option to mass change settings in the different tabs: - like duration amount for all scenes before switching into another scene / micros / performing a different action, changing scene transition types, etc.

Or even allow us to copy / paste scenes.
Trying to redo hundreds of scenes manually by hand, one by one, is actually torture.
I appreciate the request / suggestion, but I am afraid it is unlikely I will add functionality to the non-macro tabs in the near future.

In case it is of help:
The macro tab does allow you to create copies of macros by right clicking on the macro you want to create copy of:
Copy.png


Alternatively you could export the settings to a file and change the values there and reimport it if that is quicker.
But please make sure to back up the settings before hand in case something goes wrong.
 

AaronD

Active Member
The way macro conditions are evaluated is always from top to bottom within each macro.
So if you have macro with conditions...

IF A
OR B
AND C
OR NOT D

It will be evaluated as (((A OR B) AND C) OR NOT D).

In case of the "Macro" condition type, the value of whatever the conditions of the specified macro resulted in the last time the macro was checked is simply reused (and not re-evaluted in place).

To give an example, let's call the example above "Macro 1" and reuse in this setup:

IF X
AND Y
AND NOT "conditions of 'Macro 1' are true"
OR Z

This would effectively result in:

(((X AND Y) AND NOT (((A OR B) AND C) OR NOT D)) OR Z)

I hope this is somewhat clear.
If not please let me know :)
That's exactly the build-as-you-go version that I mentioned. Thanks for clearing that up!

RPN might be interesting to play with too, but not necessary.
 

GabiDG

New Member
Can a macro do "pause all title match checks when a certain scene is active"? Or I still have to use the Pause tab? I do not want to completely stop the plugin...
 

PlatinumLive

New Member
Maybe something like this will work for you?
View attachment 87296


Thanks for the hint - I have identified the issue and will release a new version.

Hey Warmuptill,

A big thank you for creating, updating, and maintaining this app. I could imagine it takes a lot of time to identify the issue, develop a working patch, and confidently update the version for everyone else to download, all while responding to messages in a timely manner. So again, thank you!

I was able to update to the latest version of Advanced Scene Switcher, V 1.19.1 and the scene switched from scene A to B after 5 minutes as intended. I left the "with a duration of - seconds" untouched, in the lower portion of the macro and it worked for me, didn't know what that was intended for given the time is set in the top section of the macro. I've tested it out over the past few days and it works perfectly! I attached a screenshot for anyone else looking to accomplish the same thing. In my scenario, it was from the intro scene to the main scene after 5 minutes and 5 seconds into the stream.
 

Attachments

  • OBS Scene Macro.JPG
    OBS Scene Macro.JPG
    59.8 KB · Views: 33

mlgudi

New Member
Is it possible to use the value of a regex match as part of the subsequent action? For example, if I used a regex to match a window title, could I assign that value to a variable or use it in a text field somehow?
 

Warmuptill

Active Member
Is it possible to use the value of a regex match as part of the subsequent action? For example, if I used a regex to match a window title, could I assign that value to a variable or use it in a text field somehow?
Unfortunately not at the moment.
But I will add your suggestion to the todo list.
Thanks!
 

dayu

New Member
I have created a simple Python program. I started it triggering "RAN" but the command pronto screen immediately closed.

I was able to start it manually, so my Python file is not the problem.

Any suggestions?
 

Warmuptill

Active Member
I have created a simple Python program. I started it triggering "RAN" but the command pronto screen immediately closed.

I was able to start it manually, so my Python file is not the problem.

Any suggestions?
Can you share how you are attempting to run it?
The most common source of issues is using relative paths instead of absolute ones.
 

GabiDG

New Member
I am trying to use macros to show a scene when Chrome is full screen and another screen when Chrome is not full screen. My best result is a flickering between the two scene when Chrome is full screen. Do you have any idea what's happening? It looks like second macro is activated even when Chrome is not full screen, and there is a race between the two macros...
1665590852907.png

1665590889010.png
 

AaronD

Active Member
I am trying to use macros to show a scene when Chrome is full screen and another screen when Chrome is not full screen. My best result is a flickering between the two scene when Chrome is full screen. Do you have any idea what's happening? It looks like second macro is activated even when Chrome is not full screen, and there is a race between the two macros...
View attachment 87579
View attachment 87580

I probably solved it by adding the condition "If not" Chrome fulscreen, maxed and focused to the second macro....
I was going to say that unchecking the fullscreen box (or any of them) is not the inverse condition, but simply not looking at that condition at all. I wonder if this would work for you:

Macro A:
If Chrome exist
AND
If Chrome exist and fullscreen

Macro B:
If Chrome exist
AND
If Not Chrome exist and fullscreen

The first term in each might seem redundant, since it also appears in the second term, but I don't think it can go away from the second term, and it needs to be there explicitly to keep Macro B from running when Chrome doesn't exist. Its appearance in Macro A is just for parallelism between the two.
 

reservoirducks

New Member
Apologies in advance if this is a dumb question but - I'm working on a film festival, and trying to set OBS up to easily play blocks of films. For example, for a simpler one - I have one preroll video file and one movie file. I've tried putting them both in a VLC playlist and playing that, but the playlist restarts when the movie is over. When I try to make a macro to switch to the next scene when the playlist ends (using that Media state Ended(playlist)), it doesn't work. Is there a simple way to build out these blocks of videos to just play through once?
 

AaronD

Active Member
Apologies in advance if this is a dumb question but - I'm working on a film festival, and trying to set OBS up to easily play blocks of films. For example, for a simpler one - I have one preroll video file and one movie file. I've tried putting them both in a VLC playlist and playing that, but the playlist restarts when the movie is over. When I try to make a macro to switch to the next scene when the playlist ends (using that Media state Ended(playlist)), it doesn't work. Is there a simple way to build out these blocks of videos to just play through once?
I've never had the Ended state work for me either. I wonder if it was a good intent from the writers of the API, but something about it is fatally broken.

Anyway, Played to End does work. Don't know what the difference is internally, but that's the one you need to use.
 

CodeYan

Member
The way macro conditions are evaluated is always from top to bottom within each macro.
So if you have macro with conditions...

IF A
OR B
AND C
OR NOT D

It will be evaluated as (((A OR B) AND C) OR NOT D).

In case of the "Macro" condition type, the value of whatever the conditions of the specified macro resulted in the last time the macro was checked is simply reused (and not re-evaluted in place).

To give an example, let's call the example above "Macro 1" and reuse in this setup:

IF X
AND Y
AND NOT "conditions of 'Macro 1' are true"
OR Z

This would effectively result in:

(((X AND Y) AND NOT (((A OR B) AND C) OR NOT D)) OR Z)

I hope this is somewhat clear.
If not please let me know :)
I see, thank you. So if I do the multiple conditions for hourly time range, and I want to add an AND condition, I can simply add 1 AND at the end for the extra condition (although ofc I'll still put the hourly time range conditions in a separate macro).

That being said, trying it made me encounter a bug with the Date condition, where it seemed like you were converting the time to UTC, but fails to convert it back (happens on switching between macros back and forth). Will try to provide screenshots or a video later.
 

Warmuptill

Active Member
Apologies in advance if this is a dumb question but - I'm working on a film festival, and trying to set OBS up to easily play blocks of films. For example, for a simpler one - I have one preroll video file and one movie file. I've tried putting them both in a VLC playlist and playing that, but the playlist restarts when the movie is over. When I try to make a macro to switch to the next scene when the playlist ends (using that Media state Ended(playlist)), it doesn't work. Is there a simple way to build out these blocks of videos to just play through once?
This will be a bit tricky unfortunately.
Internally the VLC source only supplies the "ended" state.
This is however triggered even after a single playlist item ends, but the playlist has still items remaining.

I added the "Ended(Playlist)" condition type to work around this limitation.
It works by checking if the selected media source reports the "ended" state for an extended period of time.

An issue now arises as you have configured the playlist to contentiously loop.
This means that neither the "Ended" or the "Ended(Playlist)" check will work to detect the end of the playlist.

You can however work around this by disabling the "Loop playlist" option in the VLC source's settings and letting the scene switcher do the restart of the playlist by doing something similar to this:

VLCEndedExample.PNG


Now you can rely on the "Ended(Playlist)" check to detect the end of the VLC playlist. (Even in other macros)

Sorry that this is so complicated, but this is the best solution I could think of with what the OBS media state API provided.
I will try to document this behaviour / limitation in the wiki once I have the time to.

Hope that clears things up a bit.
Let me know if you have any questions!
 
Top