Creating Instruments

The aRts Handbook
Prev | Chapter 5. MIDI | Next

# 5.5. Creating Instruments

The way aRts does midi synthesis is this: you have a structures which has some input ports, where it gets the frequency, velocity (volume) and a parameter which indicates whether the note is still pressed. The structure should now synthesize exactly that note with that volume, and react on the pressed parameter (where pressed = 1 means the user still holds down that key and pressed = 0 means the user has released that key).

When midi events arrive, aRts will create new structures for the notes as needed, give them the parameters, and clean them up once they are done.

To create and use such a structure, you should do the following:

- To get started, the most convenient way is to open template_Instrument.arts in artsbuilder. This can be achieved by using File->Open Example... and choosing template_Instrument in the file selector. This will give you an empty structure with the required parameters, which you only need to "fill out".

- To process the pressed parameter, it is convenient to use Synth_ENVELOPE_ADSR, or, in case of playing some drum wav, just play it anyway, and ignore the pressed parameter.

- The structure should indicate when it is no longer needed on the "done" output. If done is 1, aRts assumes that it can delete the structure. Conveniently, the ADSR envelope provides a parameter when it is done, so you just need to connect this to the done output of the structure.

- You should rename your structure to some name starting with instrument_, like instrument_piano.arts - you should save the file under the same name, in your $HOME/arts/structures directory (which is where artsbuilder wants to save files normally).

- Finally, once you saved it, you will be able to use it with artscontrol in the midi manager .

- Oh, and of course your structure should play the audio data it generates to the left and right output of the structure, which will then be played via audio manager (you can see that in artscontrol), so that you finally can hear it (or postprocess it with effects).

A good way to learn how to do instruments is to open an existing instrument via File+Open Example and see how it works ;)

Prev | Home | Next
midisend | Up | Mapped Instruments