Home Next

ALab User Tutorial Part 1

ALab is a java package for creating experimental sounds. In this tutorial we will create some sounds by using the available classes. After we have done this, we will create a class using the available classes of ALab to build complexer structures and provide methods for easy access to this structures.

First of all we will generate noise. ARandom is used for generating random values, that sound like noise. To store this values to disc we use the class AContainer and its method write(). If you want to listen to the result, you need a tool that can read raw PCM coded data or you put a fileformat header at the beginning of the output stream. The following example creates stereo noise at 44100kHz and 16Bit of one half second length.

noise (all tutorial java-files can be found in docs/tutorial/examples)

Now we will create a sine at 440Hz using the class ASin. With the class AAmp we will control the amplitude of the sine. The first example creates a 440Hz sine with 90% of the maximal amplitude. The second example creates a sine with full amplitude at start but no amplitude (silence) after a half second. This changing amplitude value can be done by modulating the amplitude with the method setAmpMod(). We use a ARamp as modulator, but could use any other AObject (eg. ARandom or ASin) as well.

sine1, sine2

Instead of an ASin, we could also use any other subclass of AWave (eg. ATri or ASaw) as well.

In the next example we will create an envelope and control the amplitude of a sound by this envelope. We will build a complexer sound by using frequency modulation (FM). All subclasses of AWave can do FM by setting the frequency modulator with the method setFreqMod(). FM sounds very interesting and we will use it in several examples again. To avoid writing the same code again we will create a method that returns a FM sound. We can use this method later again. We call this method ASinFM() and put it in a class called AExample.

FM (frequency modulation)

Because we will use envelopes in several examples, we will create a method generating envelopes, too. The method will be called AEnv(). It uses any AObject and modulates its amplitude by a typical ADSR envelope. First we will create an AContainer filled with several ARamps and then this container will be multiplied with the input object with the help of an AMul. At last we use both methods and create a sound with them.

envelope, envFM (enveloped FM sound)

Now we build a delay. The method will be called ADelay() and will return an AObject that not only plays itself, but plays itself a couple of times. It starts as usual, but after a certain amount of samples it will sound again like an echo. Our delay will be able to play itself several times, each echo sounding darker and darker. To reach this effect we have to amplify the delays and filter them. AAvg (average) can be used as a lowpass filter. The original sound will not be filtered, but all echos will be filtered, depending on their appearance. The last echo is filtered most. We will generate this filtered sounds and mix them, but befor mixing them, we have to move them in time. The original sound is not moved, but each echo is moved backwards a little bit. This movement can be done with AMove. To mix all echos we will create an method AMix() that addes two objects with certain amplitudes. At last we take our FM sound and use it for our delay.


delay

We can use our delay to create a reverb. Our reverb will simply use a couple of delays with different delaytimes. The delays will be amplified, so that the mix of all delays cannot be above the maximal amplitude value. Then we will use the reverb at our FM sound. For faster calculation we use an ABuffer that buffers the enveloped sound. If we would not buffer it, the values of the sound would have to be calculated several times (eg: a delay with 4 echos needs to calculate the values of the sound 5 times; a reverb with 3 of such delays needs the values 15 times).

reverb

The first part of the user tutorial is almost finished. At last we create a method that mixes all channels of an AObject to one (mono). We use ASplit to split one channel out of an object. The second method removes very low disturbing noises and offsets by subtracting the lowpass average values from the original values. We use ASub for subtracting and AAvg for filtering. And we add a wait parameter to our envelope generator by adding an additional ramp (always zero) before starting with the envelope. Now our usefull class AExample is finished.

AExample

In the next part of the user tutorial we will learn how to handle tables and what we can do, to avoid recalculating complex sounds.

Home Next