1st Ever Jesusonic Tutorial

From CockosWiki

(Difference between revisions)
Jump to: navigation, search
Line 105: Line 105:
-
== CHAPTER 3 - STEREO CHANNEL SWAP ==
+
== CHAPTER 03 - STEREO CHANNEL SWAP ==
This FX will swap the stereo channels
This FX will swap the stereo channels
Line 138: Line 138:
  spl0 = spl1;
  spl0 = spl1;
  spl1 = tmp;
  spl1 = tmp;
 +
 +
== CHAPTER 04 - ECHO ==
 +
 +
Start with the settings:
 +
 +
desc:Echo
 +
slider1:120<0,1000,1>Length [ms]
 +
@slider
 +
 +
Converting from ms (i.e. milliseconds) to samples
 +
 +
echolength = slider1 / 1000 * srate ;
 +
 +
Note: 'slider1 / 1000' gives us the value in seconds and this is then
 +
multiplied with the current samplerate ('srate' you may look this up in
 +
your documentation) to get the corresponding number of samples.
 +
 +
 +
@sample
 +
 +
To create a echo, we need to store the current audio stream to replay it
 +
again later. The best way to do this is to use Jesusonics FX buffer.
 +
Just imagine the buffer to be a filing cabinet with alot of drawers, with each
 +
drawer having its own number (offset). So we just put the current sample into
 +
the buffer with the offset 'bufpos', for later playback.
 +
Read Documentation ("Reference" - "Operators" - "[ ]") to learn more
 +
about the buffer.
 +
 +
bufpos[0] = spl0 ;
 +
 +
Now we incrementing our buffer offset 'bufpos'
 +
 +
bufpos = bufpos + 1 ;
 +
 +
Now we need to check if the 'bufpos' has already reached our echo length.
 +
If so we have to reset it to the start i.e. zero (0).
 +
To do this we will use the '?' and '>' operators.
 +
 +
bufpos > echolength ? bufpos = 0;
 +
 +
This piece of code is basicly asking:
 +
Is 'bufpos' greater than 'echolength' (the 'bufpos > echolength' part),
 +
if so then set 'bufpos' to zero (the 'bufpos = 0' part).
 +
 +
Look this up in the Documentation ("Reference" - "Operators" - "?" and ">"),
 +
to get more information on the '?' and '>' operators.
 +
 +
And now we mix our echo buffer back to the signal.
 +
"How that? We have just stored it?"
 +
Yeah, but we have moved our offset, so we are 1 item ahead in the buffer
 +
and so our courser ('bufpos') points to the item we stored exactly 'echolength'
 +
samples ago (which is our echo length). So it is about time to mix it to the
 +
current sample.
 +
 +
Just write this in order to mix 'spl0' with the buffer
 +
 +
spl0 = spl0 + bufpos[0] ;
 +
 +
Since a one sided echo sounds strange we just add the following to make it mono
 +
 +
spl1 = spl0 ;
 +
 +
Full code:
 +
 +
desc:Echo
 +
slider1:120<0,1000,1>Length [ms]
 +
 +
@slider
 +
echolength = slider1 / 1000 * srate ;
 +
 +
@sample
 +
bufpos[0] = spl0 ;
 +
bufpos = bufpos + 1 ;
 +
bufpos > echolength ? bufpos = 0;
 +
spl0 = spl0 + bufpos[0] ;
 +
spl1 = spl0 ;

Revision as of 20:55, 10 February 2007

This is the Wiki adaption of LOSER's 1st Ever Jesusoinc Tutorial. It is transfered right now and may be unfinished at the moment.

Contents

CHAPTER 01 - MUTE

This FX will be a simple FX that mutes the output. So the describtion will be 'Mute'. To define a describltion you just add 'desc:' and after that you write a short describtion of your FX Like this:

desc:Mute

We do not need any '@init', '@slider', '@block', or '@serialize' code so we can just omit them, since writing them isn't required, when you don't need them.

Now to mute the output we need to manipulate the samples. To maniplulate samples we need to set up the '@sample' code, everything in (i.e. following the '@sample' line) is executed every and each sample the plug-in is running. So we just add our '@sample' code to do this.

@sample

To mute 'spl0' (left sample) and 'spl1' (right sample) we just set them to zero, by typing the following

spl0 = 0;
spl1 = 0;

The full code:

desc:Mute

@sample
spl0 = 0;
spl1 = 0;


CHAPTER 02 - VOLUME ADJUST

This FX will be a simple volume adjust plug-in. So the description will be:

