Mod Archive Forums

Community => Project / Coder's Corner => Topic started by: Steffest on June 16, 2017, 12:15:59

Title: The Counting Riddle (sample offset question)
Post 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:

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 ...

 




Title: Re: The Counting Riddle (sample offset question)
Post by: Steffest on June 16, 2017, 13:52:14
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 ...


 ???



Title: Re: The Counting Riddle (sample offset question)
Post by: Nikku4211 on June 16, 2017, 19:15:25
OpenMPT needs to support all of these.
Title: Re: The Counting Riddle (sample offset question)
Post by: Saga Musix on June 17, 2017, 18:04:53
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.
Title: Re: The Counting Riddle (sample offset question)
Post by: Nikku4211 on June 17, 2017, 20:27:26
@Sagamusix

OpenMPT needs to support all of these in case some modules exploit each of these sample offset bugs.
Title: Re: The Counting Riddle (sample offset question)
Post by: Steffest on June 19, 2017, 10:27:18
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


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.


 
Title: Re: The Counting Riddle (sample offset question)
Post by: Saga Musix on June 19, 2017, 14:17:23
Quote
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.