Skip to contents

Get the file size in bytes of a PTModule object, when it is to be saved as an original module file with write.module.

Usage

# S4 method for PTModule
moduleSize(x)

Arguments

x

A PTModule object for which the file size is to be calculated.

Value

Returns potential uncompressed module file size in bytes represented by a number of class object_size.

Details

The ProTracker module has a 1084 byte sized header containing all (meta) information on the patterns, their order and the audio samples. Each pattern holds exactly 1 Kb of information and the length of the audio samples corresponds with the size in bytes, as they are of 8 bit quality in mono. This function calculates the file size of the PTModule object when it is to be saved with write.module.

Author

Pepijn de Vries

Examples

## Calculate the file size for the example module 'mod.intro':

data("mod.intro")
moduleSize(mod.intro)
#> 9214 bytes

## Note that this is not the same as the size the object
## requires in R working memory:

object.size(mod.intro)
#> 99384 bytes

## In working memory it takes more memory to store the module, than in a
## file. This is because the S4 structure of the object consumes some
## memory. In addition, samples are of 8 bit quality, corresponding with
## a byte per sample. In the PTSample object it is stored as a
## vector of integer values. In R, integer values are 32 bit, which
## costs 4 times as much memory as the original 8 bit.