The K Desktop Environment

Next Previous Table of Contents

7. Tutorial

7.1 Step 1

Start artsbuilder.

You need a Synth_PLAY-module to hear the output you are creating. The third parameter (channels) should be set to 1 or 2 to select mono or stereo sound. So create a Synth_PLAY-module by selecting Modules/Synth_PLAY and clicking on the empty module space. Put it below the fifth line or so, because we'll add some stuff above.

To select the number of voices doubleclick on channels (the rightmost port of the module), select constant value and type 2 in the edit box. Click okay to apply.

Hit File/Execute structure. You will hear absolutely nothing. The play module needs some input yet... ;) If you have listened to the silence for a while, click okay and go to Step 2

7.2 Step 2

Create a Synth_WAVE_SIN module and put it above the Synth_PLAY module. (Leave one line space in between). As you see, it produces some output, but requires a "pos" as input. First lets put the output to the speakers. Click on the "out" port of the Synth_WAVE_SIN and then on the "left" port of Synth_PLAY. Voila, you have connected two modules.

All oscillators in aRts don't require a frequency as input, but a position in the wave. The position should be between 0 and 1, which maps for a standard Synth_WAVE_SIN object to the range 0..2*pi. To generate oscillating values from a frequency, a Synth_FREQUENCY modules is used.

Create a Synth_FREQUENCY module and connect it's "pos" output to the "pos" input of your Synth_WAVE_SIN. Specify the frequency port of the FREQUENCY generator as constant value 440.

Hit File/Execute structure. You will hear a sinus wave at 440 Hz on one of your speakers If you have listened to it for a while, click okay and go to Step 3.

7.3 Step 3

Ok, it would be nicer if you would hear the sin wave on both speakers. Connect the right port of Synth_PLAY to the outvalue of the Synth_WAVE_SIN as well.

Create a Synth_SEQUENCE object. It should be at the top of the screen. If you need more room you can move the other modules by selecting them (to select multiple modules use Shift), and dragging them around.

Now connect the frequency output of Synth_SEQUENCE to the frequency input of the Synth_FREQUENCY module. Then specify the sequence speed as constant value 0.13 (the speed is the leftmost port).

Now go to the rightmost port (sequence) of Synth_SEQUENCE and type in as constant value A-3;C-4;E-4;C-4; this specifies a sequence. More to that in the Module Reference.

Note: Synth_SEQUENCE really _needs_ a sequence and the speed. Without that you'll perhaps get core dumps.

Hit File/Execute structure. You will hear a nice sequence playing. If you have enjoyed the feeling, click okay and go to Step 4.

7.4 Step 4

Create a Synth_PSCALE Module. Disconnect the outvalue of the SIN wave by doubleclicking it and choosing "not connected". Connect

Finally, set the PSCALE top to some value, for instance 0.1.

How that works now: The Synth_SEQUENCE gives additional information about the position of the note it is playing right now, while 0 means just started and 1 means finished. The Synth_PSCALE module will scale the audio stream that is directed through it from a volume 0 (silent) to 1 (original loudness) back to 0 (silent). According to the position. The position where the peak should occur can be given as pos. 0.1 means that after 10% of the note has been played, the volume has reached its maximum, and starts decaying afterwards.

Hit File/Execute structure. You will hear the sequence with scaled notes. If you have enjoyed the feeling, click okay and go to Step 5.

7.5 Step 5: Starting to beam data around ;)

Start another artsbuilder

Put a Synth_PLAY into it, configure it to two channels. Put a Synth_BUS_DOWNLINK into it and

Start executing the structure. As expected, you hear nothing, ... not yet

Go back to the structure with the Synth_WAVE_SIN stuff and replace the Synth_PLAY module by an Synth_BUS_UPLINK, and configure the name to audio (or fred if you like). Deleting modules works with selecting them and choosing edit/delete from menu (or pressing the del key).

Hit File/Execute structure. You will hear the sequence with scaled notes, transported over the bus, which is not so loud as before, because the bus can carry 8 clients.

