Skip to content

Instantly share code, notes, and snippets.

@pepijn-devries
Last active February 6, 2019 13:46
Show Gist options
  • Save pepijn-devries/50a77dfdbac4230129a0 to your computer and use it in GitHub Desktop.
Save pepijn-devries/50a77dfdbac4230129a0 to your computer and use it in GitHub Desktop.
# required packages:
require(plot3D)
require(ProTrackR)
# Read the module 'elekfunk' from the Mod Archive:
con <- url("http://api.modarchive.org/downloads.php?moduleid=41528", "rb")
mod <- read.module(con)
close(con)
rm(con)
# see how much memory the module object is eating:
format(object.size(mod), "Kb")
# calculate the ratio between the size of the object
# in memory and the size of the mod.file:
print(as.numeric(object.size(mod)/moduleSize(mod)))
# note that the object is roughly four times the size as the original file.
# This is probably because the Wave object (which the ProTrackerSample objec
# enherits), stores 8 bit wave data as integer values. In R, integers are
# actually 32-bit long, which explains the factor (32 / 8 =) 4 difference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment