Next: 4.3 Calling conventions Up: 4 The system Previous: 4.1 Overview of system

# 4.2 Description of all modules

## 4.2.1 Sound Devices

Sound Devices are at the very heart of MIDAS. They provide the basic functionality for playing audio, they manage the samples loaded in the system, and provide a common programming interface for all supported sound hardware. Normally a user does not use the Sound Devices directly, but rather uses MIDAS upper level programming interfaces and libraries to play sound. However, internally MIDAS is very much centered around Sound Devices, and anyone doing any lower-level MIDAS programming or just examining the system source code can't avoid working with them.

A single Sound Device can contain information for one or more sound card. In that case the cards are usually different models of the same sound card - for example, the Sound Blaster series Sound Device includes five different sound card types: Sound Blaster 1.0, 1.5, 2.0, Pro and 16.

Internally, a Sound Device is represented by one large data structure. The structure contains a set of variables for configuring the Sound Device, plus a number of function pointers. These function pointers are then used to call the Sound Device functions. This ensures that any code working with MIDAS Sound Devices only has to maintain a pointer to the current Sound Device structure in use, and can use any supported Sound Device without code modification.

## 4.2.2 Generic Module Player

Generic Module Player, or GMPlayer for short, takes care of all module playing in MIDAS. Modules in different formats are converted to GMPlayer internal gmpModule structure format when loaded to memory, so that a single module player can handle all formats. To maintain best possible compatibility with all trackers, however, GMPlayer implements some commands and features differently depending on the original module format. This ensures that playback quality is not compromised.

GMPlayer is not limited for playing a single module only, in fact it can be used to play an unlimited number of songs simultaneously. This way sound effects can be composed as small song fragments, to eliminate the need for long samples.

GMPlayer is not dependent on the underlying sound hardware -- it operates as easily with no sound output at all as it does with an advanced wavetable sound card. At initialization phase, GMPlayer is passed a pointer to the Sound Device that should be used for music playback, and afterwards it directs all sounds to that Sound Device.

## 4.2.3 MIDAS kernel

The MIDAS "kernel" consists of smaller modules used by all system components. This includes memory management functions, error handling routines, file management functions and common utility functions. These kernel functions ensure that MIDAS does not depend on the underlying operating system any C runtime libraries -- all dependencies are encapsulated in single modules.

Next: 4.3 Calling conventions Up: 4 The system Previous: 4.1 Overview of system