desc:Volume

As we want the user to be able to adjust the volume, we need to give him/her a slider. To do this we just add:

slider1: 0 < -120 , 60 , 1 >Volume [dB]

READ: Documentation: "Effect Format" - "2. 'slider' definition(s)" to get some more information about what this syntax does and the values we just set.


As we do not need any '@init', '@block', or '@serialize' code, we omit it.

But what we need to do is to convert the 'slider1' variable (from the user input) from dB into its amplitude value. This conversion needs some calculation so to save CPU we just convert whenever the slider is changed.

To do this we use the '@slider' code, which is called only when sliders are changed, look this up in your documentation to get more information on it.

@slider

To convert from dB to amplitude and store this as the variable 'volume', we just type:

volume = 2 ^ ( slider1 / 6 );

What this conversion does, is to convert
0 dB To 1
-6 dB To 0.5
6 dB To 2
and so forth... Try searching for "dB" or decibel on "wikipedia.org" or "google.com" for more information on this subject.

Now to adjust the volume of the output we need to manipulate the samples. So we put our '@sample' code.

@sample

To adjust the Volume of 'spl0' (left sample) and 'spl1' (right sample) we simply multiply them with our 'volume' variable, thus add this:

spl0 = spl0 * volume;
spl1 = spl1 * volume;


Full code:

desc:Volume
slider1: 0 < -120 , 60 , 1 >Volume [dB]

@slider
volume = 2 ^ ( slider1 / 6 );

@sample
spl0 = spl0 * volume;
spl1 = spl1 * volume;


CHAPTER 03 - STEREO CHANNEL SWAP

This FX will swap the stereo channels

desc:Stereo Channel Swap

not needed stuff omited

@sample

To swap 'spl0' with 'spl1' we store 'spl0' in a temporary variable 'tmp' (the name doesn't matter)

tmp = spl0;

Now since we have the value of 'spl0' saved in 'tmp' we can assign 'spl0' the value of 'spl1'

spl0 = spl1;

and now we assign 'spl1' the value of 'tmp' (since we can't use 'spl0' anymore).

spl1 = tmp;

Full code:

desc:Stereo Channel Swap

@sample

tmp = spl0;
spl0 = spl1;
spl1 = tmp;

CHAPTER 04 - ECHO

Start with the settings:

desc:Echo
slider1:120<0,1000,1>Length [ms]
@slider

Converting from ms (i.e. milliseconds) to samples

echolength = slider1 / 1000 * srate ;

Note: 'slider1 / 1000' gives us the value in seconds and this is then multiplied with the current samplerate ('srate' you may look this up in your documentation) to get the corresponding number of samples.


@sample

To create a echo, we need to store the current audio stream to replay it again later. The best way to do this is to use Jesusonics FX buffer. Just imagine the buffer to be a filing cabinet with alot of drawers, with each drawer having its own number (offset). So we just put the current sample into the buffer with the offset 'bufpos', for later playback. Read Documentation ("Reference" - "Operators" - "[ ]") to learn more about the buffer.

bufpos[0] = spl0 ;

Now we incrementing our buffer offset 'bufpos'

bufpos = bufpos + 1 ;

Now we need to check if the 'bufpos' has already reached our echo length. If so we have to reset it to the start i.e. zero (0). To do this we will use the '?' and '>' operators.

bufpos > echolength ? bufpos = 0;

This piece of code is basicly asking: Is 'bufpos' greater than 'echolength' (the 'bufpos > echolength' part), if so then set 'bufpos' to zero (the 'bufpos = 0' part).

Look this up in the Documentation ("Reference" - "Operators" - "?" and ">"), to get more information on the '?' and '>' operators.

And now we mix our echo buffer back to the signal. "How that? We have just stored it?" Yeah, but we have moved our offset, so we are 1 item ahead in the buffer and so our courser ('bufpos') points to the item we stored exactly 'echolength' samples ago (which is our echo length). So it is about time to mix it to the current sample.

Just write this in order to mix 'spl0' with the buffer

spl0 = spl0 + bufpos[0] ; 

Since a one sided echo sounds strange we just add the following to make it mono

spl1 = spl0 ;

Full code:

desc:Echo
slider1:120<0,1000,1>Length [ms]

@slider
echolength = slider1 / 1000 * srate ;

@sample
bufpos[0] = spl0 ;
bufpos = bufpos + 1 ;
bufpos > echolength ? bufpos = 0;
spl0 = spl0 + bufpos[0] ; 
spl1 = spl0 ;
Personal tools