59 lines
2.5 KiB
Plaintext
59 lines
2.5 KiB
Plaintext
SPS allows you to program signal processing using simple expressions.
|
||
|
||
Many aspects of SPS code are similar to C (including comments).
|
||
|
||
You can create new variables just by using them, and you can read
|
||
and write predefined variables (of which each effect has its own)
|
||
to interact with the effect. Note that variables are all floating
|
||
point numbers (no strings), and the maximum length of a variable's
|
||
name is 8 characters (anything longer will be ignored).
|
||
|
||
So, to create a variable, you can simply use it, for example:
|
||
x = 5;
|
||
|
||
You can also use a variety of operators and math functions to
|
||
modify variables, see the Operators and Functions tabs above.
|
||
|
||
Code can include C and C++ style comments:
|
||
// using the doubleslash comments until the end of the line
|
||
/* using the classic C comments
|
||
comment a block of text */
|
||
|
||
You can combine operators and functions into expressions, such
|
||
as:
|
||
x = 5 * cos(y) / 32.0; // this does some leetness right here
|
||
|
||
You can use multiple expressions by seperating them with one or
|
||
more semicolons, for example:
|
||
x = x * 17.0; x = x / 5; y = pow(x,3.0);
|
||
|
||
It is worth noting that extra whitespace (spaces, newlines) is
|
||
ignored, so if you need to space things out for clarity, you can.
|
||
|
||
Variables that are predefined for your effect to use:
|
||
nch: number of channels of PCM stream (1 or 2)
|
||
srate: samplerate of stream (i.e. 44100)
|
||
slider1, slider2, slider3, slider4: the four sliders. Each has a range of 0.0..1.0
|
||
trig1, trig2, trig3, trig4: the four trigger buttons. These should be reset to 0.0
|
||
by your code when you've caught the trigger
|
||
|
||
Variables that your per-sample code can modify to apply its effect:
|
||
spl0 = left/mono channel sample, -1.0..1.0
|
||
spl1 = right channel sample, if nch == 2, -1.0..1.0
|
||
skip = set this to > 0 to drop the current sample and not output it
|
||
(this effectively can be used to speed up the output
|
||
repeat = set this to > 0 to process this sample again after
|
||
outputting (this effectively can be used to slow down
|
||
the output. Note that the most you can slow down the
|
||
output due to Winamp architecture limitations is by 50%)
|
||
|
||
Now to the important part, how to actually make meaningful effects:
|
||
A simple volume control might be:
|
||
spl0 = spl0*slider1; spl1=spl1*slider1;
|
||
To slow down the output to half speed:
|
||
tmp=bnot(tmp); repeat=tmp;
|
||
To speed up the output to double speed:
|
||
tmp=bnot(tmp); skip=tmp;
|
||
To swap left and right channels:
|
||
tmp=spl0; spl0=spl1; spl1=tmp;
|
||
etc |