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

Add implementation to rotate visualizer #5

Closed marcopixel closed 7 years ago

marcopixel commented 7 years ago

Requested by multiple people on Reddit and on DeviantArt.

marcopixel commented 7 years ago

If anyone got some tips or tricks to do this, please write them here or send a pull request.

tjhrulz commented 7 years ago

Well I was gonna just suggest just setting the bar orientation option to horizontal but I see that doesn't quite produce the effects the user wanted. With a bit of tweaking you could probably get that to work using that option.

The other more fun (aka hard) option would be to try to use a transformation matrix, but I am not sure that bar meters support that.

tjhrulz commented 7 years ago

After some testing if they were to change ScriptFactoryBars to the code below it should work, even keeps intact the flip variable so it can work in either direction still. Probably the easiest way would be maybe have a ScriptFactoryBars and a ScriptFactoryBars90 that enable or disable themselves based on an orientation variable.

If this is implemented should similar changes be made to song information to support it being vertical?

[ScriptFactoryBars] Measure=Script ScriptFile=#@#scripts\Factory.lua IncFile=#@#include\MeterBars.inc Number=#BarCount# SectionName=MeterBar%% Option0=Meter Value0=BAR Option1=Group Value1=GroupBarColor Option2=MeasureName Value2=MeasureAudioSmoothed{%%} Option3=X Value3=0 Option4=Y Value4=(#BarGap#*#ScaleVisualizer#)R Option5=W Value5=#BarHeight# Option6=H Value6=(#BarWidth#*#ScaleVisualizer#) Option7=BarOrientation Value7=Horizontal Option8=Flip Value8=#FlipVisualizer# UpdateDivider=-1

tjhrulz commented 7 years ago

Just realized that if this is added would you also want to base the visualizer scale to be based on screen height instead of width. Not a big deal if it is not though as the scale as separate now.

eclectic-tech commented 7 years ago

Hi MarcoPixel!

Been an admirer of your work and thought I would offer a TransformationMatrix to 'tilt' your visualizer. This general formula will work for a few degrees of positive tilt before clipping will occur. SkinWidth, SkinHeight, X & Y values would need to be adjusted to compensate for clipping, positioning, and negative rotation. ;/ Not perfect, or complete, but perhaps you can use it as a start.

[Rainmeter]
Group=Spectrum
Update=16

SkinHeight=((#BarCount#*(#BarWidth#+#BarGap#)*#ScaleVisualizer#)*1.25)
SkinWidth=((#BarCount#*(#BarWidth#+#BarGap#)*#ScaleVisualizer#)*1.5)
....
[Variables]
; Includes the variables/styles used for the skin.
@include=#@#variables.ini
; Include MeasureGenre and Chameleon for dynamic colors.
@include2=#@#include\Measure#MPMode#.inc
@include3=#@#include\MeasureStyling.inc
Rotation=5
...
[ScriptFactoryBars]
Measure=Script
ScriptFile=#@#scripts\Factory.lua
IncFile=#@#include\MeterBars.inc
Number=#BarCount#
SectionName=MeterBar%%
Option0=Meter
Value0=BAR
Option1=Group
Value1=GroupBarColor
Option2=MeasureName
Value2=MeasureAudioSmoothed{%%}
Option3=X
Value3=(#BarGap#*#ScaleVisualizer#)R
Option4=Y
Value4=(10*#ScaleVisualizer#+(#BarHeight#*2))
Option5=W
Value5=(#BarWidth#*#ScaleVisualizer#)
Option6=H
Value6=#BarHeight#
Option7=BarOrientation
Value7=Vertical
Option8=Flip
Value8=#FlipVisualizer#
Option9=TransformationMatrix
Value9=(Cos(Rad(#Rotation#)));(-Sin(Rad(#Rotation#)));(Sin(Rad(#Rotation#)));(Cos(Rad(#Rotation#)));(#CURRENTSECTION#:X-#CURRENTSECTION#:X*Cos(Rad(#Rotation#))-#CURRENTSECTION#:Y*Sin(Rad(#Rotation#)));(#CURRENTSECTION#:Y+#CURRENTSECTION#:X*Sin(Rad(#Rotation#))-#CURRENTSECTION#:Y*Cos(Rad(#Rotation#))
UpdateDivider=-1

I am not a math wiz, and only draw on the wisdom of others, and time. Hope this help in some small way.

marcopixel commented 7 years ago

Hey @eclectic-tech, thanks for your post!

I have also tried it myself with a similar approach and i also never got it fully working. It seems that to get it working propertly i have to offset the bars but i don't know where to get the values for it. So i'm pretty much stuck for now. I also tried to get some insight by looking at the Fountain of Colors skin but i didn't get that much out of it.

I've still trying to get it work tho, so hang tight.

eclectic-tech commented 7 years ago

Yes, getting the initial positioning for bar 0 is key, and I am not sure how to calculate that either.

I have successfully modified the factory script to let me write multiple sets of meters; first script writes a new file, and the rest append to it. I did this to write rings, dots, and bars/circles in my visualizer using multiple factory measures.

I also modified it to let me use an alternate single line of the first meter; I use that to position bar 0. You might find it useful... so it is attached (I am a novice lua coder, so you may be able to improve it).

My skin issue is writing a script to automatically generate gradient colors for a varying number of bars... it's no problem with a set number, but no success yet for a user selected number... :(

Factory.zip

marcopixel commented 7 years ago

Added to master branch with commit ec91a9d09e6a378b37cff409822634f76c8b58df

alatsombath commented 7 years ago

Hi MarcoPixel, sorry for the late reply, congrats on the new release! It is working and looks great as the intended.

If necessary I did prepare edits that does not include Initialize skin or Rotate.lua, if it is a more familiar skin structure (but is also the older version)

To preserve users old settings, I also recommend saving #@#Variables in the skin installer (though default variables that you changed will not update)

(To implement there is also the new Shape meter with a Skew feature, but I did not read how it works yet)

marcopixel commented 7 years ago

Hi @alatsombath, thanks for your reply :)

Thanks for your feedback and I really love your skins, they are quite something different. So far I have used the code base from the 3.6.11 version of your skin and so far it working fine so I think I will keep it that way.

I also thought about preserving the #@#variables file via the built-in installer but I also did some heavy reworks in the last few updates and at that time I thought it was an bad idea. But now I think the current settings are final so far, so I think I will implement that in the next release.

For the Shape meter I also haven't read too much of the documentation, but it seems to be quite flexible with special shapes. This might be more interesting for my Lano Visualizer and your skins, as the Monstercat one is strictly set to keep the original video looks.

Many thanks for your help 👍