It is currently December 1st, 2021, 5:43 pm

Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Help with creating, editing & fixing problems with skins
User avatar
CodeCode
Posts: 797
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Post by CodeCode »

Hello, Here I am with another question

I have these due to the configuration of some systems as in not having both a subwoofer and a Center channel. So instead of a empty channel, I am cloning either the center or subwoofer, depending on if they are receiving signal, or not:

Code: Select all

[MeasureAudioRMS_C]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
IfCondition=MeasureAudioRMS_C<0.001
IfTrueAction=[!SetVariable DeadC "LFE"][!Update]
IfFalseAction=[!SetVariable DeadC "C"][!Update]
Channel=#DeadC#
Type=RMS

[MeasureAudioRMS_LFE]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
IfCondition=MeasureAudioRMS_LFE<0.001
IfTrueAction=[!SetVariable DeadSub "C"][!Update]
IfFalseAction=[!SetVariable DeadSub "LFE"][!Update]
Channel=#DeadSub#
Type=RMS
I tried this as well (just putting one up here):

Code: Select all

[MeasureAudioRMS_C]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
IfCondition=MeasureAudioRMS_C<0.001
IfTrueAction=[!SetVariable DeadC "LFE"][!Update]
IfFalseAction=[!SetVariable DeadC "C"][!Update]
IfCondition2=MeasureAudioRMS_LFE<0.001 && MeasureAudioRMS_C<0.001
IfTrueAction2=[!SetVariable DeadC "AVE"][!Update]
IfFalseAction2=[!SetVariable DeadC "C"][!Update]
Channel=#DeadC#
Type=RMS

[MeasureAudioRMS_LFE]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
IfCondition=MeasureAudioRMS_LFE<0.001
IfTrueAction=[!SetVariable DeadSub "C"][!Update]
IfFalseAction=[!SetVariable DeadSub "LFE"][!Update]
IfCondition2=MeasureAudioRMS_LFE<0.001 && MeasureAudioRMS_C<0.001
IfTrueAction2=[!SetVariable DeadSub "AVE"][!Update]
IfFalseAction2=[!SetVariable DeadSub "LFE"][!Update]
Channel=#DeadSub#
Type=RMS
Thing is the second two do not produce expected results of using another channel to mimic a live channel, that may be nonexistent for an end user.
I tried this as well: IfCondition2=((MeasureAudioRMS_LFE<0.001) && (MeasureAudioRMS_C<0.001))
But obviously that didnt work, or I wouldn't be mentioning it.

THANKS, for any help. :great:
CC
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
balala
Rainmeter Sage
Posts: 13511
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Post by balala »

CodeCode wrote: October 6th, 2021, 8:15 am Thing is the second two do not produce expected results of using another channel to mimic a live channel, that may be nonexistent for an end user.
I tried this as well: IfCondition2=((MeasureAudioRMS_LFE<0.001) && (MeasureAudioRMS_C<0.001))
But obviously that didnt work, or I wouldn't be mentioning it.
CC
Having only two measures not all of them, it's quite hard to say, but it does work for me with a sample code I wrote. So post the whole code if you still need assistance.

Additional note: when using two or more conditions into the same IfCondition option, you have to use parenthesis, otherwise doesn't work (so as you tried use IfCondition2=((MeasureAudioRMS_LFE<0.001) && (MeasureAudioRMS_C<0.001)) instead of IfCondition2=MeasureAudioRMS_LFE<0.001 && MeasureAudioRMS_C<0.001, which for sure can't work. However if tried it this way as well and didn't work, something else is going on there).
User avatar
CodeCode
Posts: 797
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Post by CodeCode »

7.1 Upmix VU Meter_1.2b.rmskin
Here is the whole config.

Thanks more for helping me figure this out.
You do not have the required permissions to view the files attached to this post.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Rainmeter Sage
Posts: 1204
Joined: April 24th, 2021, 8:13 pm

Re: Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Post by death.crafter »

CodeCode wrote: October 6th, 2021, 8:15 am
Well, here is a tip on tackling logical operations:

