⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pt23mod.txt

📁 There are _NO_ standard sample rate for the samples used in modules. But most often the samples are
💻 TXT
📖 第 1 页 / 共 2 页
字号:
Date: Tue, 23 Mar 1993 19:38:04 +0100

There are _NO_ standard sample rate for the samples used in modules.
But most often the samples are done on the rate called C-3 (which is
about 16574 Hz if you have a PAL machine). Sometimes drums are sampled
at A-3 (around 28 kHz), and some sounds are at ~8 kHz or anything else
to save space.

The sample rate on each of the channels can be selected by a period value,
which tells the hardware how many ~3.5 MHz clocks to count down before
playing the next sample. If you have a 16 kHz sample you simply play
it at a note that gives you 16 kHz sample rate. If you play it one octave
lower, you get a 8 kHz sample rate (and a double period value).

Here are the magic formulas:

                7093789.2
SampleRate = --------------    (For a PAL machine)
               Period * 2

                7159090.5
SampleRate = --------------    (For a NTSC machine)
               Period * 2


So, the most normal rate is (C-3, period 214):

  7093789.2
 ----------- = 16574.27 Hz
   214 * 2

(16726.8 Hz if you use the NTSC formula, but i have a PAL machine)

The Amiga has four channels with independent sample rates, so there are
no such thing as a common rate for all channels, and there are no mixing
going on.

For a list of period values and what notes they are supposed to correspond
to, see the list of period values in the MOD format below.

Also note that finetuning are actually done by switching between 16 different
period tables (not included here, but get the Amiga Protracker Playroutine).

---
Lars Hamre
larsha@lise.unit.no


[ A description of the mod format follows:  -Lars]


Newsgroups: comp.sys.amiga.audio
From: steinarm@ifi.uio.no (Steinar Midtskogen)
Subject: Old MOD. format + PowerPacking
Summary: Description of the MOD format and powerpacking
Keywords: MOD, Powerpacker
Organization: University of Oslo, Norway
Date: Sun, 14 Mar 1993 23:49:00 GMT

  Since everybody seem to ask about the module format, here it comes.  I
will post this information every forthnight, at least for a period (pun
intended).

  I have put together most of the documentation about the module format
from PT2.3, edited it heavily (all credit to the original authors, but I
take responsibility for all errors) and added information about
powerpacking and how the Amiga volume work.

  The reason for not using documentation following PT3.0, which is written
by my group, is that there is no docmentation on the MOD format following
that.  Our reason for not distributing the documentation of the MOD.
format with the tracker is that we try to discourage the usage of the MOD.
format; a new format is coming up soon.  So don't write a revolutionary
piece of code based on the information presented herein; it will hopefully
be outdated in only another month.

