Interfaces and IDL
Prev
Next

Interfaces and IDL

Many of the services provided by aRts, such as modules and the sound server, are defined in terms of interfaces. Interfaces are specified in a programming language independent format: IDL.

This allows many of the implementation details such as the format of multimedia data streams, network transparency, and programming language dependencies, to be hidden from the specification for the interface. A tool, mcopidl, translates the interface definition into a specific programming language (currently only C++ is supported).

The tool generates a skeleton class with all of the boilerplate code and base functionality. You derive from that class to implement the features you want.

The IDL used by aRts is similar to that used by CORBA and DCOM.

IDL files can contain:

In IDL, interfaces are defined much like a C++ class or C struct, albeit with some restrictions. Like C++, interfaces can subclass other interfaces using inheritance. Interface definitions can include three things: streams, attributes, and methods.

Streams

Streams define multimedia data, one of the most important components of a module. Streams are defined in the following format:

[ async ] in|out [ multi ] type stream name [ , name ] ;

Streams have a defined direction in reference to the module, as indicated by the required qualifiers in or out. The type argument defines the type of data, which can be any of the types described later for attributes (not all are currently supported). Many modules use the stream type audio, which is an alias for float since that is the internal data format used for audio stream. Multiple streams of the same type can defined in the same definition uisng comma separated names.

Streams are by default synchronous, which means they are continuous flows of data at a constant rate, such as PCM audio. The async qualifier specifies an asynchronous stream, which is used for non-continuous data flows. The most common example of an async stream is MIDI messages.

The multi keyword, only valid for input streams, indicates that the interface supports a variable number of inputs. This is useful for implementing devices such as mixers that can accept any number of input streams.

Attributes

Attributes are data associated with an instance of an interface. They are declared like member variables in C++, and can can use any of the primitive types boolean, byte, long, string, or float. You can also use user-defined struct or enum types as well as variable sized sequences using the syntax sequence<type>. Attributes can optionally be marked readonly.

Methods

As in C++, methods can be defined in interfaces. The method parameters are restricted to the same types as attributes. The keyword oneway indicates a method which returns immediately and is executed asynchronously.

Standard Interfaces

Several standard module interfaces are already defined for you in aRts, such as StereoEffect, and SimpleSoundServer.

Example

A simple example of a module taken from aRts is the constant delay module, found in the file tdemultimedia/arts/modules/artsmodules.idl. The interface definition is listed below.

interface Synth_CDELAY : SynthModule {
        attribute float time;
        in audio stream invalue;
        out audio stream outvalue;
};

This modules inherits from SynthModule. That interface, defined in artsflow.idl, defines the standard methods implemented in all music synthesizer modules.

The CDELAY effect delays a stereo audio stream by the time value specified as a floating point parameter. The interface definition has an attribute of type float to store the delay value. It defines two input audio streams and two output audio streams (typical of stereo effects). No methods are required other than those it inherits.

Prev
Next
Home


Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team