It is currently April 24th, 2024, 2:54 am

Sound Visualization uses up 30% CPU

Get help with creating, editing & fixing problems with skins
Benjirich
Posts: 7
Joined: October 13th, 2015, 7:14 am

Sound Visualization uses up 30% CPU

Post by Benjirich »

Hello guys,

I've took some code from someone else which name I don't remember (sorry man!) but I only use this script for private use. Still I need to share it here for someone to look at it.

It's a speaker that reacts to bass and gets bigger and shakes. I've got two of them, the other one is for high frequency sounds. As soon as I start one up my CPU usage goes up by 30%, using both doesn't make much difference. I tried to set down the fft size but it didn't do much. Here is the code:
Could it be because of the math?

Code: Select all

[Rainmeter]
Update=10
DynamicWindowSize=1

[Variables]
MaxExtrude=200
MinSize=500
MaxWobble=10
WobbleSensitivity=2

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
Bands=3
FFTSize=1024
;FFTOverlap=1024
FFTAttack=20
FFTDecay=80
FreqMin=20
Sensitivity=10

[MeasureAudioRMS_0]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Type=Band
Bandidx=0

[Counter_0]
Measure=Calc
Formula=ROUND([MeasureAudioRMS_0] * #MaxExtrude#) + #MinSize#
DynamicVariables=1
IfCondition=(Counter_0 > ((#MaxExtrude# + #MinSize#) - ((#MaxExtrude#) / #WobbleSensitivity#)))
IfTrueAction=[!SetOption WOBBLE Formula "Random"]
IfFalseAction=[!SetOption WOBBLE Formula ""]

[WOBBLE]
Measure=Calc
LowBound=0
HighBound=#MaxWobble#
UniqueRandom=0
DynamicVariables=1

[Minus_r]
Measure=Calc
Formula=Random
LowBound=-1
HighBound=1
UpdateRandom=1
DynamicVariables=1

[Minus_r2]
Measure=Calc
Formula=Random
LowBound=-1
HighBound=1
UpdateRandom=1
DynamicVariables=1

[MeterImage]
Meter=Image
ImageName="speaker.png"
X=(((#MinSize# / 2) - ([Counter_0] / 2)) + (#MaxExtrude# / 2) + ([Minus_r] * [WOBBLE]))
Y=(((#MinSize# / 2) - ([Counter_0] / 2)) + (#MaxExtrude# / 2) + ([Minus_r2] * [WOBBLE]))
W=[Counter_0]
H=[Counter_0]
DynamicVariables=1
PreserveAspectRatio=1
EDIT: I forgot to add that I am using 2 spectrum analyzers aswell but they don't use much CPU, maybe 5%. My CPU also isn't very bad, it's mid-end (Intel i5)
User avatar
exper1mental
Posts: 269
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University

Re: Sound Visualization uses up 30% CPU

Post by exper1mental »

Sound and audio visualization skins are notorious for being CPU hogs. On my i7-3630QM this skin 7-10% of my CPU which seems about right depending on which i5 you're using. The best way I know to get better performance in visualization skins is to increase Update= under [Rainmeter].

Update=10 is what you used and eats 7-10% of my CPU. This setting also causes my i7 to start increasing it's MHz speed above the minimum 1197MHz.
Update=50 still looks pretty good but eats 5% of my CPU. This is probably what I'd recommend trying.
Update=100 looks a bit choppy but eats only 2.5% of my CPU

At the end of the day you'll have to decide what balance of performance and quality you like best.

Hope that helps!
Image
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Sound Visualization uses up 30% CPU

Post by balala »

I'd just add to what exper1mental wrote, that in fact the Update=10 is a totally wrong value. The lowest possible value for Update is 16 (read the second sentence here). With Update=10 the skin will work the same way as with Update=16.
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: Sound Visualization uses up 30% CPU

Post by dgrace »

If your sound card runs at a very high sample rate (96khz, 192khz) that will also bump things up quite a bit. Also if you're running your card in 7.1 vs 2-channel audio.

If all you want is a speaker throbbing, you might try using RMS levels rather than doing a full FFT on the audio stream.

dave
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: Sound Visualization uses up 30% CPU

Post by dgrace »

Just read your edit - are you saying you're running 3 separate parent AudioLevel measures? Keep in mind that each one of those is requesting a full stream of all the audio data from the sound card, which is a pretty expensive thing. You generally only ever want one Parent AudioLevel measure per machine.

Also in the skin you posted, you're doing a 1024-point FFT, and then interpolating it into 3 bands, which basically does a lot of math and then throws away the results. If you only need 3 bands, try a smaller FFT. (or change it to RMS which is a lot cheaper)

dave