summaryrefslogtreecommitdiffstats
path: root/tde-i18n-de/docs/kdemultimedia/artsbuilder/apis.docbook
blob: 331fa1482d658f3e127ffa63508a657562195eba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<!-- <?xml version="1.0" ?>
<!DOCTYPE chapter PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" "dtd/kdex.dtd">
To validate or process this file as a standalone document, uncomment
this prolog. Be sure to comment it out again when you are done -->

<chapter id="arts-apis">
<title
>&arts; Application Programming Interfaces</title>

<sect1 id="api-overview">
<title
>Überblick</title>
<para
>aRts is not only a piece of software, it also provides a variety of APIs for a variety of purposes. In this section, I will try to describe the "big picture", a brief glance what those APIs are supposed to do, and how they interact. </para>

<para
>There is one important distinction to make: most of the APIs are <emphasis
> language and location independent</emphasis
> because they are specified as <emphasis
>mcopidl</emphasis
>. That is, you can basically use the services they offer from any language, implement them in any language, and you will not have to care whether you are talking to local or remote objects. Here is a list of these first: </para>


<variablelist>
<varlistentry>
<term
>core.idl</term>
  <listitem
><para
>Basic definitions that form the core of the MCOP functionality, such as the protocol itself, definitions of the object, the trader, the flow system and so on. </para
></listitem>

</varlistentry>

<varlistentry>
<term
>artsflow.idl</term>

  <listitem
><para
>These contain the flow system you will use for connecting audio streams, the definition of <emphasis
>Arts::SynthModule</emphasis
> which is the base for any interface that has streams, and finally a few useful audio objects </para
></listitem>

</varlistentry>

<varlistentry>
<term
>kmedia2.idl</term>


  <listitem
><para
>Here, an object that can play a media, <emphasis
>Arts::PlayObject</emphasis
> gets defined. Media players such as the KDE media player noatun will be able to play any media for which a PlayObject can be found. So it makes sense to implement PlayObjects for various formats (such as mp3, mpg video, midi, wav, ...) on that base, and there are a lot already. </para
></listitem>

</varlistentry>

<varlistentry>
<term
>soundserver.idl</term>

  <listitem
><para
>Here, an interface for the system wide sound server artsd is defined. The interface is called <emphasis
>Arts::SoundServer</emphasis
>, which implements functionality like accepting streams from the network, playing samples, creating custom other aRts objects and so on. Network transparency is implied due to the use of MCOP (as for everything else here). </para
></listitem>

</varlistentry>

<varlistentry>
<term
>artsbuilder.idl</term>
  <listitem
><para
>This module defines basic flow graph functionality, that is, combining simpler objects to more complex ones, by defining a graph of them. It defines the basic interface <emphasis
>Arts::StructureDesc</emphasis
>, <emphasis
>Arts::ModuleDesc</emphasis
> and <emphasis
>Arts::PortDesc</emphasis
> which contain a description of a structure, module, and port. There is also a way to get a "living network of objects" out of these connection and value descriptions, using a factory. </para
></listitem>

</varlistentry>

<varlistentry>
<term
>artsmidi.idl</term>

  <listitem
><para
>This module defines basic midi functionality, like objects that produce midi events, what is a midi event, an <emphasis
>Arts::MidiManager</emphasis
> to connect the producers and consumers of midi events, and so on. As always network transparency implied. </para
></listitem>

</varlistentry>

<varlistentry>
<term
>artsmodules.idl</term>
  <listitem
><para
>Here are various additional filters, oscillators, effects, delays and so on, everything required for real useful signal processing, and to build complex instruments and effects out of these basic building blocks. </para
></listitem>

</varlistentry>

<varlistentry>
<term
>artsgui.idl</term>

  <listitem
><para
>This cares about visual objects. It defines the basic type <emphasis
> Arts::Widget</emphasis
> from which all GUI modules derive. This will produce toolkit independency, and ... visual GUI editing, and serializable GUIs. Also, as the GUI elements have normal attributes, their values can be straight forward connected to some signal processing modules. (I.e. the value of a slider to the cutoff of a filter). As always: network transparent. </para
></listitem>

</varlistentry>

</variablelist>
<para
>Where possible, aRts itself is implemented using IDL. On the other hand, there are some <emphasis
>language specific</emphasis
> APIs, using either plain C++ or plain C. It is usually wise to use IDL interfaces where possible, and the other APIs where necessary. Here is a list of language specific APIs: </para>

<variablelist>

<varlistentry>
<term
>KNotify, KAudioPlayer (included in libtdecore)</term>

  <listitem
><para
>These are convenience KDE APIs for the simple and common common case, where you just want to play a sample. The APIs are plain C++, Qt/KDE optimized, and as easy as it can get. </para
></listitem>

</varlistentry>

<varlistentry>
<term
>libartsc</term>
  <listitem
><para
>Plain C interface for the sound server. Very useful for porting legacy applications. </para
></listitem>

</varlistentry>

<varlistentry>
<term
>libmcop</term>

  <listitem
><para
>Here all magic for MCOP happens. The library contains the basic things you need to know for writing a simple MCOP application, the dispatcher, timers, iomanagement, but also the internals to make the MCOP protocol itself work. </para
></listitem>

