Mod Archive Forums
Community => Project / Coder's Corner => Topic started by: Steffest on June 16, 2017, 12:15:59
-
Hey,
I'm in the process of writing my own web-based tracker and have reached the muddy waters of tracker-variations.
My Question is about the "9" sample offset effect, especially related to special cases when notes and sample number are omitted.
I created a little demo mod that behaves differently in different players.
It's located at http://www.stef.be/bassoontracker/demomods/test/sampleoffset.mod
The sample is a voice counting from 1 to 4, depending on the sample offset and the handling of special cases, you get another sequence in different players .
I tested it on multiple trackers and there are 3 different ways the sample offset is handled:
- counting is heard as 2-3-2-3-3-4-4
- Protracker 1.3 - Amiga
- Protracker 2.3d - Amiga and the Windows Clone
- OpenMPT
- counting is heard as 2-3-2-3-2-3-2-3
- Protracker 3.15 - Amiga
- Protracker 4 - Amiga
- Milkytracker (even in Protracker 2 mode)
- counting is heard as 2-3-2-3-1-2-2-3
- FasttrackerII - DOS
- Milkytracker (in Fasttracker mode)
The problem is: I understand the 2nd and the 3th way, but I can't get my head around the logic of the first way (of Protracker 1, 2 and OpenMPT)
especially the note on row 32: this doesn't have a sample number, nor an effect but somehow the previous 9 effect gets applied twice? (the sample starts playing at "three")
Then after that, at row 48, no sample number and "900": you hear "four"? why?
My own code follows Fasttracker here as this seems the most logical implementation (http://www.stef.be/bassoontracker/?file=demomods%2Ftest%2Fsampleoffset.mod)
but most .mod files seem to expect the PT2 way so I would like to get that right.
And even more a mystery: How would you know what playback variation the .mod files expect?
Anyone who has dug deep into this and wants to shed a light?
Update:
Oh, look at that, I found a 4th way ...
XMPlay with the the "PT1" playback mode does "2-3-2-3-2-3-3-4"
How balls-on weird is that?
puzzling ...
-
Small update, before someone says "There's a bug in PT1 and 2 that adds offsets in the 9-effect when no sample number is given".
Yes, I though so too, but not exactly: here's a more simple example with just 2 notes:
http://www.stef.be/bassoontracker/demomods/test/sampleoffsetb.mod
If the offset is added, then you would hear "2-3" not "2-4" like you do now on PT1 and PT2, so somehow the offset is tripled.
Still ... puzzling ...
???
-
OpenMPT needs to support all of these.
-
OpenMPT needs to support all of these.
No.
Steffest: PT2.3 is messy but its behaviour is by far the most exploited behaviour (that is, some tunes rely on it, but I don't know of any tunes relying on e.g. PT3's behaviour).
Maybe it would help you read my description here:
https://wiki.openmpt.org/Development:_Test_Cases/MOD#ptoffset.mod
If that still doesn't help, read OpenMPT's Snd_fx.cpp, look in the function CSoundFile::SampleOffset for SONG_PT_MODE. This deals with the PT1/2 quirks.
-
@Sagamusix
OpenMPT needs to support all of these in case some modules exploit each of these sample offset bugs.
-
Aha!
Thanks Saga Musix,
Without a doubt you have the deepest technical tracker knowledge on the planet, but of course you already knew that :-)
To boil it down to a simple ruleset for my own peace of mind:
For PT1 and 2 playback
- if a 9 command is present, advance the sample offset and set the start of the sample
- advance the sample offset again (but don't set start)
- at the next note, when no sample number is given, don't reset the sample offset (and do reset the offset otherwise) then set start of the sample and apply effects
That's why the offset gets tripled in some cases on notes with no sample number and a repeating 9 command.
The way XMPlay in PT1 mode handles this is a small bug IMHO, as I haven't seen this behaviour on any other player on any other platform.
-
That's why the offset gets tripled in some cases on notes with no sample number and a repeating 9 command.
To be even more precise, it cannot only get tripled, but it can advance indefinitely (up to the end of the sample) if no instrument number is present. So a series of 901 effects with no instrument number will slowly sweep through the whole sample.