[ Outdated? I don't think so... -Lars]

  (The "I" in this file refer to Vishnu of Cryptoburners, the "we" refer to
respectively Amiga Freelancers and Cryptoburners; it should be obvious from
the context which of them)

Credits for original doc files:

Lars "ZAP" Hamre /Amiga Freelancers
  The documentation to the song/module format.
  The information about how to calculate BMPs from the Amiga CIA timings.

Peter "CRAYON" Hanning /Mushroom Studios/Noxious
  Updates to the song/module format information. (I thought that it looked
   pretty similar to the one from PT1.3, but he had put his name under,
   so...)
  The table of effect commands.

[ Hrm. Both files are mine. I can see no big changes. -Lars]


  I have updated the information in the song/module format text, and added
information on how the finetuning work.

***********************************************************************

Protracker 2.3A Song/Module Format:
-----------------------------------

Offset  Bytes  Description
------  -----  -----------
   0     20    Songname. Remember to put trailing null bytes at the end...
               When written by ProTracker this will be only uppercase;
               there are only historical reasons for this. (And the
               historical reason is that Karsten Obarski, who made the
               first SoundTracker, was stupid.)

Information for sample 1-31:

Offset  Bytes  Description
------  -----  -----------
  20     22    Samplename for sample 1. Pad with null bytes. Will only be
               uppercase.  The samplenames are often used for storing
               messages from the author; in particular, samplenames
               starting with a '#' sign will generally be a message.  This
               convention is a result of a player called IntuiTracker
               displaying all samples starting with # as a message to the
               person playing the module.
  42      2    A WORD with samplelength for sample 1.  Stored as number of
               words.  Multiply by two to get real sample length in bytes.
               This is a big-endian number; for all PC programmers out
               there, this means that to get your 8-bit-orginated format,
               you have to swap the two bytes.
  44      1    Lower four bits are the finetune value, stored as a signed
               four bit number. The upper four bits are not used, and
               should be set to zero.
.       They should also be masked out reading; you can never be
.       sure what some stupid program could have stored here...
  45      1    Volume for sample 1. Range is $00-$40, or 0-64 decimal.
  46      2    Repeat point for sample 1. Stored as number of words offset
               from start of sample. Multiply by two to get offset in bytes.
  48      2    Repeat Length for sample 1. Stored as number of words in
               loop. Multiply by two to get replen in bytes.

Information for the next 30 samples starts here. It's just like the info for
sample 1.

Offset  Bytes  Description
------  -----  -----------
  50     30    Sample 2...
  80     30    Sample 3...
   .
   .
   .
 890     30    Sample 30...
 920     30    Sample 31...

Offset  Bytes  Description
------  -----  -----------
 950      1    Songlength. Range is 1-128.
 951      1    This byte is set to 127, so that old trackers will search
               through all patterns when loading.
               Noisetracker uses this byte for restart, ProTracker doesn't.
 952    128    Song positions 0-127.  Each hold a number from 0-63 (or
               0-127) that tells the tracker what pattern to play at that
               position.
1080      4    The four letters "M.K." - This is something Mahoney & Kaktus
               inserted when they increased the number of samples from
               15 to 31. If it's not there, the module/song uses 15 samples
               or the text has been removed to make the module harder to
               rip. Startrekker puts "FLT4" or "FLT8" there instead.
               If there are more than 64 patterns, PT2.3 will insert M!K!
               here. (Hey - Noxious - why didn't you document the part here
               relating to YOUR OWN PROGRAM? -Vishnu)

Offset  Bytes  Description
------  -----  -----------
1084    1024   Data for pattern 00.
   .
   .
   .
xxxx  Number of patterns stored is equal to the highest patternnumber
      in the song position table (at offset 952-1079).

  Each note is stored as 4 bytes, and all four notes at each position in
the pattern are stored after each other.

00 -  chan1  chan2  chan3  chan4
01 -  chan1  chan2  chan3  chan4
02 -  chan1  chan2  chan3  chan4
etc.

Info for each note:

 _____byte 1_____   byte2_    _____byte 3_____   byte4_
/                \ /      \  /                \ /      \
0000          0000-00000000  0000          0000-00000000

Upper four    12 bits for    Lower four    Effect command.
bits of sam-  note period.   bits of sam-
ple number.                  ple number.

  To separate out the different parts of the note, something like this
would be used (C to have it a bit portable; I like assembler and Pascal
better myself):

int samplenum,effectcommand,effectdata,extendedcommand;
char notename[];
...

void ProcessNote(byte notedata[]) {
  extendedcommand=-1;
  samplenum=(*notedata&0xF0)|(*(notedata+2)>>4);
  switch(((*notedata<<8)|(*notedata))&0xfff) {
    case 856: notename="C-1"; break;
    case 808: notename="C#1"; break;
    case 762: notename="D-1"; break;
    case 856: notename="D#1"; break;
   /* etc */
    default: notename="???"; /* This should NOT occur; if it do, it is */
                             /* not a ProTracker module! */
   }
   effectcommand=*(notedata+2)&0xF;
   effectdata=*(notedata+3);
   if effectcommand==0xE then /* Extended command */ {
      extendedcommand=effectdata>>4;
      effectdata&=0xf; /* Only one nibble data for extended command */
   }
}

Probably this isn't 100% valid C code, but I think you catch my drift...



Periodtable for Tuning 0, Normal
  C-1 to B-1 : 856,808,762,720,678,640,604,570,538,508,480,453
  C-2 to B-2 : 428,404,381,360,339,320,302,285,269,254,240,226
  C-3 to B-3 : 214,202,190,180,170,160,151,143,135,127,120,113

  To determine what note to show, scan through the table until you find the
same period as the one stored in byte 1-2.  Use the index to look up in a
notenames table.

  If you have a bit of memory, it is probably smarter to use an 744 byte
block to store the indexes relating to the different periods (ie:  at
position 808 in the block you store 1, as 1 is the index of period 808.
Then you use the block as a look up table)

  This is the data stored in a normal song.  A packed song starts with the
four letters "PACK", and then comes the packed data.

  It is somewhat unclear to me what kind of packing that is referred to
here.  One thing is clear though - it is NOT powerpacked or LHAed modules!
I belive somebody (Probably Amiga Freelancers) was planning to install some
form of direct packing into ProTracker, reserved this ID, and then it never
came...  -Vishnu

[No. We never intended to install any packing here. This is an older
 invention :)  Songs (modules WITHOUT the samples) can be packed by this
 method, and it will put the "PACK" tag at the beginning of the file.
 But since everyone saves modules with samples instead of songs, I wouldn't
 care about it. The packer/depacker for PACK'ed files are in the PT source
 code, available on aminet sites.  -Lars Hamre]

  In a module, all the samples are stored right after the patterndata.  To
