Mpeg Audio Datafile Format Specification

MPEG audio datafile (*.m3d) is database of informations gathered from mpeg audio files. You do not need to have mpeg audio file itself to get it's info if you previously stored that info in database. This is very useful for cataloguing data when mpeg audio files are on removable media.

Main purpose of this file format is mpeg audio info distribution among applications. It may be used as personal database, or as catalogue.

It is currently supported by MPGScript MPEG audio cataloguing application and MPGTools Delphi unit for accessing informations from MPEG files.

Last updated version of this document may be found at m3dspecs.htm

File format specification

Generally, M3D is divided in four sections: file signature, application identification, header info, and mpeg data. In file structure they are sorted out like this:
<file signature>

This section signs file as MPEG Audio datafile and determines file version. Version numbers are defined by author and may not be changed by third parties. You are entitled to create only files according to current version definition. Current version is 1.2 and this document describes it. If you want to read older versions, look support site of MPGTools Delphi Unit for details. Check this site for future structure updates.

 <file_id>8 characters Always contains #9'MP3DATA' characters. This part may be used by third party applications to recognize file as MPEG Audio Datafile.
<version>1 byte Contains file version number (currently 1)
<subversion>1 byte Contains file subversion number (currently 2)


<application id>

This section describes application used to create file. It also may contain other, application specific data. Third party applications may or may read data from this section or just skip them.

<block_length>1 byte Contains length of <application id> section excluding <block_length> byte
<app_name_length>1 byte Contains number of bytes used for application name (maximum value is 15).
<app_name>up to 15 characters Containing application name. Should be used to determine which application created m3d file. Application name must be registered with author to avoid same ID-s for different applications.
<custom data> Space used by application. Author of that application is responsible for publishing data structure of this block if he wants third parties to use his data. He does not have to do that. This block length may be calculated as <block_length>-<app_name_length>-1. It may contain any additional data application needs



Contains header info about owner of file, catalogue info, order info or else. It may use different structure, therefore it's divided into three blocks:

<header_type>1 byte Describes type of header:

0 - custom header used by third party application (use <app id> to see which one) that created this header. Other applications should just skip reading header informations. Third party applications may publish their custom format. In that case, it is advisable to contact author of m3d to register its own type.

1 - catalogue header. Should be used for distributed MPEG catalogues.

    Pascal (Delphi) structure definition:

    TMPEGDataCatalogue = packed record
        Title : string[30];      { Catalogue title }
        Publisher : string[30];  { Catalogue publisher name }
        City : String[30];       { Publisher's contact info }
        ZIP : String[10];
        Country : String[20];
        Address : String[30];
        Phone: String[15];
        Fax: string[15];
        Email: string[30];
        WWWURL: string[30];

2 - order header. Should be used for MPEG orders generated from catalogues.

    Pacal (Delphi) structure defition:
      TMPEGDataOrder1v1 = packed record
        CustomerID : string[15]; { customer unique ID
                                   used by catalogue publisher }
        Name : string[30];       { customer name and           }
        City : String[30];       { other contact data          }
        ZIP : String[10];
        Country : String[20];
        Address : String[30];
        Phone: String[15];
        Fax: string[15];
        Email: string[30];

Other - we may define other publicly available header types, that may be used by all applications. It is recommended to let us know about specific headers you use for your application, so we may add it to public header types if they are of general interest.

<header_length>2 bytes Contains length of header data. Maximum value is 65535. It may be used to simplify reading header info and to skip unsupported header types.
<header_data>up to 65535 bytes Contains additional info about owner and data in file. It may have predefined or custom structure, which is described by <header_type>



This section contains unlimited number of MPEG data records.

This is Pascal (Delphi) record structure (note that string3, string30, string4, string255 and string20 are actually string[3], string[30], string[4], string[255] and string[20]):

      TMPEGData1v2 = packed record
        Header : String3;        { Should contain "TAG" if header is correct }
        Title : String30;        { Song title  }
        Artist : String30;       { Artist name }
        Album : String30;        { Album  }
        Year : String4;          { Year }
        Comment : String30;      { Comment }
        Genre : Byte;            { Genre code }
        Track : byte;            { Track number on Album }
        Duration : word;         { Song duration }
        FileLength : LongInt;    { File length }
        Version : byte;          { MPEG audio version index (1 - Version 1,
                                   2 - Version 2,  3 - Version 2.5,
                                   0 - unknown }
        Layer : byte;            { Layer (1, 2, 3, 0 - unknown) }
        SampleRate : LongInt;    { Sampling rate in Hz}
        BitRate : LongInt;       { Bit Rate }
        BPM : word;              { bits per minute - for future use }
        Mode : byte;             { Number of channels (0 - Stereo,
                                   1 - Joint-Stereo, 2 - Dual-channel,
                                   3 - Single-Channel) }
        Copyright : Boolean;     { Copyrighted? }
        Original : Boolean;      { Original? }
        ErrorProtection : boolean; { Error protected? }
        Padding : Boolean;       { If frame is padded }
        FrameLength : Word;      { total frame size including CRC }
        CRC : word;              { 16 bit File CRC (without TAG).
                                   Not implemented yet. }
        FileName : String255;    { MPEG audio file name }
        FileDateTime : LongInt;  { File last modification date and time in
                                   DOS internal format }
        FileAttr : Word;         { File attributes }
        VolumeLabel : string20;  { Disk label }
        Selected : word;         { If this field's value is greater than
                                   zero then file is selected. Value
                                   determines order of selection. }
        Reserved : array[1..45] of byte; { for future use }

This document and file specification are copyrighted by Predrag Supurovic (c)1998.
You may use it freely.