1. First note down all the possibilities that can be there, you may miss something and add them later, but first note down all that comes to you.
2. Note down all the results that you need.
3. Then make a logical map of what leads to what, and through which way, "and","or","not" or other combinations. This is where usually mistakes happen.
4. Then make the measures that process the data you get, check the required conditions and execute the actions that give you the results.
5. Don't use real time data to debug your logic, never.
6. Make a measure that changes with your interaction, test your logic measure with that measure first.
7. Always, always keep the log open and check if you are getting the correct results for all the possibilities you listed down.
8. If you think something is not working right, check for the condition you set up for that possibility.
9. If nothing works right, check your conditions again, more carefully this time, in case you are missing something, may be another possibility.
10. This is the last step. Ask for help. :D
from the Realm of Death
User avatar
death.crafter
Rainmeter Sage
Posts: 1204
Joined: April 24th, 2021, 8:13 pm

Re: Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Post by death.crafter »

Also,

IfCondition2=MeasureAudioRMS_LFE<0.001 && MeasureAudioRMS_C<0.001

is wrong as,
Examples:

IfCondition=MeasureName >= 10

IfCondition=MeasureOne = (MeasureTwo + #VarName#) / 2

IfCondition=(MeasureName > 5) && (MeasureName < 10)

IfCondition=(MeasureName = 25) || (MeasureName = 50) || (MeasureName = 75)

Note: The comparison on either side of logical AND && and OR || operators must be enclosed in (parentheses).
So this becomes:

IfCondition2=(MeasureAudioRMS_LFE<0.001) && (MeasureAudioRMS_C<0.001)
from the Realm of Death
User avatar
balala
Rainmeter Sage
Posts: 13511
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Post by balala »

CodeCode wrote: October 6th, 2021, 11:18 am Here is the whole config.

Thanks more for helping me figure this out.
What is not working? Because I get everything working well. But just note that both the [MeasureAudioRMS_C] and the [MeasureAudioRMS_LFE] measures are always returning 0, never above (at least for me). Check this.
How am I sure the IfConditions are working? By moving them to measures which are returning greater values. For instance:

Code: Select all

[MeasureAudioRMS_L]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
Channel=L
IfCondition=(#CURRENTSECTION#<0.001)
IfTrueAction=[!SetVariable DeadC "LFE"][!Update]
IfFalseAction=[!SetVariable DeadC "C"][!Update]
Type=RMS

[MeasureAudioRMS_R]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
Channel=R
IfCondition=(#CURRENTSECTION#<0.001)
IfTrueAction=[!SetVariable DeadSub "C"][!Update]
IfFalseAction=[!SetVariable DeadSub "LFE"][!Update]
Type=RMS
(see that replaced the names of measures by #CURRENTSECTION# in the IfCondition options, to get them working always with the current measures and also added the parentheses).
This step makes me absolutely sure the IfConditions are working well. I suppose they are as well on the initial measures ([MeasureAudioRMS_C] and [MeasureAudioRMS_LFE]) as well, but since these measures are always returning 0, you see them like they wouldn't work. My guess at least...
User avatar
balala
Rainmeter Sage
Posts: 13511
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Post by balala »

death.crafter wrote: October 6th, 2021, 12:12 pm Also,

IfCondition2=MeasureAudioRMS_LFE<0.001 && MeasureAudioRMS_C<0.001

is wrong as,



So this becomes:

IfCondition2=(MeasureAudioRMS_LFE<0.001) && (MeasureAudioRMS_C<0.001)
This has been clarified by both, the author (last paragraph here) and me (Additional note here).
User avatar
death.crafter
Rainmeter Sage
Posts: 1204
Joined: April 24th, 2021, 8:13 pm

Re: Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Post by death.crafter »

balala wrote: October 6th, 2021, 5:51 pm This has been clarified by both, the author (last paragraph here) and me (Additional note here).
Ohh sorry, didn't see that :oops:
from the Realm of Death
User avatar
CodeCode
Posts: 797
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Post by CodeCode »

balala wrote: October 6th, 2021, 5:48 pm What is not working? Because I get everything working well.
Alright. I have added this code, and the values are changing in the log:

Code: Select all

[MeasureAudioRMS_C]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
IfCondition=(#CURRENTSECTION# < 0.001)
IfTrueAction=[!SetVariable DeadC "LFE"][!Update]
IfFalseAction=[!SetVariable DeadC "C"][!Update]
IfCondition2=(MeasureAudioRMS_LFE < 0.001) && (MeasureAudioRMS_C < 0.001)
IfTrueAction2=[!SetVariable DeadC "Ave"][!Update]
IfFalseAction2=[!SetVariable DeadC "LFE"][!Update]
OnChangeAction=[!Update]
Channel=#DeadC#
Type=RMS

[MeasureAudioRMS_LFE]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
IfCondition=(#CURRENTSECTION# < 0.001)
IfTrueAction=[!SetVariable DeadSub "C"][!Update]
IfFalseAction=[!SetVariable DeadSub "LFE"][!Update]
IfCondition2=(MeasureAudioRMS_LFE < 0.001) && (MeasureAudioRMS_C < 0.001)
IfTrueAction2=[!SetVariable DeadSub "Ave"][!Update]
IfFalseAction2=[!SetVariable DeadSub "LFE"][!Update]
OnChangeAction=[!Update]
Channel=#DeadSub#
Type=RMS
What that is all bout, is me trying to find workaround/s for zero value channels (in the case of my concern these are usually center channel and subwoofer channel.

The top works to a charm. The dead or silent center channel is seeing the condition and setting the Channel to mirror the subwoofer channel.
IfCondition=(#CURRENTSECTION# < 0.001)
IfTrueAction=[!SetVariable DeadC "LFE"][!Update]

So I have been experimenting to cover the contingencies of silent channels. But when I disable the channel/s with the exception of the one positively is working, nothing is happening.
The actual question is in the list of channels has something for full 8ch stereo (or upmixed pseudo 7.11) - the one value i thought would average "Ave" to again cover the dead channel, by having it mimic Ave or the LFE in the top Ifcondition=

Is the AVE Value not really an average of all channels? I also tried to use the Sum value as well but with no progress.
The log shows that channels are being renamed, but there must be something I am missing, or it isnt possible the way I am trying.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 797
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using IfCondition for AudioLevel Channel Option - Syntax/Logic Confusion.

Post by CodeCode »

As per usual, I made things too complicated.

Instead of having the clone channel, for a channel with no direct output for, I simplified the code, and now use Ave for center or subwoofer - so if either channel is dominant, thus disabling the other an inactive channel VU would have now the info to use the Ave channel option.

Before I was trying to set the channel, then set the channel again. This verily crashed rainmeter a couple times - but that was my poor syntax.

So now Channel=Ave is the go to surrogate VU channel when C or Sub are not producing output.

Lakia deece:

Code: Select all

[MeasureAudioRMS_C]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
IfCondition=(#CURRENTSECTION# < 0.001)
IfTrueAction=[!SetVariable DeadC "AVE"][!Update]
IfFalseAction=[!SetVariable DeadC "C"][!Update]
OnChangeAction=[!Update]
Channel=#DeadC#
Type=RMS

[MeasureAudioRMS_LFE]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
IfCondition=(#CURRENTSECTION# < 0.001)
IfTrueAction=[!SetVariable DeadSub "AVE"][!Update]
IfFalseAction=[!SetVariable DeadSub "LFE"][!Update]
OnChangeAction=[!Update]
Channel=#DeadSub#
Type=RMS
Testing seems inconsistent though, and I am not sure this is even a true fix for dead channel.
This above code 'should work' if someone has center on and sub off, or vice versa.
But if both are 'dead' they are not producing signal, but the safety net Ave option seems yo only work in the first instance - applying it later on with no refresh of rainmeter may show poor or no result.

This is a dusty area of AudioLevel Plugin, as there is really nothing about using Ave dynamically. That much is considered in the RM manual as an option that CAN BE handled with bangs or other variables. So that is not why this idea seems limited, and I cannot test it more than anyone else as I have only one computer as do most ppl)
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.