Skip to contents

Try to fix non-valid PTModule objects in order to meet with ProTracker specs such that they pass validity tests.

Usage

# S4 method for class 'PTModule,logical'
fix.PTModule(mod, verbose = TRUE)

# S4 method for class 'PTModule,missing'
fix.PTModule(mod)

Arguments

mod

A PTModule object which needs fixing.

verbose

With the default value of TRUE, the method prints a progress report to the sink. When set to FALSE, the progress report is suppressed.

Value

Returns a copy of object mod in which all non-conformities are attempted to be fixed. (Attempted) fixes are listed printed in the progress report.

Details

Almost any file can be read as a PTModule object (using read.module) when validity is ignored and no unexpected end of file is reached. This package's object validity are very strictly testing for compliance with ProTracker specifications. As many modules could have been created with other trackers (which often will play just as well in ProTracker) it is desirable to convert such object to ProTracker specs. This method attempts to do so, by fixing each aspect, that is also tested in the object validity functions. Note that the attempts are no guarantee for success, and `fixed' modules may not play as intended.

Note

In the current version, pattern data itself is not checked for non-conformities nor is it fixed.

Author

Pepijn de Vries

Examples

data("mod.intro")

## Let's do something illegal and destroy mod.intro:
mod.intro@pattern.order <- mod.intro@pattern.order[1:9]

## We should have used the 'patternOrder'-method to
## change the pattern order. Now we have broken the
## object:
validObject(mod.intro, TRUE)
#> [1] "FALSE"

## No worries, we can fix it:
mod.intro <- fix.PTModule(mod.intro)
#> Check and fix if pattern.order.length is a raw of length 1
#> Check and fix if pattern.order.length value is out of range (1-128)
#> Check and fix if the module name has a length of exactly 20 raw values
#> Check and fix if the pattern order table length is not equal to 128
#> Check and fix if the tracker byte when it is not equal to that of ProTracker (0x7F)
#> Check and fix if the number of samples is not equal to ProTracker's capacity of 31
#> Fixing sample number 1 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 2 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 3 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 4 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 5 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 6 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 7 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 8 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 9 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 10 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 11 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 12 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 13 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 14 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 15 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 16 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 17 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 18 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 19 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 20 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 21 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 22 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 23 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 24 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 25 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 26 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 27 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 28 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 29 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 30 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Fixing sample number 31 
#> Check and fix sample name
#> Check and fix finetune
#> Check and fix volume
#> Check and fix if loopstart is out of the samples range
#> Check and fix if the right channel of the sample is empty
#> Check and fix if the sample does not contain too much data
#> Check and fix if the sample length is not even
#> Check and fix the tracker flag if it's not equal to either of ProTrackers values 'M.K.' or 'M!K!'
#> Check and fix if the number of patterns are out of range (either 1-64, or 1-100, depending on the tracker flag)
#> Check and fix if the maximum number of patterns is listed in the pattern order table
#> Module successfully fixed

## See, it's all OK again:
validObject(mod.intro, FALSE)
#> [1] TRUE