Skip to contents

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

Usage

# S4 method for raw,missing
PTPattern(x)

# S4 method for matrix,missing
PTPattern(x)

# S4 method for PTModule,numeric
PTPattern(x, pattern)

# S4 method for PTModule,numeric,PTPattern
PTPattern(x, pattern) <- value

Arguments

x

Object (any of raw data, a 64 by 16 matrix of raw data, a 64 by 4 matrix of character strings, or a PTModule) to coerce to a PTPattern. See details below for the required format of x.

pattern

When x is a PTModule, provide an index of the pattern that needs to be coerced to a PTPattern. 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 PTPattern with which the PTPattern object at the specified index in object x needs to be replaced.

Value

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

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

Details

Method to coerce x to class PTPattern.

When x is a 64 by 16 matrix of raw data, each row implicitly represents the PTCell objects of each of the four tracks. Each PTCell consists of four raw values. The values in each row are formatted accordingly, where the values of the cells of each track are concatenated. See PTCell documentation for more details on the raw format of a PTCell object.

When x is a 64 by 16 matrix of character representations of PTCell objects, the character representation must be conform the specifications as documented at the PTCell.

When x is of class PTModule, the PTPattern at the specified index (pattern) is returned, or can be replaced.

Author

Pepijn de Vries

Examples

## This will create an 'empty' PTPattern with
## all 0x00 values, which is equivalent to
## new("PTPattern"):
PTPattern(as.raw(0x00))
#>       [,1]         [,2]         [,3]         [,4]        
#>  [1,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#>  [2,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#>  [3,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#>  [4,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#>  [5,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#>  [6,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#>  [7,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#>  [8,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#>  [9,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [10,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [11,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [12,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [13,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [14,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [15,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [16,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [17,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [18,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [19,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [20,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [21,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [22,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [23,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [24,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [25,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [26,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [27,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [28,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [29,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [30,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [31,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [32,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [33,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [34,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [35,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [36,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [37,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [38,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [39,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [40,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [41,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [42,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [43,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [44,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [45,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [46,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [47,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [48,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [49,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [50,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [51,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [52,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [53,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [54,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [55,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [56,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [57,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [58,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [59,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [60,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [61,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [62,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [63,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"
#> [64,] "--- 00 000" "--- 00 000" "--- 00 000" "--- 00 000"

## Create a PTPattern based on repeated
## PTCell character representations:
pat <- PTPattern(matrix("F#2 1A 20A", 64, 4))

data("mod.intro")

## Replace the first pattern in the patternOrder
## table in mod.intro with 'pat' (don't forget to
## add one (+1) to the index):
PTPattern(mod.intro,
          patternOrder(mod.intro)[1] + 1) <- pat