determine where a sample starts and stops, you use the sampleinfo
structures in the beginning of the file (from offset 20).  Take a look at
the mt_init routine in the playroutine, and you'll see just how it is done.
  The data for a sample must _ALWAYS_ start with two zeros, as it is used for
repeating is the sample is to be terminated.

[ Well, the playroutine will clear these two bytes anyway...  -Lars]

***********************************************************************
                                Finetuning

Value:    0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
Finetune: 0  +1  +2  +3  +4  +5  +6  +7  -8  -7  -6  -5  -4  -3  -2  -1


  Finetuning are done by multiplying the frequency of the playback by
X^(finetune), where X ~= 1.0072382087
  This means that Amiga PERIODS, which represent delay times before
fetching the next sample, should be multiplied by X^(-finetune)

Vishnu of Cryptoburners

[ This should be 2^(finetune/12/8). And 2^(1/12/8) is 1.007246412 on
  my calculator...  (12 notes per octave and 1/8 of this)  -Lars Hamre ]


***********************************************************************
          Decibel Values and Volume Ranges

   Volume  Decibel Value     Volume  Decibel Value

     64         0.0            32        -6.0
     63        -0.1            31        -6.3
     62        -0.3            30        -6.6
     61        -0.4            29        -6.9
     60        -0.6            28        -7.2
     59        -0.7            27        -7.5
     58        -0.9            26        -7.8
     57        -1.0            25        -8.2
     56        -1.2            24        -8.5
     55        -1.3            23        -8.9
     54        -1.5            22        -9.3
     53        -1.6            21        -9.7
     52        -1.8            20       -10.1
     51        -2.0            19       -10.5
     50        -2.1            18       -11.0
     49        -2.3            17       -11.5
     48        -2.5            16       -12.0
     47        -2.7            15       -12.6
     46        -2.9            14       -13.2
     45        -3.1            13       -13.8
     44        -3.3            12       -14.5
     43        -3.5            11       -15.3
     42        -3.7            10       -16.1
     41        -3.9             9       -17.0
     40        -4.1             8       -18.1
     39        -4.3             7       -19.2
     38        -4.5             6       -20.6
     37        -4.8             5       -22.1
     36        -5.0             4       -24.1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -