View Single Post
Old 29th September 2001, 18:27   #3
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
Different explanation

I found Linus' explanation to be a bit unclear so here's my way of explaining the superscope:

A superscope is basically a renderer that draws either dots, or the lines between these dots. You have to write code that, at the end, outputs a set of x,y coordinates for each point to be drawn. X ranges from -1 to 1 and is the horizontal coordinate, Y ranges from -1 to 1 and is the vertical coordinate. Some examples:

(0,0) - the center of the AVS screen
(-1,-1) - the top-left of the AVS screen
(0,1) - the center of the bottom border of the AVS screen
(0.8,0.9) - a point near the bottom right

The variable n is used to set the number of points to calculate each frame. Higher n means slower presets, so don't use huge numbers if it's not needed.

The variable i is different for each point and is a percentage that tells you which point you're drawing. For example:
- first point: i=0 (0%)
- last point: i=1 (100%)
- the 50th point of a 150 point superscope: i=0.33333... (33%)

The variable v is also different for each point and contains the current sound value for this point (either oscilloscope- or spectrumdata, depending on your choice).

If you click the 'help' button, you'll see all the functions you can use. Experiment with them if you don't know what they do exactly.

So now we'll make a basic superscope:
Init: n=300;t=0;tpi=acos(-1)*2;
Beat: t=t+rand(200)/50
Frame: t=t-0.05;rad=sin(t)/2+0.5
Point: x=cos(i*tpi)*(rad+v/5);y=sin(i*tpi)*(rad+v/5)

This will seem very complex at first, but let's look at it step by step:

Init - First we set n to 300, so that the superscope draws 300 different points. We also set the variable t to 0. Then, we set the variable tpi to twice the arc-cosine of -1. If you do the math, that means 2 times Pi (6.28....). Don't worry, it's just a trick to prevent you from having to type the number pi yourself, which is a useful number.

On Beat - Every beat, the variable t will be increased by a random integer number from 0-200, divided by 50. So that means a random decimal number from 0.00 to 4.00.

Per Frame - Every frame we decrease the t value slightly. We also calculate rad by taking the sine of t and scaling it a bit. If you know that a sine is a repetive wave-shape and that t is decreased slightly each frame, then you'll understand that the rad value will slowly pulse from 0 to 1 and back, except every beat. Then t gets modified drastically and the rad value jumps.

Per Point - Here we do the actual points. In our equation x and y are coordinates of a point on a circle. The circle has radius rad plus the current sound-value divided by 5. To make sure we traverse a full circle, we multiply i (range 0-1) with 2 times pi, so we get a range of 0-6.28...

Now you have a superscope that draws a spectrum or oscilloscope circle with a jumpy radius.

Another aspect of the superscope is colour. You can either use the (boring) color selector at the bottom, or you can write your own equations for the variables red, green and blue. They range from 0-1 and contain the value for their color. Let's spice up our superscope by adding this to the "on beat" equation:

cr=rand(100)/100;cg=rand(100)/100;cb=rand(100)/100;

And this to "per frame":

red=cr;green=cg;blue=cb;

What's going on here? Every beat we set cr, cg and cb to a random value in the range 0-1. Every frame, we assign these three to red, green and blue. Couldn't we just assign them directly 'on beat'? Nope... AVS resets them every frame with the color defined by the color-selector at the bottom.

So there you have your own groovy, color-changing superscope. It looks neat if you remove the t-changing on beat and combine it with a Trans / Water filter.
UnConeD is offline   Reply With Quote