English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 01 August 2019, 21:35   #1
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
Protracker file format, number of samples

Starting with offset 20 a typical Protracker MOD file has a list of 31 entries with 30 bytes each for the samples. I wonder how to make sure whether such an entry is a valid sample or not.

Offset 22 of such an entry defines the sample length in words. I would expect that a zero length is written for unused samples. But I also saw MODs which have all fields zero, except a sample length of 1 word, a loop-offset of 1 word and a loop-length of 1 word. Still they seem to be unused, invalid samples, because there is no sample-data for them in the MOD file. Is this a common method to define unused entries?

When loading this MOD into Milkytracker it lists the correct number of samples.

With my ptplayer I had a memory corruption here, because I am assuming samples with a length of 1 word and clearing the first word of these samples to allow idle-looping. As these sample words are missing at the end of the MOD file I was destroying the following memory region.

So the short question is: how can I safely identify unused sample entries in Protracker (and later tracker-) MODs?
phx is offline  
Old 01 August 2019, 22:25   #2
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,488
Quote:
Originally Posted by phx View Post
With my ptplayer I had a memory corruption here, because I am assuming samples with a length of 1 word and clearing the first word of these samples to allow idle-looping. As these sample words are missing at the end of the MOD file I was destroying the following memory region.
You answered yourself

As first word is cleared by any player to allow idle-looping it would make no sense to store this [*solo, 2 bytes] sample in the module.
So if (sample_length<=1) no_sample;

The '1' value I guess depends on (some) editors that, by default, set this value for unused samples.

Cheers.

EDIT: from the way I wrote the sentence it seemed that normally one less word is stored, which is not the case, so I added the[*]

Last edited by ross; 01 August 2019 at 22:38. Reason: []
ross is offline  
Old 02 August 2019, 00:57   #3
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,029
Quote:
Originally Posted by phx View Post
Starting with offset 20 a typical Protracker MOD file has a list of 31 entries with 30 bytes each for the samples. I wonder how to make sure whether such an entry is a valid sample or not.

Offset 22 of such an entry defines the sample length in words. I would expect that a zero length is written for unused samples. But I also saw MODs which have all fields zero, except a sample length of 1 word, a loop-offset of 1 word and a loop-length of 1 word. Still they seem to be unused, invalid samples, because there is no sample-data for them in the MOD file. Is this a common method to define unused entries?

When loading this MOD into Milkytracker it lists the correct number of samples.

With my ptplayer I had a memory corruption here, because I am assuming samples with a length of 1 word and clearing the first word of these samples to allow idle-looping. As these sample words are missing at the end of the MOD file I was destroying the following memory region.

So the short question is: how can I safely identify unused sample entries in Protracker (and later tracker-) MODs?
You can check Init Player routine from WT's Protracker replay. If I remember right, not all tracker mods was saved with Amiga Protracker, some are intialised (memory rips, different intialisation), some are from ST or Fasttracker. Then I rebuilded correctly SampleInfo, and empty word for looping was created only if was in the module size, if not, then module was too short.
Don_Adan is offline  
Old 02 August 2019, 09:00   #4
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
For me a mod having empty samples with a size of 1 is to be considered as damaged. They come from some stupid pc editor that obviously did not understand the format.

Anyway, never assume the space exists for full samples that are indicated even if you take that into account. There are some truncated mods around.
meynaf is offline  
Old 02 August 2019, 13:47   #5
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,029
BTW. "Ode to Protracker" is very good test module for your Protracker replayer.

http://wt.exotica.org.uk/examples.html
Don_Adan is offline  
Old 02 August 2019, 14:10   #6
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
Ok, so the proposed solution would be to ignore all sample lengths <= 1?

This would have probably worked in my example, because there were 3 real samples, followed by 28 length 1 samples. Although I wonder what happens when such a length-1 sample appears between two real samples. Would I have to add the word to the sample pointer or not? Probably not, but I have to find some examples to be sure...

Quote:
Originally Posted by Don_Adan View Post
You can check Init Player routine from WT's Protracker replay.
What is WT's Protracker replay? Any URL?
The original PT2.3 player doesn't even clear the sample starts, IIRC, as it expects Protracker to do it.

Quote:
If I remember right, not all tracker mods was saved with Amiga Protracker, some are intialised (memory rips, different intialisation), some are from ST or Fasttracker.
Yes. That's the problem I have to deal with. Unfortunately there are MODs from lots of sources.

My example MOD, where I realized the problem, is the rg-jingle.mod, which is used in the hovering Retroguru intro before all games (Sqrzx, Trap Runner). It was certainly composed with a PC editor.

