- AVS Troubleshooting
- Logarithmic spec?
Archive: Logarithmic spec?
romulusnr
16th August 2004 20:34 UTC
Logarithmic spec?
Someone must have figured this out, but I can't find any tips on it.
How can I base my vis on a logarithmic spectrum?
Right now I do (basically) getspec(i,1/n,0) to get the values of points across the spectrum. (This is theoretically equivalent to using just 'v' in spectrum mode, right?)
Is there any function/equation I can apply to 'i' to achieve a logarithmic spec scale? (I suppose to do it right, I'd also want to alter the second argument to getspec(), to truly get the space between logarithmic points...)
TIA.
PAK-9
17th August 2004 06:00 UTC
I can think of a couple of things you might mean, your either talking about:
* having a scope where x=2*i-1 and y= some spectrum value, but the y value is increased logarithmically along x.
* or having a scope where you sample from the waveform such that the scope sample point is derived logarithmically from the x, essentially giving you more low spectrum values and less high ones.
I doubt your talking about the first one because it would just be planting scope values onto a logarithmic curve and so wouldnt look very interesting.
The second one would be an interesting scope although you would need to tweak the equation a lot to keep your sampling range between 0 and 1, you'd probably be better off doing a hack than a true logarithm in the interests of speed, or you could precache logarithms into the megabuffer.
vanderphunck
17th August 2004 10:19 UTC
I think i know what you mean. I've been thinking about it aswell. Rather than getting the power in a specific frequency band then getting it in a "noteband".
I think the SSC below is doing it:
[frame]
f=.5/exp(1); //this sets the center frequency your scope will look at... (it can not span the entire spectrum.. Think of freq=0)
[Point]
x=2*i-1;
note=i; //maybe you'd like to scale it...
notefreq=exp(note)*f;
y=getspec(notefreq,notefreq*.01,0);
PAK-9
17th August 2004 11:38 UTC
I've been thinking about it (and drawing graphs on litte bits of paper here at work)
usually you would use a linear scale, so the position along the x of your ssc is the position in the scope you want to display, i.e.
y=getspec(x,0.1,0);
assuming your ssc only goes from 0-1, and you want the ample width to be 0.1... you could use i instead of x of course, but i'll use x for simplicity. So you could also have a nice exponential scale, which is simply:
y=getspec(pow(x,2),0.1,0);
or you could raise it to any power you like, since we're working between 0 and 1 it will always scale correctly (0 to any power is 0 and 1 to any power is 1). Apply the same principles to a logarithmic y:
y=getspec(pow(2,x)/2,0.1,0);
thats a base 2 logarithm, the division by 2 is necessary this time to keep it between 0 and 1. You can do any base log tho, its just:
y=getspec(pow(base,x)/base,0.1,0);
There you go, an unneccessarily long-winded reply :igor:
Tuggummi
17th August 2004 13:04 UTC
Uhm... excuse to sound stupid but isn't there a log() function in avs?
per frame
n=w
per pixel
x=i*2-1 ;
brng=0.5 ;
y=-getspec(log(x+2)*brng,0,0)+0.5 ;
^ just some random scriblings, nevermind ^
Well anyway, to answer to the question: "Can I alter i" inside the getspec function, then the answer is yes :)
You can use whatever you want there.
getspec(voodocode1,voodoocode2,voodoocode3)
Should work as long as the code itself ain't b0rked :)
PAK-9
17th August 2004 15:30 UTC
Uhm... excuse to sound stupid but isn't there a log() function in avs?
Well....yea....but thats far too easy. :hang:
romulusnr
17th August 2004 20:09 UTC
Thanks for the ideas... I ended up doing (basically) getspec(pow(i,10),0,0) to get more or less what I was looking for.
For the curious, the point of this was to create a spectral analysis timescope that would allow me to do the same thing as this:
http://www.visualizationsoftware.com...example15.html
Attached is a screenshot of the best I've gotten so far, with vis I used.
I suppose I could better (i.e. less blocky) results if I used a WAV as source instead of an MP3...? or maybe this just reflects the granular limitation of the spectrum input to the vis system...
UnConeD
18th August 2004 05:20 UTC
Aphex twin ;). The spectrum input is indeed limited because it's calculated directly off the MP3 data, rather than done as an FFT afterwards.
vanderphunck
18th August 2004 09:10 UTC
Cool!
But, I think you should make the bandwidth proportional to the center frequency. Here's what i mean:
[frame]
n=h;
xp=xp%w;
xp=if(below(getspec(0,1,0),0.00001),0,xp+1);
yp=0;
[point]
freq=exp((1-i)*4-1)/30;
c=getspec(freq,freq*.1,0);
red=c;green=c;blue=c;
x=(xp+.5)*2/w-1;
y=(yp+.5)*2/h-1;
yp=yp+1;
A sidenote: I think the reason for the blocky picture is because it is made using a windowed fourier transform (with a very narrow window). The best way to extract the picture would probably be using a continous wavelet transform (I would never try that in AVS). You could probably make it look alot nicer by applying time-smoothing for low frequencies.
romulusnr
18th August 2004 18:36 UTC
Yeah, I ended up doing about the same thing (specpos/10):
int=getspec(pow(specspace*i+botspec,exponent),pow(specspace*i+botspec,exponent)*.1,0);
though not perhaps as elegantly...