If you want to find out why something like this can actually be useful, click okay (in the artsbuilder that is executing the Synth_SEQUENCE stuff, you can leave the other one running) and go to Step 6.

7.6 Step 6: Beaming for advanced users

Choose File/Rename structure from the menu of the artsbuilder which contains the Synth_SEQUENCE stuff, and call it tutorial. Hit okay.

Choose File/Publish

Huh? What has happened now? - The aRts server contains a central repository of known structures. (Or better: their descriptions, how the modules must be connected to get such a structure). In later aRts versions, you will probably have descriptions of a few houndred structures, from orchestra instruments, to various effect processors, mixing devices, "standalone synthesizers" etc. lying around at the server, and then can use them from a composing program... but we're not yet there.

Anyway, your structure has just been put into that repository.

To see that this has happened, start yet another artsbuilder and choose File/Retrieve. You'll see your tutorial structure being offered. Pick it and you see: this artsbuilder has now got the same structure in the editor as the other one.

Hit File/Execute structure. In both artsbuilders having that structure. You'll now hear two times the same thing. Depending on the time when you start it it will sound more or less nice.

7.7 Step 7: Midi synthesis

Finally, now you should be able to turn your sin wave into an real instrument. This only makes sense if you have something handy that could send midi events to arts. I'll describe here how you can use some external keyboard, but Cantor will work as well.

First of all, clean up on your desktop until you only have two artsbuilders running (both not executing), one with the tutorial, the other with the play structure (lets call it base structure). Then go to the tutorial structure and replace the Synth_SEQUENCE module by a Interface_MIDI_NOTE module. Connect it's frequency to the Synth_FREQUENCY object. You'll see that this one, however, has no pos output.

This is because with no algorithm in the world, you can predict when the user will release the note he just pressed on the midi keyboard. So there's a pressed parameter instead that just indicates wether the user still holds down the key. (pressed = 1: key still hold down, pressed = 0: key released)

That means the Synth_PSCALE object also must be replaced now. Plug in a Synth_ENVELOPE_ADSR instead. Connect

Set the parameters attack to 0.1, decay to 0.2, sustain to 0.7, release to 0.1.

Another thing we need to think of is that the instrument structure somehow should know when it is ready playing and then kill itself, because otherwise it would be never stopped even if the note has been released. Fortunately, the ADSR envelope knows when the will be nothing to hear anymore, since it anyway scales the signal to zero at some point after the note has been released.

This is indicated by setting the done output to 1. Take a Synth_STRUCT_KILL module and connect it to the done output of the ADSR envelope. It will kill the structure as soon as done goes up to 1.

Publish your instrument structure on the server (it is still called tutorial and will overwrite the old definition).

Go to the other artsbuilder and insert a Synth_MIDI_ROUTER module. Set it's channel to 0, it's max to 4 and it's structure to tutorial. It will now listen for midi events on channel 0, and every time it gets one create one of our tutorial structures, which will in turn create some sine wave and write it to the bus. By the way: set the "bus" parameter if the MIDI_ROUTER to some dummy value, say "audio", I'll explain that later. Also ignore the other stuff like x,y,parent.

Hit File/Execute structure (in the artsbuilder with the base structure only, as executing an instrument without giving the frequency is pointless).

Open a terminal and type midisend. Take your keyboard and start playing (of course it should be connected to your computer). If you see that there is plenty of CPU power remaining, you can probably increment the max setting of the MIDI_ROUTER allowing 8 or perhaps even more voices to be calculated.

7.8 Making a real instrument

...TODO... Well ok, this section needs to be written. If you are curious how to make a "real" instrument that is accepted by the instrument mapper (and probably even have an own control panel for that), read about "instruments" in the concepts section. ...END TODO...

7.9 Suggestions

You now should be able to work with arts. Here are a few tips what you could try to improve with your structures now:

If you have created something great, please send an mpg sample (and/or the structure itself) to our Web Master, so that we can show something on our pages ;).

Next Previous Table of Contents