sezero / mikmod

Mikmod Sound System (mirror of git repo at https://sf.net/projects/mikmod/)
http://mikmod.sourceforge.net/
72 stars 22 forks source link

Fix volume event handling for .FAR modules. #14

Closed AliceLR closed 3 years ago

AliceLR commented 3 years ago

The volume byte in Farandole Composer patterns is handled incorrectly by MikMod (and libxmp and libmodplug for that matter). Despite the (once again) confusing documentation, the volume in .FAR files is encoded as:

I modified my FAR utility to print raw pattern data dumps to prove this is the case for several .FAR modules affected by this bug. The volume byte is the 3rd byte in each column. The dumps have been edited down to their relevant sections. 0x00 bytes are printed as blank spaces.

rainruin.far.zip rainruin2

: pattern 16: length=2050, expected_rows=32, break byte=30, difference=2
: 05 01 0a b8:          b8:          b8:          b8:          b8:          b8:       0f   :       0f   :       0f   :       0f   :       01   :          b8:
:            :            :            :            :            :            :       0e   :       0e   :       0e   :       0e   :            :            :
:            : 0c 01 0a   :            :            :            :            :       0d   :       0d   :       0d   :       0d   :            :            :
:            :            :            :            :            :            :       0c   :       0c   :       0c   :       0c   :            :            :
:            :            : 11 01 0a   :            :            :            :       0b   :       0b   :       0b   :       0b   :            :            :
:            :            :            :            :            :            :       0a   :       0a   :       0a   :       0a   :            :            :
:            :            :            : 18 01 0a   :            :            :       09   :       09   :       09   :       09   :            :            :
:            :            :            :            :            :            :       08   :       08   :       08   :       08   :            :       0f   :
: 03 01 0a   :            :            :            :            :            :       07   :       07   :       07   :       07   :            :       0e   :
:            :            :            :            :            :            :       06   :       06   :       06   :       06   :            :       0d   :
:            : 0d 01 0a   :            :            :            :            :       05   :       05   :       05   :       05   :            :       0c   :
:            :            :            :            :            :            :       04   :       04   :       04   :       04   :            :       0b   :
:            :            : 18 01 0a   :            :            :            :       03   :       03   :       03   :       03   :            :       0a   :
:            :            :            :            :            :            :       02   :       02   :       02   :       02   :            :       09   :
:            :            :            : 1d 01 0a   :            :            :       01   :       01   :       01   :       01   :            :       08   :
:            :            :            :            :            :            :            :            :            :            :            :       07   :
: 01 01 0a   :            : 0d 01 0a   :            :            :            :            :            :            :            :            :       06   :
:            :            :            :            :            :            :            :            :            :            :            :       05   :
:            : 22 01 0a   :            :            :            :            :            :            :            :            :            :       04   :
:            :            :            :            :            :            :            :            :            :            :            :       03   :
:            :            : 24 01 0a   :            :            :            :            :            :            :            :            :       02   :
:            :            :            :            :            :            :            :            :            :            :            :       01   :

m31.far.zip m31

: pattern 04: length=4098, expected_rows=64, break byte=62, difference=2
: 11    10   :            : 1d 02 02   :       0f   :
:            :            :       03   :            :
:            : 1d    10   :       04   :       0e   :
:            :            :       05   :            :
: 1d    10   :            :       06   :       0d   :
:            :            :       07   :            :
:            : 1d    10   :       08   :       0c   :
:            :            :       09   :            :
: 11    10   :            : 1d 02 03   :       0b   :
:            :            :       04   :            :
:            : 1d    10   :       05   :       0a   :
:            :            :       06   :       09   :
: 1d    10   :            :       07   :       08   :
:            :            :       08   :       07   :
:            : 1d    10   :       09   :       06   :
:            :            :       0a   :       05   :
: 11    10   :            : 1d 02 04   :       04   :
:            :            :       05   :            :
:            : 1d    10   :       06   :       03   :
:            :            :       07   :            :
: 1d    10   :            :       08   :            :
:            :            :       09   :       02   :
:            : 1d    10   :       0a   :            :
:            :            :       0b   :            :
: 11    10   :            : 1e 02 05   :       01   :
:            :            :       06   :            :
:            : 1d    10   :       07   :            :
:            :            :       08   :            :
: 1d    10   :            :       09   :            :
:            :            :       0a   :            :
:            : 1d    10   :       0b   :            :
:            :            :       0c   :            :

residual ambient amperage.far.zip (NOTE: by Daniel Potter, the author of Farandole Composer.) residual

: pattern 00: length=2050, expected_rows=32, break byte=30, difference=2
: 1e    10 f2:            :            : 18 05 10   : 0c 05 10   : 11 06 10   :
:            : 1e    08   : 0f 03 04   :            :            :       05   :
:            :            :            : 18 05 10   :            :       10   :
:            :            : 0f 03 04   :            :            :       05   :
: 1e 02 10   :            :            :            :            :       10   :
:            : 1e 02 08   :            :            :            :       05   :
:            :            :            : 18 05 10   : 0c 05 10   :       10   :
:            :            : 0f 03 04   :            :            :       05   :
: 1e 01 10   :            :            : 18 05 10   :            :       10   :
:            : 1e 01 08   : 0f 03 04   :            :            :       05   :
:            :            :            :            :            :       10   :
:            :            :            :            :            :       05   :
: 1e 02 10   :            :            : 18 05 10   :            :       10   :
:            : 1e 02 08   : 0f 03 04   :            :            :       05   :
:            :            :            : 1b 05 10   : 0f 05 10   :       10   :
:            :            : 12 03 04   :            :            :       05   :
: 1e    10   :            :            :            :            :       10   :
:            : 1e    08   :            :            :            :       05   :
:            :            :            :            :            :       10   :
:            :            :            :            :            :       05   :
: 1e 02 10   :            :            : 1b 05 10   :            :       10   :
:            : 1e 02 08   : 12 03 04   :            :            :       05   :
:            :            :            :            :            :       10   :
:            :            :            :            :            :       05   :
: 1e 01 10   :            :            : 1a 05 10   :            :       10   :
:            : 1e 01 08   : 1f 07 04   :            :            :       05   :
:            :            :            :            :            :       10   :
:            :            :            :            :            :       05   :
: 1e 02 10   :            :            : 16 05 10   : 0a 05 10   :       10   :
:            : 1e 02 08   : 0d 03 04   :            :            :       05   :
:            :            :            :            :            :       10   :
:            :            :            :            :            :       05   :

This patch has been tested and confirmed to fix the volume bugs in these files. The bug appears to have been inherited from libmodplug.