Skip to content

medlib

A MED module is a Blitz object, numbered from 0: a MED or OctaMED module in the MMD0 or MMD1 format, in chip memory. LoadMedModule loads one from disk, DecodeMedModule takes one that is already in memory, and StartMedModule prepares it and starts it from the beginning.

The library has no interrupt of its own: the music moves on one step each time the program calls PlayMed, which is meant to happen once every vertical blank, after a VWait in the main loop or in a vertical blank interrupt handler:

LoadMedModule 0,"song.med"
StartMedModule 0
SetInt 5
  PlayMed
End SetInt
MouseWait
StopMed

GetMedNote, GetMedInstr and GetMedVolume tell what a channel plays, for graphics that follow the music. SetMedMask keeps channels free for sound effects.

The player is the MED V3 player by Teijo Kinnunen. It plays tracks 0 to 3 of a module, one on each of the four channels of the Amiga, and ignores the notes and commands of tracks 4 to 15.

Based on the medlib guide by Acid Software.

Library number 82. It manages MedModule objects, by default at most 8 (the compiler options set the maximum).

Commands

DecodeMedModule

Makes the MED module that is already in memory at the address the module of the object, for example one included in the program. A module in chip memory is used where it is, others are copied to chip memory.

Statement. Help text: MedModule#,MemoryLocation
Arguments: .w, .l

GetMedInstr

The instrument of the last note on the channel, and 0 after it has been read once.

Function, result .w. Help text: Channel
Arguments: .w

GetMedNote

The last note played on the channel, and 0 after it has been read once, for example for graphics that follow the music.

Function, result .w. Help text: Channel
Arguments: .w

GetMedVolume

The volume the channel plays at, from its last note or volume command. Unlike GetMedNote and GetMedInstr, it does not become 0 when it has been read.

Function, result .w. Help text: Channel
Arguments: .w

Fixed in the port: the original set the volume to 0 when it was read, which silenced the channel until its next note; a program that used that 0 to see a new note uses GetMedNote (#212).

JumpMed

Makes the song go on at the given entry of its play sequence, counted from 1, from its first line. With runtime error checking, a call without a playing module is the error “No Module Playing”.

Statement. Help text: Pattern#
Arguments: .w

LoadMedModule

Loads a MED module from disk into chip memory; a module the object held before is freed. Amiga mode only. A file that cannot be opened is the error “Can’t Open Med Module”; a file that is not a MED module leaves the object empty.

Statement. Help text: MedModule#,Name
Arguments: .w, $

MedModule

The object of a MED module, as the introduction describes.

Object name. No help text.

PlayMed

Plays one step of the started module; call it once every vertical blank, after VWait or in a vertical blank interrupt handler. Without a started module it does nothing.

Statement. No help text.
No arguments.

SetMedMask

Which channels the module may use, as a channel mask (bit 0 for channel 0, 15 for all four), to keep the others free for sound effects. StartMedModule sets it to 15.

Statement. Help text: Channel Mask
Arguments: .w

SetMedVolume

Sets the overall volume of the module for all its tracks, in place of the master volume stored in the song; lowering it step by step fades the music out.

Statement. Help text: Volume
Arguments: .w

StartMedModule

Prepares the module for playing and starts it from the beginning; it also restarts a module that plays. All four channels are used again. An object without a module is the error “Med Library Error”.

Statement. Help text: MedModule#
Arguments: .w

StopMed

Stops the module and silences the channels. PlayMed then does nothing until the next StartMedModule.

Statement. No help text.
No arguments.