Skip to contents

Reads a ProTracker module file and coerces it to a PTModule object.

Usage

# S4 method for character,logical
read.module(file, ignore.validity = F)

# S4 method for ANY,missing
read.module(file, ignore.validity = F)

# S4 method for ANY,missing
read.module(file, ignore.validity = F)

# S4 method for ANY,logical
read.module(file, ignore.validity = F)

Arguments

file

either a filename or a file connection, that allows reading binary data (see e.g., base::file or base::url).

ignore.validity

A logical value indicating whether the validity of the PTModule should be ignored. When set to FALSE (default), the validity of the read object is checked; an error is thrown when the object is not valid. When this argument is set to TRUE, the validity of the object will not be checked and a potentially invalid object is returned. As the validity check of PTModule objects is very strict, it can be useful to ignore this check. This way you can try to read a broken module file, try to fix it such that it becomes valid and save (with write.module) it again.

Value

Returns a PTModule object read from the provided ProTracker file

Details

The routine to read ProTracker modules is based on the referenced version of ProTracker 2.3A. This means that the routine may not be able to read files produced with later ProTracker versions, or earlier versions with back-compatibility issues. So far I've successfully tested this method on all modules I've composed with ProTracker version 2.3A (which I believe was one of the more popular versions of ProTracker back in the days).

It should also be able to read most of the .mod files in The Mod Archive.

Author

Pepijn de Vries

Examples

if (FALSE) {

## first create an module file from example data:
data("mod.intro")
write.module(mod.intro, "intro.mod")

## read the module:
mod  <-  read.module("intro.mod")

## or create a connection yourself:
con  <- file("intro.mod", "rb")

## note that you can also read from URL connections!
mod2 <- read.module(con)

## don't forget to close the file:
close(con)
}