Quote:
Originally Posted by meynaf View Post
For me a mod having empty samples with a size of 1 is to be considered as damaged. They come from some stupid pc editor that obviously did not understand the format.
That was also my first impression, as they do not appear in MODs composed on the Amiga. Nevertheless I have to support this crap somehow.

Quote:
Anyway, never assume the space exists for full samples that are indicated even if you take that into account. There are some truncated mods around.
What? Are you sure? I don't think that I saw that yet.
And how could I ever support those? How do I recognize a missing sample when there is a sample length > 1 in the header? That would be an extremely corrupt MOD file for me.
phx is offline  
Old 02 August 2019, 14:13   #7
chip
Registered User
 
Join Date: Oct 2012
Location: Italy
Age: 49
Posts: 2,947
Out of curiosity phx, are you writing a MOD ripper ?
chip is offline  
Old 02 August 2019, 14:42   #8
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
Quote:
Originally Posted by chip View Post
Out of curiosity phx, are you writing a MOD ripper ?
Slightly off-topic, as a ripper is quite different to a player - but, no, I have no plans to do a ripper. When automatic rippers don't work I would do that manually.
phx is offline  
Old 02 August 2019, 14:53   #9
chip
Registered User
 
Join Date: Oct 2012
Location: Italy
Age: 49
Posts: 2,947
Thanks
chip is offline  
Old 02 August 2019, 15:18   #10
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
Quote:
Originally Posted by phx View Post
That was also my first impression, as they do not appear in MODs composed on the Amiga. Nevertheless I have to support this crap somehow.
You'll run into big trouble if you want to support all crap floating around
F.e. some old mods (again from non-Amiga software) use rep/replen in bytes rather than in words, leading to horrors if you're not prepared to this (DeliTracker supports them).

For this length=1 problem, perhaps you could contact mod authors to know what exact software was used, then make tests with said software.


Quote:
Originally Posted by phx View Post
What? Are you sure? I don't think that I saw that yet.
And how could I ever support those? How do I recognize a missing sample when there is a sample length > 1 in the header? That would be an extremely corrupt MOD file for me.
Aside of bad rips, i've seen old mods saved from some pc program that did not take the "M.K." into account and always saved 4 bytes less than real size...
Note that mods bigger than computed size also exist.
To support them, throw away anything larger than computed size, and fill missing data with zeroes. Maybe the latter can do the trick with length=1.

