Learn R Programming

ProTrackR (version 0.4.4)

read.module: Read a ProTracker module file

Description

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

Usage

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

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

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

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

Value

Returns a PTModule object read from the provided ProTracker file

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.

Author

Pepijn de Vries

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.

References

https://wiki.multimedia.cx/index.php?title=Protracker_Module

See Also

Other io.operations: read.sample(), write.module(), write.sample()

Other module.operations: PTModule-class, appendPattern(), clearSamples(), clearSong(), deletePattern(), fix.PTModule(), modToWave(), moduleSize(), patternLength(), patternOrderLength(), patternOrder(), playMod(), playingtable(), rawToPTModule(), trackerFlag(), write.module()

Examples

Run this code
## first create an module file from example data:
data("mod.intro")

f <- tempfile(fileext = ".mod")
write.module(mod.intro, f)

## read the module:
mod  <-  read.module(f)

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

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

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

Run the code above in your browser using DataLab