</varlistentry>

<varlistentry>
<term
>libartsflow</term>
  <listitem
><para
>Besides the implementation of artsflow.idl, some useful utilities like sampling rate conversion. </para
></listitem>

</varlistentry>

<varlistentry>
<term
>libqiomanager</term>

  <listitem
><para
>Integration of MCOP into the Qt event loop, when you write Qt applications using MCOP. </para
></listitem>

</varlistentry>

</variablelist>



</sect1>
<sect1 id="knotify">
<title
>knotify</title>
<para
>Noch nicht geschrieben. </para>
</sect1>

<sect1 id="kaudioplayer">
<title
>kaudioplayer</title>
<para
>Noch nicht geschrieben. </para>
</sect1>

<sect1 id="libkmid">
<title
>libkmid</title>
<para
>Noch nicht geschrieben. </para>
</sect1>

<sect1 id="kmedia2">
<title
>kmedia2</title>
<para
>Noch nicht geschrieben. </para>
</sect1>

<sect1 id="soundserver">
<title
>sound server</title>
<para
>Noch nicht geschrieben. </para>
</sect1>

<sect1 id="artsflow">
<title
>artsflow</title>
<para
>Noch nicht geschrieben. </para>
</sect1>

<sect1 id="capi">
<title
>C <acronym
>API</acronym
></title>

<sect2 id="capiintro">
<title
>Einleitung</title>

<para
>The &arts; C <acronym
>API</acronym
> was designed to make it easy to writing and port plain C applications to the &arts; sound server. It provides streaming functionality (sending sample streams to <application
>artsd</application
>), either blocking or non-blocking. For most applications you simply remove the few system calls that deal with your audio device and replace them with the appropriate &arts; calls.</para>

<para
>I did two ports as a proof of concept: <application
>mpg123</application
> and <application
>quake</application
>. You can get the patches from <ulink url="http://space.twc.de/~stefan/kde/download/artsc-patches.tar.gz"
>here</ulink
>. Feel free to submit your own patches to the maintainer of &arts; or of multimedia software packages so that they can integrate &arts; support into their code.</para>

</sect2>

<sect2 id="capiwalkthru">
<title
>Quick Walkthrough</title>

<para
>Sending audio to the sound server with the <acronym
>API</acronym
> is very simple:</para>
<procedure>
<step
><para
>include the header file using <userinput
>#include &lt;artsc.h&gt;</userinput
></para
></step>
<step
><para
>initialize the <acronym
>API</acronym
> with <function
>arts_init()</function
></para
></step>
<step
><para
>create a stream with <function
>arts_play_stream()</function
></para
></step>
<step
><para
>configure specific parameters with <function
>arts_stream_set()</function
></para
></step>
<step
><para
>write sampling data to the stream with <function
>arts_write()</function
></para
></step>
<step
><para
>close the stream with <function
>arts_close_stream()</function
></para
></step>
<step
><para
>free the <acronym
>API</acronym
> with <function
>arts_free()</function
></para
></step>
</procedure>

<para
>Here is a small example program that illustrates this:</para>

<programlisting
>#include &lt;stdio.h&gt;
#include &lt;artsc.h&gt;
int main()
{
    arts_stream_t stream;
    char buffer[8192];
    int bytes;
    int errorcode;

    errorcode = arts_init();
    if (errorcode &lt; 0)
    {
        fprintf(stderr, "arts_init error: %s\n", arts_error_text(errorcode));
        return 1;
    }

    stream = arts_play_stream(44100, 16, 2, "artsctest");

    while((bytes = fread(buffer, 1, 8192, stdin)) &gt; 0)
    {
        errorcode = arts_write(stream, buffer, bytes);
        if(errorcode &lt; 0)
        {
            fprintf(stderr, "arts_write error: %s\n", arts_error_text(errorcode));
            return 1;
        }
    }

    arts_close_stream(stream);
    arts_free();

    return 0;
}
</programlisting>
</sect2>

<sect2 id="capiartscconfig">
<title
>Compiling and Linking: <application
>artsc-config</application
></title>

<para
>To easily compile and link programs using the &arts; C <acronym
>API</acronym
>, the <application
>artsc-config</application
> utility is provided which knows which libraries you need to link and where the includes are. It is called using</para>

<screen
><userinput
><command
>artsc-config</command
>  <option
>--libs</option
></userinput
>
</screen>

<para
>to find out the libraries and </para>

<screen
><userinput
><command
>artsc-config</command
> <option
>--cflags</option
></userinput
>
</screen>

<para
>to find out additional C compiler flags. The example above could have been compiled using the command line:</para>

<screen
><userinput
><command
>cc</command
> <option
>-o artsctest artsctest.c `artsc-config --cflags` `artsc-config --libs`</option
></userinput>

<userinput
><command
>cc</command
> <option
>-o artsctest</option
> <option
>artsctest.c</option
> <option
>`artsc-config --cflags`</option
> <option
>`artsc-config --libs`</option
></userinput
>
</screen>

</sect2>

<sect2 id="c-api-reference">
<title
>Library Reference</title>

<para
>[TODO: generate the documentation for artsc.h using kdoc] </para>

</sect2>

</sect1>
</chapter>