AGBMidi

From GameBrew

AGBMidi
Agbmidi2.png
General
AuthorRuben Nunez (AikenToAki)
Last Updated2008/12/12
TypeMedia players
Version1.0a
LicenseMixed
Links
Download
Website

AGBMidi is a MIDI player targeted at the GBA.

Features

  • 4 configurable music players.
  • 8 frequency setting (10512, 11468, 13379, 18157, 20068, 21024, 26758 and 31536 Hz).
  • 32 fully panable channels.
  • 128 point reverb setting.
  • Frequency can be changed without altering sounds or music.
  • Average speed mixing routines (~1.8% CPU per channel, non-looped or quick looped* @ 18157Hz).
  • Slightly above average RAM consumption. (~4.5KB EWRAM, ~3.1KB IWRAM).
  • Plays MIDI (MOD and S3M support planned).

User guide

The demos included in the Demo folder are identical, except for Demo2.

  • Demo1 shows the engine's capabilities without interpolation.
  • Demo2 shows the engine's capabilities with interpolation.

Check readme file for more information.

Converter

The AGBMidi converter is a MIDI type 0 with tick-based timing converter.

Usage: agbmidi_conv file1.mid [file2.mid ...]

However, there is a small note about the converter:

  • The converter itself will output song data just fine, but it needs a sample bank (not included).
  • (Though even without a sample bank, song data is still exported).

The converter will look in the "PatchDat" directory for patch files. It should be structured like so:

root
  |-PatchDat
  |   |-Patch0
  |   |   |-Patch0.amp
  |   |   |-Patch0_0.dat
  |   |   |-Patch0_1.dat
  |   |   |...
  |   |-Patch1
  |   |   |-Patch1.amp
  |   |   |-Patch1_0.dat
  |   |   |...

Drum kits are set out as the drum kit number plus 128. For example, Standard1 (127:000) would be Patch128. Standard2 (127:001) would be Patch129. Etc.

File format Patch[].amp:

AMP stands for 'Agb Midi Patch.' It is a little-endian file. The format is set out as (in psuedo-C)...

patch {
 s8  volume;   //Volume  control
 s8  tune;     //Tuning  control
 u16 attack;   //Attack  envelope (.8 fixed point)
               //This is the value x increments with until reaching 127
               //Note on to enter this stage
 u16 decay;    //Decay   envelope (.8 fixed point)
               //This is the value y decrements with until reaching 0
               //Enters this state after attack is over
 u16 releas;   //Release envelope (.8 fixed point)
               //This is the value z decrements with until reaching 0
               //Key off to enter this stage

 u8  smpcnt;   //Sample count
 u8  smpdat[]; //The range to which this sample goes to.
               //For example...
               //{65, 89, 98, 127} (MIDI Key numbers, including C-1)
               //This would indicate that sample 0 (Patch_0.dat)
               //ranges from 0..65
               //Then sample 1 (Patch_1.dat) ranges from 66 (65+1)
               //to 89. Then sample 2 ranges from 90 to 98, etc.
}

File format Patch[]_[].dat:

DAT stands for "Data." It is also a little-endian file. This is also the format SFX files use. The format is (also set out in psuedo-C)...

sample {
 u16 root;   //Root key (MIDI key-style, including C-1) (Ignored by SFX)
 u16 stat;   //Status (4000h: Forward loop, 0h: No loop)
 u32 freq;   //Frequency calculation value (Frequency in a .10 format)
 u32 loop;   //Loop start position
 u32 size;   //Sample length/Loop end position (limited to 1MB)
 u8  data[]; //Sample data. This is unsigned, linear sample data in 8 bit
             //formatting. Convert from/to s8/u8 by XOR'ing 128.
}

Controls

Up/Down - Select the song/variable

Left/Right - Adjust

Compatibility

Does not work well with no$gba.

External links