marcopixel / monstercat-visualizer

A real time audio visualizer for Rainmeter similar to the ones used in the Monstercat videos.
MIT License
920 stars 103 forks source link

Dynamic Sensitivity #12

Closed jacklul closed 7 years ago

jacklul commented 7 years ago

It would be cool feature if the sensitivity could adjust itself depending on player's set volume.

Currently using this to achieve something similar with Spotify:

[Rainmeter]
Update=1000
AccurateText=1

[Metadata]
Author=Jack'lul

[Dummy]
Meter=STRING
X=0
Y=0

[getSpotifyPID]
Measure=Plugin
Plugin=Perfmon.dll
PerfMonObject="Process"
PerfMonCounter="ID Process"
PerfMonInstance=Spotify
PerfMonDifference=0

[isSpotifyRunning]
Measure=Calc
Formula=getSpotifyPID > 0 ? 1 : 0
IfEqualValue=0
IfEqualAction=!Execute [!DeactivateConfig "Monstercat-Visualizer\Song Information" "Spotify.ini"][!DeactivateConfig "Monstercat-Visualizer" "visualizer.ini""]
IfAboveAction=!Execute [!ActivateConfig "Monstercat-Visualizer\Song Information" "Spotify.ini"][!ActivateConfig "Monstercat-Visualizer" "visualizer.ini"]

[getSpotifyVolume]
Measure=Plugin
Plugin=SpotifyPlugin.dll
Type=Volume

[adjustVisualizerSensitivty]
Measure=Calc
Formula=[getSpotifyVolume]
DynamicVariables=1
IfCondition=([getSpotifyVolume] <= 10)
IfTrueAction=[!WriteKeyValue Variables Sensitivity 120 "#SKINSPATH#\Monstercat-Visualizer\@Resources\variables.ini"][!RefreshGroup "Spectrum"]
IfCondition2=([getSpotifyVolume] > 10) && ([getSpotifyVolume] <= 20)
IfTrueAction2=[!WriteKeyValue Variables Sensitivity 100 "#SKINSPATH#\Monstercat-Visualizer\@Resources\variables.ini"][!RefreshGroup "Spectrum"]
IfCondition3=([getSpotifyVolume] > 20) && ([getSpotifyVolume] <= 30)
IfTrueAction3=[!WriteKeyValue Variables Sensitivity 80 "#SKINSPATH#\Monstercat-Visualizer\@Resources\variables.ini"][!RefreshGroup "Spectrum"]
IfCondition4=([getSpotifyVolume] > 30) && ([getSpotifyVolume] <= 40)
IfTrueAction4=[!WriteKeyValue Variables Sensitivity 70 "#SKINSPATH#\Monstercat-Visualizer\@Resources\variables.ini"][!RefreshGroup "Spectrum"]
IfCondition5=([getSpotifyVolume] > 40) && ([getSpotifyVolume] <= 50)
IfTrueAction5=[!WriteKeyValue Variables Sensitivity 60 "#SKINSPATH#\Monstercat-Visualizer\@Resources\variables.ini"][!RefreshGroup "Spectrum"]
IfCondition6=([getSpotifyVolume] > 50) && ([getSpotifyVolume] <= 60)
IfTrueAction6=[!WriteKeyValue Variables Sensitivity 50 "#SKINSPATH#\Monstercat-Visualizer\@Resources\variables.ini"][!RefreshGroup "Spectrum"]
IfCondition7=([getSpotifyVolume] > 60) && ([getSpotifyVolume] <= 80)
IfTrueAction7=[!WriteKeyValue Variables Sensitivity 40 "#SKINSPATH#\Monstercat-Visualizer\@Resources\variables.ini"][!RefreshGroup "Spectrum"]
IfCondition8=([getSpotifyVolume] > 80)
IfTrueAction8=[!WriteKeyValue Variables Sensitivity 30 "#SKINSPATH#\Monstercat-Visualizer\@Resources\variables.ini"][!RefreshGroup "Spectrum"]

(This also disables visualizer when Spotify is not running - might also consider a feature like this?)

But it would be cool if user could specify 'min' and 'max' value and it would autoscale depending on volume!

And thanks for making this visualizer skin, it's awesome. 👍

marcopixel commented 7 years ago

Hey, thanks for your request.

On first glance your code seems pretty cool, but it's limited to Spotify. The big problem is player support right now, where not every player supports the volume variable and also not every player outputs the same value. So it's quite hard to do it consistently.

I'm gonna keep this issue open for now but if i can't find a proper solution in the next few days i will close this issue. Maybe someone with some more Rainmeter knowledge can jump in here and propose a proper solution.

tjhrulz commented 7 years ago

I know my plugin supports volume, but I am not sure what how many of the NowPlaying players support it and what the default value is in the ones that dont. If the default value is 100 then we can safely add it. The bigger issue will be potentially when the player is closed.

Edit: looking closer at it all but WLM players support volume.

marcopixel commented 7 years ago

Ok, thats one first thing but how consistent are those values between the players? Because for example 50 in AIMP is not the same as 50 in Spotify.

jacklul commented 7 years ago

Updated to better way of doing this:

[Rainmeter]
Update=1000

[Variables]
MinSensitivity=30
MaxSensitivity=120

[Dummy]
Meter=STRING

[getSpotifyVolume]
Measure=Plugin
Plugin=SpotifyPlugin.dll
Type=Volume

[calculateVisualizerSensitivity]
Measure=Calc
Formula=((100 - [getSpotifyVolume]) / 100) * #MaxSensitivity#
DynamicVariables=1

[adjustVisualizerSensitivity]
Measure=Calc
Formula=([calculateVisualizerSensitivity] >= #MinSensitivity#) ? (([calculateVisualizerSensitivity] <= #MaxSensitivity#) ? [calculateVisualizerSensitivity] : #MaxSensitivity#) : #MinSensitivity#
DynamicVariables=1
OnChangeAction=[!WriteKeyValue Variables Sensitivity "[adjustVisualizerSensitivity]" "#SKINSPATH#\Monstercat-Visualizer\@Resources\variables.ini"][!RefreshGroup "Spectrum"]

MaxSensitivity = set at volume 0, kinda pointless MinSensitivity = as the volume goes up makes sensitivity never go below this value

marcopixel commented 7 years ago

I have decided to close this issue for now, because there is sadly no constant way to dynamically adjust the sensitivity via volume for now. If you want to use it for Spotify, use the code from @jacklul above.

I will reopen the issue if there will be an easier way to do this in the future.