| Title: | Manipulate and Play 'ProTracker' Modules |
|---|---|
| Description: | 'ProTracker' is a popular music tracker to sequence music on a Commodore Amiga machine. This package offers the opportunity to import, export, manipulate and play 'ProTracker' module files. Even though the file format could be considered archaic, it still remains popular to this date. This package intends to contribute to this popularity and therewith keeping the legacy of 'ProTracker' and the Commodore Amiga alive. This package is the successor of 'ProTrackR' providing better performance. |
| Authors: | Pepijn de Vries [aut, cre] (ORCID: <https://orcid.org/0000-0002-7961-6646>), Olav Sørensen [aut] (Developer of the ProTracker 2.3d clone) |
| Maintainer: | Pepijn de Vries <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.1 |
| Built: | 2026-05-19 08:10:30 UTC |
| Source: | https://github.com/pepijn-devries/ProTrackR2 |
Functions to select and assign elements to ProTracker modules.
See vignette('s3class') for an overview of ProTrackR2 S3 class objects. See vignette('sel_assign')
for practical guidance on selecting and assigning elements of ProTrackR2 class objects.
## S3 method for class 'pt2mod' x$i, ... ## S3 replacement method for class 'pt2mod' x$i <- value ## S3 replacement method for class 'pt2mod' x[[i]] <- value ## S3 method for class 'pt2mod' x[[i, ...]] ## S3 method for class 'pt2patlist' x[i, ...] ## S3 method for class 'pt2patlist' x[[i, ...]] ## S3 replacement method for class 'pt2patlist' x[[i]] <- value ## S3 method for class 'pt2samplist' x[i, ...] ## S3 method for class 'pt2samplist' x[[i, ...]] ## S3 replacement method for class 'pt2samplist' x[[i]] <- value ## S3 method for class 'pt2pat' x[[i, ...]] ## S3 replacement method for class 'pt2pat' x[[i]] <- value ## S3 method for class 'pt2pat' x[i, j, ...] ## S3 replacement method for class 'pt2pat' x[i, j, ...] <- value ## S3 replacement method for class 'pt2celllist' x[[i, ...]] <- value ## S3 replacement method for class 'pt2celllist' x[i, ...] <- value ## S3 method for class 'pt2celllist' x[[i, ...]] ## S3 method for class 'pt2celllist' x[i, ...] ## S3 method for class 'pt2command' x[[i, ...]] ## S3 method for class 'pt2command' x[i, ...] ## S3 replacement method for class 'pt2command' x[[i, ...]] <- value ## S3 replacement method for class 'pt2command' x[i, ...] <- value## S3 method for class 'pt2mod' x$i, ... ## S3 replacement method for class 'pt2mod' x$i <- value ## S3 replacement method for class 'pt2mod' x[[i]] <- value ## S3 method for class 'pt2mod' x[[i, ...]] ## S3 method for class 'pt2patlist' x[i, ...] ## S3 method for class 'pt2patlist' x[[i, ...]] ## S3 replacement method for class 'pt2patlist' x[[i]] <- value ## S3 method for class 'pt2samplist' x[i, ...] ## S3 method for class 'pt2samplist' x[[i, ...]] ## S3 replacement method for class 'pt2samplist' x[[i]] <- value ## S3 method for class 'pt2pat' x[[i, ...]] ## S3 replacement method for class 'pt2pat' x[[i]] <- value ## S3 method for class 'pt2pat' x[i, j, ...] ## S3 replacement method for class 'pt2pat' x[i, j, ...] <- value ## S3 replacement method for class 'pt2celllist' x[[i, ...]] <- value ## S3 replacement method for class 'pt2celllist' x[i, ...] <- value ## S3 method for class 'pt2celllist' x[[i, ...]] ## S3 method for class 'pt2celllist' x[i, ...] ## S3 method for class 'pt2command' x[[i, ...]] ## S3 method for class 'pt2command' x[i, ...] ## S3 replacement method for class 'pt2command' x[[i, ...]] <- value ## S3 replacement method for class 'pt2command' x[i, ...] <- value
x |
Object to apply S3 method to. See 'usage' section for allowed object types. |
i, j
|
Indices for extracting or replacing ProTrackR2 object elements |
... |
Passed on to other methods. |
value |
Replacement value for the selected element(s). |
Returns the selected object in case of a selection ([, [[, or $) operator. Returns the
updated object x in case of an assignment (<-) operator.
OpenMpt is a popular modern music tracker. This function allows
you to format a pattern such that it can be pasted directly into OpenMPT.
On Windows you can use writeClipboard() for this purpose.
as_modplug_pattern(pattern, ...)as_modplug_pattern(pattern, ...)
pattern |
An object of class |
... |
Ignored |
Returns a character object formatted such that it can be copied into OpenMPT
Pepijn de Vries
mod <- pt2_read_mod(pt2_demo()) as_modplug_pattern(pt2_pattern(mod, 0L))mod <- pt2_read_mod(pt2_demo()) as_modplug_pattern(pt2_pattern(mod, 0L))
Protracker uses pattern tables to annotate music progression.
Each cell in the table contains information about the note,
sample identifier and sound effect. This function coerces objects
to pt2cell or pt2cell class objects, such that they can be inserted into
patterns.
as_pt2cell(x, ...) as_pt2celllist(x, ...)as_pt2cell(x, ...) as_pt2celllist(x, ...)
x |
A ( |
... |
Ignored |
An object of class pt2cell, pt2celllist.
as_pt2cell("A-3 02 121") as_pt2cell("--- 01 000") as_pt2celllist(c("A-3 02 121", "--- 01 000"))as_pt2cell("A-3 02 121") as_pt2cell("--- 01 000") as_pt2celllist(c("A-3 02 121", "--- 01 000"))
ProTracker uses codes to achieve certain effects or jump to a
specific position (see vignette("effect_commands")).
effect_commands is a data.frame with three columns:
Code: a character of pseudo code used to achieve a certain effect
in ProTracker
Effect: Name of the effect.
Description: Description of the effect.
It is used for documentation and reference purposes.
data("effect_commands")data("effect_commands")
Implementation of basic S3 methods, such as, format, print, as.raw and as.character (
see usage section for a complete overview). See vignette('s3class') for an overview
of ProTrackR2 S3 class objects. See usage section for an overview of available methods.
## S3 method for class 'pt2mod' format(x, ...) ## S3 method for class 'pt2mod' print(x, ...) ## S3 method for class 'pt2pat' format( x, padding = " ", empty_char = "-", fmt = getOption("pt2_cell_format"), ... ) ## S3 method for class 'pt2command' as.character(x, ...) ## S3 method for class 'pt2command' format(x, fmt = getOption("pt2_effect_format"), ...) ## S3 method for class 'pt2command' print(x, max.print = 10L, ...) ## S3 method for class 'pt2pat' print(x, sep = " ", show_header = TRUE, show_row = TRUE, ...) ## S3 method for class 'pt2pat' as.character(x, ...) ## S3 method for class 'pt2celllist' as.raw(x, ...) ## S3 method for class 'logical' as.raw.pt2celllist(x, compact = TRUE, ...) ## S3 method for class 'pt2pat' as.raw(x, ...) ## S3 method for class 'logical' as.raw.pt2pat(x, compact = TRUE, ...) ## S3 method for class 'pt2cell' format( x, padding = " ", empty_char = "-", fmt = getOption("pt2_cell_format"), ... ) ## S3 method for class 'pt2cell' print(x, ...) ## S3 method for class 'pt2cell' as.character(x, ...) ## S3 method for class 'pt2celllist' as.character(x, ...) ## S3 method for class 'pt2command' as.raw(x, ...) ## S3 method for class 'pt2cell' as.raw(x, ...) ## S3 method for class 'logical' as.raw.pt2cell(x, compact = TRUE, ...) ## S3 method for class 'pt2samp' format(x, ...) ## S3 method for class 'pt2samp' print(x, ...) ## S3 method for class 'pt2patlist' format(x, ...) ## S3 method for class 'pt2patlist' print(x, ...) ## S3 method for class 'pt2celllist' format(x, ...) ## S3 method for class 'pt2celllist' print(x, ...) ## S3 method for class 'pt2samplist' format(x, ...) ## S3 method for class 'pt2samplist' print(x, ...) ## S3 method for class 'pt2mod' as.raw(x, ...) ## S3 method for class 'pt2samp' as.raw(x, ...) ## S3 method for class 'pt2samp' as.integer(x, ...) ## S3 method for class 'pt2celllist' length(x, ...) ## S3 method for class 'pt2command' length(x, ...)## S3 method for class 'pt2mod' format(x, ...) ## S3 method for class 'pt2mod' print(x, ...) ## S3 method for class 'pt2pat' format( x, padding = " ", empty_char = "-", fmt = getOption("pt2_cell_format"), ... ) ## S3 method for class 'pt2command' as.character(x, ...) ## S3 method for class 'pt2command' format(x, fmt = getOption("pt2_effect_format"), ...) ## S3 method for class 'pt2command' print(x, max.print = 10L, ...) ## S3 method for class 'pt2pat' print(x, sep = " ", show_header = TRUE, show_row = TRUE, ...) ## S3 method for class 'pt2pat' as.character(x, ...) ## S3 method for class 'pt2celllist' as.raw(x, ...) ## S3 method for class 'logical' as.raw.pt2celllist(x, compact = TRUE, ...) ## S3 method for class 'pt2pat' as.raw(x, ...) ## S3 method for class 'logical' as.raw.pt2pat(x, compact = TRUE, ...) ## S3 method for class 'pt2cell' format( x, padding = " ", empty_char = "-", fmt = getOption("pt2_cell_format"), ... ) ## S3 method for class 'pt2cell' print(x, ...) ## S3 method for class 'pt2cell' as.character(x, ...) ## S3 method for class 'pt2celllist' as.character(x, ...) ## S3 method for class 'pt2command' as.raw(x, ...) ## S3 method for class 'pt2cell' as.raw(x, ...) ## S3 method for class 'logical' as.raw.pt2cell(x, compact = TRUE, ...) ## S3 method for class 'pt2samp' format(x, ...) ## S3 method for class 'pt2samp' print(x, ...) ## S3 method for class 'pt2patlist' format(x, ...) ## S3 method for class 'pt2patlist' print(x, ...) ## S3 method for class 'pt2celllist' format(x, ...) ## S3 method for class 'pt2celllist' print(x, ...) ## S3 method for class 'pt2samplist' format(x, ...) ## S3 method for class 'pt2samplist' print(x, ...) ## S3 method for class 'pt2mod' as.raw(x, ...) ## S3 method for class 'pt2samp' as.raw(x, ...) ## S3 method for class 'pt2samp' as.integer(x, ...) ## S3 method for class 'pt2celllist' length(x, ...) ## S3 method for class 'pt2command' length(x, ...)
x |
Object to apply S3 method to. See 'usage' section for allowed object types. |
... |
Passed on to other methods. |
padding |
A |
empty_char |
A |
fmt |
Experimental feature to format a |
max.print |
Maximum number of elements to be printed. |
sep |
A separator |
show_header |
A |
show_row |
A |
compact |
Should the pattern be formatted using a compact notation (as used for
file storage), or a none-compact format as used by the player? This can be
set with the |
The following is returned by the different methods:
format: a formatted character representation of the object
print: same as format
as.character: same as format
as.raw: a raw representation of the object. In many cases it inherits the same
class as x
as.integer: converted raw 8 bit sample data to signed pulse code modulation integer
values between -128 and +127.
length returns number of elements in x
## First create some ProTrackR2 objects to which ## S3 methods can be applied: mod <- pt2_read_mod(pt2_demo()) patterns <- mod$patterns pattern <- patterns[[1]] cells <- pattern[1:4,1] cell <- cells[[1]] samples <- mod$samples sample <- samples[[1]] cmnd <- pt2_command(cell) ## Let's go wild with S3 methods: print(mod) print(patterns) print(pattern) print(cells) print(cell) print(samples) print(sample) print(cmnd) format(mod) format(patterns) format(pattern) format(cells) format(cell) format(samples) format(sample) format(cmnd) as.character(pattern) as.character(cells) as.character(cell) as.character(cmnd) as.raw(mod) as.raw(pattern) as.raw(cells) as.raw(cell) as.raw(sample) as.raw(cmnd) as.integer(sample)## First create some ProTrackR2 objects to which ## S3 methods can be applied: mod <- pt2_read_mod(pt2_demo()) patterns <- mod$patterns pattern <- patterns[[1]] cells <- pattern[1:4,1] cell <- cells[[1]] samples <- mod$samples sample <- samples[[1]] cmnd <- pt2_command(cell) ## Let's go wild with S3 methods: print(mod) print(patterns) print(pattern) print(cells) print(cell) print(samples) print(sample) print(cmnd) format(mod) format(patterns) format(pattern) format(cells) format(cell) format(samples) format(sample) format(cmnd) as.character(pattern) as.character(cells) as.character(cell) as.character(cmnd) as.raw(mod) as.raw(pattern) as.raw(cells) as.raw(cell) as.raw(sample) as.raw(cmnd) as.integer(sample)
Renders a ProTrackR2 class object as audio::audioSample() and plays it.
## S3 method for class 'pt2mod' play(x, duration = NA, options = pt2_render_options(), position = 0L, ...) ## S3 method for class 'pt2samp' play(x, duration = 5, options = pt2_render_options(), note = "C-3", ...) ## S3 method for class 'pt2patlist' play(x, duration = NA, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2pat' play(x, duration = NA, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2celllist' play(x, duration = 5, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2cell' play(x, duration = 5, options = pt2_render_options(), samples, ...)## S3 method for class 'pt2mod' play(x, duration = NA, options = pt2_render_options(), position = 0L, ...) ## S3 method for class 'pt2samp' play(x, duration = 5, options = pt2_render_options(), note = "C-3", ...) ## S3 method for class 'pt2patlist' play(x, duration = NA, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2pat' play(x, duration = NA, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2celllist' play(x, duration = 5, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2cell' play(x, duration = 5, options = pt2_render_options(), samples, ...)
x |
Object to be played. |
duration |
Duration of the rendered output in seconds. When set to |
options |
A list of options used for rendering the audio. Use
|
position |
Starting position in the pattern sequence table ( |
... |
Arguments passed to |
note |
Note to be played when |
samples |
When rendering or playing patterns (or elements of it), samples are needed
to interpret the pattern. Pass the samples as a sample list (class |
Returns an [audio::$.audioInstance] object which
allows you to control the playback (pause, resume, rewind).
Pepijn de Vries
if (interactive()) { mod <- pt2_read_mod(pt2_demo()) ## ctrl will contain the audioInstance that will let ## you control the audio playback: ctrl <- play(mod) ## You can also play individual samples samp <- mod$samples[[3]] play(samp, note = "C-2") play(samp, note = "E-2") play(samp, note = "G-2") ## As well as an individual pattern play(mod$patterns[[1]], samples = mod$samples) ## Or a subset of a pattern play(mod$patterns[[1]][17:32, 1:2], samples = mod$samples) ## Or even an individual cell play(mod$patterns[[1]][1, 1][[1]], samples = mod$samples) }if (interactive()) { mod <- pt2_read_mod(pt2_demo()) ## ctrl will contain the audioInstance that will let ## you control the audio playback: ctrl <- play(mod) ## You can also play individual samples samp <- mod$samples[[3]] play(samp, note = "C-2") play(samp, note = "E-2") play(samp, note = "G-2") ## As well as an individual pattern play(mod$patterns[[1]], samples = mod$samples) ## Or a subset of a pattern play(mod$patterns[[1]][17:32, 1:2], samples = mod$samples) ## Or even an individual cell play(mod$patterns[[1]][1, 1][[1]], samples = mod$samples) }
A cell is an element at a specific row and column (channel). It holds information
aboute the note to be played, the instrument (sample) number and the effect to be applied.
For mor information about cells (class pt2cell) consult vignette("s3class").
For more information about selecting elements from ProTrackR2 class objects check out
vignette("select_opts").
pt2_cell(pattern, i, j, ...)pt2_cell(pattern, i, j, ...)
pattern |
A |
i, j
|
Indices for extracting or replacing ProTrackR2 object elements. The indices starts at 0, for consistency with ProTracker! |
... |
Ignored |
Returns a cell object from the table as class pt2cell.
Pepijn de Vries
mod <- pt2_read_mod(pt2_demo()) pt2_cell(mod$patterns[[1]], 0L, 0L)mod <- pt2_read_mod(pt2_demo()) pt2_cell(mod$patterns[[1]], 0L, 0L)
As explained in vignette("s3class"), the ProTracker pattern table
consists of cells, containing information about the note and instrument
to be played. This function can be used to retrieve or replace the
effect commands in a module.
pt2_command(x, ...) pt2_command(x, silent = TRUE, ...) <- valuept2_command(x, ...) pt2_command(x, silent = TRUE, ...) <- value
x |
An object of class |
... |
Ignored |
silent |
Don't warn about replacement values not being used or recycled. |
value |
A replacement value. It should be an object that can be converted into
an effect command. It can be a |
Returns a pt2command object containing the raw command code.
In case of the assign operator (<-) an update version of x is returned.
mod <- pt2_read_mod(pt2_demo()) ## select a specific cell from the module cell <- pt2_cell(mod$patterns[[1]], 0L, 0L) ## show the command used for this cell pt2_command(cell) ## convert character strings into ProTracker commands pt2_command(c("C30", "F06")) ## Set the command for all cells in the first pattern ## to `C20` (volume at 50%): pt2_command(mod$patterns[[1]][]) <- "C20"mod <- pt2_read_mod(pt2_demo()) ## select a specific cell from the module cell <- pt2_cell(mod$patterns[[1]], 0L, 0L) ## show the command used for this cell pt2_command(cell) ## convert character strings into ProTracker commands pt2_command(c("C30", "F06")) ## Set the command for all cells in the first pattern ## to `C20` (volume at 50%): pt2_command(mod$patterns[[1]][]) <- "C20"
A path to demonstration ProTracker module file. It can be used for demonstration purposes.
pt2_demo()pt2_demo()
Returns a string with a path of a ProTracker module file
Pepijn de Vries
How long a module will play depends on several aspects such as
the length of the pattern sequence table (pt2_pattern_table(), pt2_length()),
the speed and tempo at which the patterns are defined,
loops, pattern breaks and delay effects. The duration in seconds of the
module is calculated by this function.
pt2_duration(x, options = pt2_render_options(), position = 0L, ...)pt2_duration(x, options = pt2_render_options(), position = 0L, ...)
x |
Object for which to determine the duration. Should be of class |
options |
A list of options used for rendering the audio. Use
|
position |
Starting position in the pattern sequence table ( |
... |
Ignored |
The duration in seconds (as a difftime class object)
Pepijn de Vries
mod <- pt2_read_mod(pt2_demo()) pt2_duration(mod) pt2_duration(mod, pt2_render_options(timing_mode = "cia")) pt2_duration(mod, pt2_render_options(timing_mode = "vblank"))mod <- pt2_read_mod(pt2_demo()) pt2_duration(mod) pt2_duration(mod, pt2_render_options(timing_mode = "cia")) pt2_duration(mod, pt2_render_options(timing_mode = "vblank"))
Get or set properties of a ProTracker sample. See 'details' section for available properties and associated functions.
pt2_finetune(sample, ...) pt2_finetune(sample, ...) <- value pt2_volume(sample, ...) pt2_volume(sample, ...) <- value pt2_loop_start(sample, ...) pt2_loop_start(sample, ...) <- value pt2_loop_length(sample, ...) pt2_loop_length(sample, ...) <- value pt2_is_looped(sample, ...) pt2_is_looped(sample, ...) <- valuept2_finetune(sample, ...) pt2_finetune(sample, ...) <- value pt2_volume(sample, ...) pt2_volume(sample, ...) <- value pt2_loop_start(sample, ...) pt2_loop_start(sample, ...) <- value pt2_loop_length(sample, ...) pt2_loop_length(sample, ...) <- value pt2_is_looped(sample, ...) pt2_is_looped(sample, ...) <- value
sample |
A module sample of class |
... |
Ignored |
value |
Replacement value for the sample property |
ProTracker audio samples hold some meta data that affect their playback. The following functions can be used to get or set these properties:
pt2_finetune(): When a sample is out of tune, you can use the
use the 'finetune' value to tune the sample. It is an integer value
ranging between -8 and +7.
pt2_volume(): An integer value to adjust the sample volume. It ranges
between 0 (silent) to 64 (maximum volume).
pt2_loop_start() and pt2_loop_length(): defines if a sample is looped.
The loop start is defined as an even integer indicating the sample index
(zero based) where the loop should start. The loop length is the number
of samples, over which to loop. The loop length should also be an even
number greater than 0. The sum of the loop start and the loop length
should never be larger than the sample's length.
pt2_is_looped(): a logical value, indicating if the sample is looped.
If you set the loop status to TRUE when the sample is not looped yet,
the new loop will start at index 0, and will have a length equal to the
sample length.
Returns an integer or logical value. Depending on the
called function. See the detail section for specifics.
mod <- pt2_read_mod(pt2_demo()) pt2_finetune(mod$samples[[1]]) pt2_finetune(mod$samples[[1]]) <- -8L pt2_volume(mod$samples[[2]]) pt2_volume(mod$samples[[2]]) <- 64L pt2_loop_start(mod$samples[[1]]) pt2_loop_start(mod$samples[[1]]) <- 400L pt2_loop_length(mod$samples[[1]]) pt2_loop_length(mod$samples[[1]]) <- 274L pt2_is_looped(mod$samples[[2]]) pt2_is_looped(mod$samples[[2]]) <- TRUEmod <- pt2_read_mod(pt2_demo()) pt2_finetune(mod$samples[[1]]) pt2_finetune(mod$samples[[1]]) <- -8L pt2_volume(mod$samples[[2]]) pt2_volume(mod$samples[[2]]) <- 64L pt2_loop_start(mod$samples[[1]]) pt2_loop_start(mod$samples[[1]]) <- 400L pt2_loop_length(mod$samples[[1]]) pt2_loop_length(mod$samples[[1]]) <- 274L pt2_is_looped(mod$samples[[2]]) pt2_is_looped(mod$samples[[2]]) <- TRUE
As explained in vignette("s3class"), the ProTracker pattern table
consists of cells containing information about the note and instrument
to be played. This function extracts the sample index (instrument)
from such a cell.
pt2_instrument(x, ...) pt2_instrument(x, silent = TRUE, ...) <- valuept2_instrument(x, ...) pt2_instrument(x, silent = TRUE, ...) <- value
x |
An object of class |
... |
Ignored. |
silent |
Don't warn about replacement values not being used or recycled. |
value |
Replacement value for the instrument (sample id). An |
Returns the integer sample index in x. The index
has a base of 1. An index of 0 means 'no sample'.
In case of the assignment operator (<-) an updated version of
x is returned
mod <- pt2_read_mod(pt2_demo()) ## select a specific cell from the first pattern cell <- pt2_cell(mod$patterns[[1]], 0L, 0L) ## get the sample number used in this cell pt2_instrument(cell) ## Replace the instrument in all cells of ## pattern 1 with sample number 3: pt2_instrument(mod$patterns[[1]][]) <- 3mod <- pt2_read_mod(pt2_demo()) ## select a specific cell from the first pattern cell <- pt2_cell(mod$patterns[[1]], 0L, 0L) ## get the sample number used in this cell pt2_instrument(cell) ## Replace the instrument in all cells of ## pattern 1 with sample number 3: pt2_instrument(mod$patterns[[1]][]) <- 3
Obtain information about a ProTracker module or embedded samples.
pt2_length(mod, ...) pt2_length(mod, ...) <- value pt2_n_pattern(mod, ...) pt2_pattern_table(mod, ...) pt2_pattern_table(mod, ...) <- value pt2_name(x, ...) pt2_name(x, ...) <- value ## S3 method for class 'pt2mod' pt2_name(x, ...) ## S3 replacement method for class 'pt2mod' pt2_name(x, ...) <- value ## S3 method for class 'pt2samp' pt2_name(x, ...) ## S3 replacement method for class 'pt2samp' pt2_name(x, ...) <- value ## S3 method for class 'pt2samplist' pt2_name(x, ...) ## S3 replacement method for class 'pt2samplist' pt2_name(x, ...) <- value pt2_n_sample(mod, ...)pt2_length(mod, ...) pt2_length(mod, ...) <- value pt2_n_pattern(mod, ...) pt2_pattern_table(mod, ...) pt2_pattern_table(mod, ...) <- value pt2_name(x, ...) pt2_name(x, ...) <- value ## S3 method for class 'pt2mod' pt2_name(x, ...) ## S3 replacement method for class 'pt2mod' pt2_name(x, ...) <- value ## S3 method for class 'pt2samp' pt2_name(x, ...) ## S3 replacement method for class 'pt2samp' pt2_name(x, ...) <- value ## S3 method for class 'pt2samplist' pt2_name(x, ...) ## S3 replacement method for class 'pt2samplist' pt2_name(x, ...) <- value pt2_n_sample(mod, ...)
... |
Ignored |
value |
Replacement value. In case of:
|
x, mod
|
A |
You can use the following functions to get or set information on
a ProTracker modules (represented by pt2mod class objects):
pt2_length(): get or set the length the pattern table.
pt2_n_pattern(): number of distinct patterns. Same as
length(mod$patterns).
pt2_pattern_table(): get or set table of pattern indexes. Patterns
will be played in this order. Normally, only the first pt2_length()
number of listed patterns are played. Patterns beyond this length are
only played if you explicitly start the module at that position,
or the module contains jump commands.
pt2_name(): get or set the name of a module. Can also be used
on samples in a module. Names in a ProTracker module are limited.
Module names are automatically truncated to 20 UTF8 characters.
For samples, the names are truncated to 22 characters.
Returns information about the specified ProTracker module
Pepijn de Vries
mod <- pt2_read_mod(pt2_demo()) pt2_length(mod) pt2_n_pattern(mod) pt2_n_sample(mod) pt2_pattern_table(mod) pt2_name(mod) pt2_name(pt2_sample(mod, 4L)) mod2 <- pt2_new_mod("new") pt2_length(mod2) <- 3L pt2_pattern_table(mod2)[1L:3L] <- c(0L, 2L, 1L) pt2_name(mod2) <- "foobar"mod <- pt2_read_mod(pt2_demo()) pt2_length(mod) pt2_n_pattern(mod) pt2_n_sample(mod) pt2_pattern_table(mod) pt2_name(mod) pt2_name(pt2_sample(mod, 4L)) mod2 <- pt2_new_mod("new") pt2_length(mod2) <- 3L pt2_pattern_table(mod2)[1L:3L] <- c(0L, 2L, 1L) pt2_name(mod2) <- "foobar"
Creates an empty ProTracker module, it is returned as a pt2mod class object.
pt2_new_mod(name, ...)pt2_new_mod(name, ...)
name |
Name for the new module. It will be truncated if longer than 20 characters. |
... |
Ignored |
A pt2mod class module, with no samples and one empty pattern.
Pepijn de Vries
mod <- pt2_new_mod("my_song")mod <- pt2_new_mod("my_song")
Creates a new ProTracker pattern, consisting
of four channels and 64 rows.
pt2_new_pattern(..., compact = TRUE)pt2_new_pattern(..., compact = TRUE)
... |
Currently ignored |
compact |
Should the pattern be formatted using a compact notation (as used for
file storage), or a none-compact format as used by the player? This can be
set with the |
Returns a new clean pt2pat object.
Pepijn de Vries
Gets note information from a cell in a pattern table in a ProTracker Module.
pt2_note(x, ...) pt2_note(x, silent = TRUE, ...) <- valuept2_note(x, ...) pt2_note(x, silent = TRUE, ...) <- value
x |
An object of class |
... |
Ignored |
silent |
Don't warn about replacement values not being used or recycled. |
value |
A |
A string representing the note's key is returned by the function.
The first letter indicates the position of the note in the
diatonic scale.
The second character indicates if it is a sharp key (with a hash
symbol, and a dash if it is not). The third character indicates
the octave of the note. In ProTracker allowed notes range from
"C-1" to "B-3".
Returns a string representing the note's key.
mod <- pt2_read_mod(pt2_demo()) ## select a specific cell from the first pattern cell <- pt2_cell(mod$patterns[[1]], 0L, 0L) ## get the note played by this particular cell pt2_note(cell) ## Replace the notes in the first pattern ## with those of the first bar of ## 'Frère Jacques' pt2_note(mod$patterns[[1]][]) <- c("C-2", "---", "---", "---", "D-2", "---", "---", "---", "E-2", "---", "---", "---", "C-2", "---", "---", "---")mod <- pt2_read_mod(pt2_demo()) ## select a specific cell from the first pattern cell <- pt2_cell(mod$patterns[[1]], 0L, 0L) ## get the note played by this particular cell pt2_note(cell) ## Replace the notes in the first pattern ## with those of the first bar of ## 'Frère Jacques' pt2_note(mod$patterns[[1]][]) <- c("C-2", "---", "---", "---", "D-2", "---", "---", "---", "E-2", "---", "---", "---", "C-2", "---", "---", "---")
Back in the days, ProTracker was hardware driven on a Commodore Amiga. It made
advantage of a custom chipset where each chip had specific tasks. One of the chips
(named Paula) could play 8 bit audio samples stored in memory directly to one of
the four audio channels. On that chip you could set the integer 'period' value which is
inversely related to the sample rate at which the sample is played. Hence, it
defines the pitch of the sample. ProTracker used the period value to play different
notes. With this function you can convert a character string representing a
note to its corresponding period value used by Paula.
pt2_note_to_period(note, empty_char = "-", finetune = 0, ...)pt2_note_to_period(note, empty_char = "-", finetune = 0, ...)
note |
A |
empty_char |
A |
finetune |
ProTracker used |
... |
Ignored. |
Returns a vector of integer period values.
pt2_note_to_period(c("A#2", "C-1"))pt2_note_to_period(c("A#2", "C-1"))
Get a pattern table (sequence of notes and effects on each of the 4 channels) at
a specific index from a ProTracker module. If mod is missing, a new empty
pattern is created.
pt2_pattern(mod, i, ..., compact = TRUE)pt2_pattern(mod, i, ..., compact = TRUE)
mod |
A |
i |
The index ( |
... |
Ignored |
compact |
Should the pattern be formatted using a compact notation (as used for
file storage), or a none-compact format as used by the player? This can be
set with the |
A pt2pat object representing the pattern.
Pepijn de Vries
mod <- pt2_read_mod(pt2_demo()) pt2_pattern(mod, 0L) pt2_pattern()mod <- pt2_read_mod(pt2_demo()) pt2_pattern(mod, 0L) pt2_pattern()
Functions to read and write ProTracker module. The read function will read a number of mod files that are compatible with ProTracker, this includes files compressed with PowerPacker (PP). The write function will only write modules conform ProTracker specifications.
pt2_read_mod(file, ...) pt2_write_mod(mod, file, ...)pt2_read_mod(file, ...) pt2_write_mod(mod, file, ...)
file |
Filename of the file to read from or write to. |
... |
Ignored |
mod |
An object of class |
pt2_read_mod() returns a pt2mod class object when successful.
pt_write_mod() returns NULL invisibly.
Pepijn de Vries
mod <- pt2_read_mod(pt2_demo())mod <- pt2_read_mod(pt2_demo())
Functions to read and write ProTracker audio samples. Reading is supported for common types of WAV, IFF and AIFF files. Writing is supported for WAV and IFF files.
pt2_read_sample(file, ...) pt2_write_sample(sample, file, ...)pt2_read_sample(file, ...) pt2_write_sample(sample, file, ...)
file |
Filename of the file to read from or write to. For |
... |
Ignored |
sample |
An object of class |
pt2_read_sample() returns a pt2samp class object when successful.
pt_write_sample() returns NULL invisibly.
Pepijn de Vries
mod <- pt2_read_mod(pt2_demo()) my_sample <- pt2_sample(mod, 1L) my_sample_file <- tempfile(fileext = ".iff") pt2_write_sample(my_sample, my_sample_file)mod <- pt2_read_mod(pt2_demo()) my_sample <- pt2_sample(mod, 1L) my_sample_file <- tempfile(fileext = ".iff") pt2_write_sample(my_sample, my_sample_file)
Renders a 16bit pulse-code modulation waveform from a ProTracker module. The rendered format can be played on a modern machine.
pt2_render(x, duration = NA, options = pt2_render_options(), ...) ## S3 method for class 'pt2mod' pt2_render( x, duration = NA, options = pt2_render_options(), position = 0L, ... ) ## S3 method for class 'pt2samp' pt2_render(x, duration = 5, options = pt2_render_options(), note = "C-3", ...) ## S3 method for class 'pt2patlist' pt2_render(x, duration = NA, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2pat' pt2_render(x, duration = NA, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2celllist' pt2_render(x, duration = 5, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2cell' pt2_render(x, duration = 5, options = pt2_render_options(), samples, ...)pt2_render(x, duration = NA, options = pt2_render_options(), ...) ## S3 method for class 'pt2mod' pt2_render( x, duration = NA, options = pt2_render_options(), position = 0L, ... ) ## S3 method for class 'pt2samp' pt2_render(x, duration = 5, options = pt2_render_options(), note = "C-3", ...) ## S3 method for class 'pt2patlist' pt2_render(x, duration = NA, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2pat' pt2_render(x, duration = NA, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2celllist' pt2_render(x, duration = 5, options = pt2_render_options(), samples, ...) ## S3 method for class 'pt2cell' pt2_render(x, duration = 5, options = pt2_render_options(), samples, ...)
x |
The object to be rendered |
duration |
Duration of the rendered output in seconds. When set to |
options |
A list of options used for rendering the audio. Use
|
... |
Ignored |
position |
Starting position in the pattern sequence table ( |
note |
Note to be played when |
samples |
When rendering or playing patterns (or elements of it), samples are needed
to interpret the pattern. Pass the samples as a sample list (class |
Rendered audio inheriting the audio::audioSample() class.
Pepijn de Vries
mod <- pt2_read_mod(pt2_demo()) aud <- pt2_render(mod) aud_samp <- pt2_render(mod$samples[[1]])mod <- pt2_read_mod(pt2_demo()) aud <- pt2_render(mod) aud_samp <- pt2_render(mod$samples[[1]])
Retrieve options for rendering ProTracker modules. See also
pt2_render().
pt2_render_options(...)pt2_render_options(...)
... |
Specify custom options. |
Returns a named list of options that can be used for rendering
ProTracker modules (see pt2_render() and play()).
It contains the following elements:
sample_rate: an integer value specifying the sample rate of the output in Hz.
stereo_separation: an integer percentage determining how much the
tracker channels will be separated to the left and right stereo output channels.
amiga_filter: a character string specifying the hardware filter to be emulated.
Can be "A500" for emulating Amiga 500 hardware filters, or "A1200" for emulating
Amiga 1200 hardware filters.
speed: An integer value specifying the initial speed of the module measured in 'ticks'
per row. Should be in range of 1 and 31.
tempo: An integer value specifying the initial tempo of the module. When speed is set
to 6, it measures the tempo as beats per minute. Should be in the range of 32 and 255
led_filter: A logical value specifying the state of the hardware LED filter to be emultated.
timing_mode: on the original Commodore Amiga timing in tracker modules could be
handled using different approaches. The first is the 'vertical blanking' method, were timing
was based on each time the monitor blanks (before being redrawn). This method thus depends
on the monitor that was used. PAL monitors operated at approximately 50 Hz, wereas NTCS monitors
used 60 Hz. Alternatively, the Complex Interface Adapter (CIA) offer hardware-level timing and
was system independent. You can set the timing mode by specifying "cia" (default) here, or
"vblank" (currently, only PAL is supported).
Pepijn de Vries
pt2_render_options(stereo_separation = 100)pt2_render_options(stereo_separation = 100)
Obtain sample data and info from a ProTracker module at a specific index. ProTracker modules can hold up to 31 samples. The index should range from 0 to 30.
pt2_sample(mod, i, ...)pt2_sample(mod, i, ...)
mod |
An object of class |
i |
The index of the requested sample (between 0 and 30). |
... |
Ignored. |
Returns a sample object of class pt2samp.
Pepijn de Vries
mod <- pt2_read_mod(pt2_demo()) smp <- pt2_sample(mod, 0L)mod <- pt2_read_mod(pt2_demo()) smp <- pt2_sample(mod, 0L)
Coerce a sample from a ProTracker module to an audio package
sample. Note that this function differs from pt2_render() as
it will not mimic Commodore Amiga hardware. It will just
pass the pure sample data.
pt2_sample_to_audio( sample, note = "C-3", finetune = 0, options = pt2_render_options(), loop = 20L, ... )pt2_sample_to_audio( sample, note = "C-3", finetune = 0, options = pt2_render_options(), loop = 20L, ... )
sample |
A ProTracker sample of class |
note |
A character representing a note ( |
finetune |
An |
options |
Options used for calculating play back rate. See
|
loop |
An |
... |
Ignored |
Returns an audio sample of class audio::audioSample().
mod <- pt2_read_mod(pt2_demo()) aud <- pt2_sample_to_audio(mod$samples[[1]])mod <- pt2_read_mod(pt2_demo()) aud <- pt2_sample_to_audio(mod$samples[[1]])
Check aspects of S3 class objects for validity. For samples for instance it is checked if all parameters (volume, finetune, etc.) are within ProTracker specifications.
pt2_validate(x, ...) ## S3 method for class 'pt2samp' pt2_validate(x, ...)pt2_validate(x, ...) ## S3 method for class 'pt2samp' pt2_validate(x, ...)
x |
object to be validated |
... |
Ignored |
A logical value indicating whether the object is valid or not
Pepijn de Vries
mod <- pt2_read_mod(pt2_demo()) pt2_validate(mod$samples[[1]])mod <- pt2_read_mod(pt2_demo()) pt2_validate(mod$samples[[1]])