Learn R Programming

ProTrackR (version 0.3.7)

PTCell-method: Coerce to or replace PTCell

Description

This method will coerce a set of objects to a PTCell object. It can also be used to select specific cells from PTModule, PTPattern and PTTrack objects and replace the selected PTCell.

Usage

# S4 method for raw,missing,missing,missing
PTCell(x)

# S4 method for character,missing,missing,missing PTCell(x)

# S4 method for PTModule,numeric,numeric,numeric PTCell(x, row, track, pattern)

# S4 method for PTModule,numeric,numeric,numeric,PTCell PTCell(x, row, track, pattern) <- value

# S4 method for PTPattern,numeric,numeric,missing PTCell(x, row, track)

# S4 method for PTPattern,numeric,numeric,missing,PTCell PTCell(x, row, track) <- value

# S4 method for PTTrack,numeric,missing,missing PTCell(x, row)

# S4 method for PTTrack,numeric,missing,missing,PTCell PTCell(x, row) <- value

Value

When PTCell is used, a PTCell object based on x is returned.

When PTCell<- is used, object x is returned in which the selected PTCell is replaced with value.

Arguments

x

Object (any of raw data, a character string, a PTTrack, a PTPattern or a PTModule) to coerce to a PTCell. See details below for the required format of x.

row

When x is a PTTrack, a PTPattern, or a PTModule, provide an index [1,64] of the row that needs to be coerced to a PTCell.

track

When x is a PTPattern, or a PTModule, provide an index [1,4] of the track that needs to be coerced to a PTCell.

pattern

When x is a PTModule, provide an index of the pattern that needs to be coerced to a PTCell. Note that ProTracker uses indices for patterns that start at zero, whereas R uses indices that start at one. Hence add one to an index obtained from a PTModule object (e.g., x$pattern.order)

value

An object of PTCell with which the PTCell object at the specified indices in object x needs to be replaced.

Author

Pepijn de Vries

Details

Method to coerce x to class PTCell.

When x is raw data, it should consist of a vector of 4 elements, formatted as specified in the PTCell-class.

When x is a character string, it should be formatted as follows: "NNO SS EEE", where NN is the note (for instance "C-" or "A#", where the dash has no particular meaning and may be omitted, the hash sign indicates a sharp note). Use a dash if the cell holds no note. O is the octave (with a value of 0, or a dash, if a note is missing, otherwise any of 1, 2 or 3). SS is the sample index number, formatted as two hexadecimal digits (for example `1A'). EEE is a three hexadecimal digit effect or trigger code (for more details see the PTCell-class). The method is not case sensitive, so you can use both upper and lower case. White spaces are ignored, you can use as many as you would like. A correct character input for x would be for example: "A#2 01 A0F". An `blank' character representation would look like this: "--- 00 000".

When x is of class PTTrack, PTPattern, or PTModule, the PTCell at the specified indices (row, track and pattern) is returned, or can be replaced.

See Also

Other cell.operations: PTCell-class, effect(), note(), sampleNumber()

Examples

Run this code
## This will create an empty PTCell (equivalent
## to new("PTCell"):
PTCell(raw(4))

## Use a character representation to create
## a new PTCell object. A cell with note
## B in octave 2, sample number 10 and with
## effect '105':
cell <- PTCell("B-2 0A 105")

data("mod.intro")

## replace PTCell at pattern number 1, track
## number 2, and row number 3:
PTCell(mod.intro, 3, 2, 1) <- cell

Run the code above in your browser using DataLab