Am I writing IT files correctly?

Started by uyjulian, March 17, 2015, 23:46:07

Previous topic - Next topic

uyjulian

https://github.com/uyjulian/spc2it/blob/master/it.c#L335
I'm not sure of any tools to verify IT files output... ITTECH.TXT is confusing to me...

Saga Musix

#1
Well, that is a very broad question, especially given that there is no canonical way of saving IT files. If you save the file and it loads as intended in any IT player, you can be mostly sure that the file is written correctly. Do you have any specific problems with opening your saved IT files?
ITTECH.TXT is incomplete but I find it very well-written. You probably just need to stop interpreting things into it. For example:
"// Channels are 1 based (Channels start at 1, not 0, ITTECH.TXT is WRONG) !!!"
No, you just misinterpreted this line:
Channel = (channelvariable-1) & 63              ; Channel is 0 based.
The variable Channel is 0-based. It is obtained from the variable channelvariable by subtracting one.

Some things are not documented in ITTECH.TXT, but I have documented them in the OpenMPT Wiki. Especially the stuff about storing (or not storing) the Edit History correctly is interesting. It seems like you are trying to copy OpenSPC's way of writing the IT header, which might be okay because the libraries and trackers that actually care about identifying which program was used to create a file know how to detect OpenSPC already, but it would be cleaner to register a Tracker ID in the wiki.


Also, I do hope this code won't bring in another wave of people believing that SPC must be some kind of magical module format and clearly OpenMPT should be able to open it...
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

uyjulian

Quote from: Saga Musix on March 17, 2015, 23:58:10
Well, that is a very broad question, especially given that there is no canonical way of saving IT files. If you save the file and it loads as intended in any IT player, you can be mostly sure that the file is written correctly. Do you have any specific problems with opening your saved IT files?
ITTECH.TXT is incomplete but I find it very well-written. You probably just need to stop interpreting things into it. For example:
"// Channels are 1 based (Channels start at 1, not 0, ITTECH.TXT is WRONG) !!!"
No, you just misinterpreted this line:
Channel = (channelvariable-1) & 63              ; Channel is 0 based.
The variable Channel is 0-based. It is obtained from the variable channelvariable by subtracting one.

Some things are not documented in ITTECH.TXT, but I have documented them in the OpenMPT Wiki. Especially the stuff about storing (or not storing) the Edit History correctly is interesting. It seems like you are trying to copy OpenSPC's way of writing the IT header, which might be okay because the libraries and trackers that actually care about identifying which program was used to create a file know how to detect OpenSPC already, but it would be cleaner to register a Tracker ID in the wiki.


Also, I do hope this code won't bring in another wave of people believing that SPC must be some kind of magical module format and clearly OpenMPT should be able to open it...

Line 24 and 25...
https://github.com/uyjulian/spc2it/blob/master/it.h

Saga Musix

Impulse Tracker will have issues with files exceeding its originally specified ranges, however most other players have no problems with the following:
- 256 rows per pattern or more (OpenMPT and I think XMPlay cap this at 1024)
- 240 distinct patterns (could in theory be 254, but is less for historical reasons, I guess)
- 200 samples (could again be 255, but this is probably another historical limit)
For your SPC conversion, you could probably save a lot of patterns by varying the ticks per row (Axx effect) depending on the number of events. Alternatively, use the SEx or S6x effects for repeating a row or adding ticks respectively.
Also, it might be possible to use 2 ticks per row instead of 1 tick at the cost of some possible minor precision loss, by using volume and tempo slides (D0x decreases volume on all ticks but the first, Dx0 increases it, Fxx with xx < E0 increases pitch on all ticks but the first, Exx decreases).
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

uyjulian

#4
Quote from: Saga Musix on March 18, 2015, 00:54:02
Impulse Tracker will have issues with files exceeding its originally specified ranges, however most other players have no problems with the following:
- 256 rows per pattern or more (OpenMPT and I think XMPlay cap this at 1024)
- 240 distinct patterns (could in theory be 254, but is less for historical reasons, I guess)
- 200 samples (could again be 255, but this is probably another historical limit)
For your SPC conversion, you could probably save a lot of patterns by varying the ticks per row (Axx effect) depending on the number of events. Alternatively, use the SEx or S6x effects for repeating a row or adding ticks respectively.
Also, it might be possible to use 2 ticks per row instead of 1 tick at the cost of some possible minor precision loss, by using volume and tempo slides (D0x decreases volume on all ticks but the first, Dx0 increases it, Fxx with xx < E0 increases pitch on all ticks but the first, Exx decreases).
Thanks, I'll keep that in mind when I'm rewriting my code to be more modular.