If you want to be safe, be prepared to face just every possible garbage that can be done (by checking everything and bailing out with what you don't know how to handle).
meynaf is offline  
Old 02 August 2019, 16:30   #11
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,488
Quote:
Originally Posted by phx View Post
What is WT's Protracker replay? Any URL?
http://wt.exotica.org.uk/files/sourc...Protracker.lzx

Relevant part for your case:
Code:
	subq.l	#1,D0
	moveq	#1,D1
	lea	42(A0),A1
CheckInfos
	cmp.w	(A1),D1
	bne.b	NoInit
	clr.w	(A1)
NoInit
	addq.l	#6,A1
	tst.w	(A1)
	bne.b	NoProtect
	move.w	D1,(A1)
NoProtect
	lea	24(A1),A1
	dbf	D0,CheckInfos
So yes, check for 1 and correct; check also sample_repeat_length.

As Don_Adan suggested, if you survive ode2ptk.mod you're more than okay.
http://wt.exotica.org.uk/files/examp...Protracker.lzx

ross is offline  
Old 02 August 2019, 16:48   #12
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
This might be off topic... apologies if it is...

The other day I had DJ Metune create an updated version of the Rygar music, some of the tunes when using PHX's replayer have a strange noise now... I tried the same mod through ProTracker on Windows and on Amiga and they're fine.

I'm wondering if PHX would be willing to take a look to see if it's his player and if it is apply a fix?

@Phx - Let me know and I can provide links via pm.

Geezer
mcgeezer is offline  
Old 02 August 2019, 20:03   #13
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
Quote:
Originally Posted by meynaf View Post
Note that mods bigger than computed size also exist.
To support them, throw away anything larger than computed size, and fill missing data with zeroes.
My player doesn't know the real size of a MOD (which certainly would make it easier). It just gets a pointer to its start address. So I cannot check that.

Quote:
If you want to be safe, be prepared to face just every possible garbage that can be done (by checking everything and bailing out with what you don't know how to handle).
As I cannot check everything I will have to give up here. MODs which are that damaged will simply fail. There is nothing I can do about it.

But doing the length=1 check seems to be important.
phx is offline  
Old 02 August 2019, 20:08   #14
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
Quote:
Originally Posted by ross View Post
That helps a lot! Thank you very much!

So I added the check for length 1 and reset it to zero. This should fix support for these PC-MODs. The check for the repeat-length of 1 was already done for ptplayer V5.2 (as used in my last two games).

Quote:
As Don_Adan suggested, if you survive ode2ptk.mod you're more than okay.
Yes, got it and tested it. Very useful test. Seems that the final sequence of that MOD doesn't play correctly. Will have a look.
phx is offline  
Old 02 August 2019, 20:17   #15
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
Quote:
Originally Posted by mcgeezer View Post
The other day I had DJ Metune create an updated version of the Rygar music, some of the tunes when using PHX's replayer have a strange noise now... I tried the same mod through ProTracker on Windows and on Amiga and they're fine.
Sounds like a bug which I fixed in ptplayer 5.2 (zero repeat-length for samples). Which version of the player do you use?

Quote:
I'm wondering if PHX would be willing to take a look to see if it's his player and if it is apply a fix?
Yes, usually I am willing to fix my bugs.
Please test the latest player version first. Last official release on Aminet is 5.1, but you can find 5.2 in the Celtic Heart and Trap Runner source archives (on EAB in Coders.Releases). I'm still waiting (since nearly 6 months) for a patch from Stingray, so I never released it.

Quote:
Let me know and I can provide links via pm.
Ok. Please do so (preferably by email, but PM is also ok), when the latest player still fails.

EDIT: Attached you find the current ptplayer.asm (which may become 5.3), where I just fixed the length=1 case, as discussed above. Maybe you should try this.

Last edited by phx; 07 December 2020 at 11:49.
phx is offline  
Old 02 August 2019, 20:19   #16
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Quote:
Originally Posted by phx View Post
Sounds like a bug which I fixed in ptplayer 5.2 (zero repeat-length for samples). Which version of the player do you use?

Yes, usually I am willing to fix my bugs.
Please test the latest player version first. Last official release on Aminet is 5.1, but you can find 5.2 in the Celtic Heart and Trap Runner source archives (on EAB in Coders.Releases). I'm still waiting (since nearly 6 months) for a patch from Stingray, so I never released it.

Ok. Please do so (preferably by email, but PM is also ok), when the latest player still fails.
I'm currently using 5.0, I'll try it with 5.2.

Incidentally DJ Metune sent another mod across which now works fine so I've asked him what he did.
mcgeezer is offline  
Old 02 August 2019, 20:21   #17
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
Quote:
Originally Posted by phx View Post
My player doesn't know the real size of a MOD (which certainly would make it easier). It just gets a pointer to its start address. So I cannot check that.
Then you can forget about altering the mod at all - as it's taking the risk of overwriting memory that does not belong to you - and instead setup another start address if you find an empty repeat (to play real nulls instead of the first two bytes of the sample).
meynaf is offline  
Old 02 August 2019, 20:28   #18
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
Quote:
Originally Posted by mcgeezer View Post
Incidentally DJ Metune sent another mod across which now works fine so I've asked him what he did.
Thanks. And please test with the old MOD, if you still have it. I would really like to know if there is a bug.
phx is offline  
Old 02 August 2019, 20:31   #19
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
Quote:
Originally Posted by meynaf View Post
Then you can forget about altering the mod at all - as it's taking the risk of overwriting memory that does not belong to you
Indeed. That was the problem which started this thread.

Quote:
and instead setup another start address if you find an empty repeat (to play real nulls instead of the first two bytes of the sample).
I'm already doing that since V5.2 for zero repeats. I let it point to the start address of the first sample, in the hope that at least one valid sample exists in a MOD.
phx is offline  
Old 02 August 2019, 21:08   #20
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,029
Quote:
Originally Posted by phx View Post
Indeed. That was the problem which started this thread.

I'm already doing that since V5.2 for zero repeats. I let it point to the start address of the first sample, in the hope that at least one valid sample exists in a MOD.
I see some different solution too, you dont need to clear memory, you can alloc 4 bytes of chip ram and use this for your replay. Or even you can use clr.l 0 command and use 0 address as empty sample. I see this method in some Amiga replayers.
Don_Adan is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Protracker loads song but not the samples Brick Nash support.Other 6 12 May 2019 16:20
Creating chiptune style samples in protracker demether request.Music 22 26 September 2018 07:55
How to rip chiptune samples using ProTracker? BSF-OF-BGP request.Other 2 12 November 2017 15:37
Getting protracker 2.2a samples from PC to floppy and working W4LKR New to Emulation or Amiga scene 12 16 June 2013 17:45
Does anyone have any protracker samples adf's? CaptainNow Amiga scene 7 26 June 2011 13:36

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:02.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10557 seconds with 13 queries