Skip to contents

Information of PTCell, PTTrack and PTPattern objects are stored as raw values. This method can be used to extract and replace this raw data. PTModule objects can also be converted to raw data but not replaced by it.

Usage

# S4 method for PTCell
as.raw(x)

# S4 method for PTCell,raw
as.raw(x) <- value

# S4 method for PTTrack
as.raw(x)

# S4 method for PTTrack,matrix
as.raw(x) <- value

# S4 method for PTPattern
as.raw(x)

# S4 method for PTPattern,matrix
as.raw(x) <- value

# S4 method for PTModule
as.raw(x)

Arguments

x

A PTCell, PTTrack or PTPattern object, for which the raw data needs to extracted or replaced. A PTModule object is also allowed, but this object cannot be replaced.

value

raw data with which the raw data in object x needs to be replaced.

If x is a PTCell object, value should be a vector of four raw values (conform specifications provided at the documentation of the PTCell).

If x is a PTTrack object, value should be a 64 by 4 matrix holding raw values (conform specifications provided at the documentation of the PTTrack).

If x is a PTPattern object, value should be a 64 by 16 matrix holding raw values (conform specifications provided at the documentation of the PTPattern).

Value

For as.raw, a length 4 vector, 64 by 4 matrix or a 64 by 16 matrix of raw data is returned, when x is of class PTCell, PTTrack or PTPattern, respectively.

If x is a PTModule object, the raw data returned will have the same format as the ProTracker file format.

For as.raw<-, a copy of object x is returned in which the raw data is replaced by value.

Details

A PTCell is an element of a PTTrack which in turn is an element of a PTPattern. A PTPattern tells a tracker which sample to play at which frequency on which of the four audio channels and with which effects. A PTCell in essence holds all this information as described at the documentation of the PTCell.

Data in these objects are stored in these objects in a raw form, to save working memory and to comply to the ProTracker file specifications (see documentation of each of these classes for more details). This method can be used to extract and replace raw data.

The PTModule object has a more complex structure but can also be converted into raw data (the way it would be stored in a ProTracker module file). However, this object cannot be replaced by raw data.

Author

Pepijn de Vries

Examples

data("mod.intro")

## Get the raw data of the PTCell at
## pattern #1, track #1 and row #1
## of mod.intro:
as.raw(PTCell(mod.intro, 1, 1, 1))
#> [1] 00 d6 1a 08

## idem for PTTrack #1 of pattern #1:
as.raw(PTTrack(mod.intro, 1, 1))
#>       [,1] [,2] [,3] [,4]
#>  [1,]   00   d6   1a   08
#>  [2,]   00   00   1a   08
#>  [3,]   00   00   1a   08
#>  [4,]   00   00   00   00
#>  [5,]   00   00   1a   08
#>  [6,]   00   00   00   00
#>  [7,]   00   00   1a   08
#>  [8,]   00   00   00   00
#>  [9,]   00   00   1a   08
#> [10,]   00   00   00   00
#> [11,]   00   00   1a   08
#> [12,]   00   00   00   00
#> [13,]   00   8f   10   00
#> [14,]   00   00   0a   08
#> [15,]   00   a0   10   00
#> [16,]   00   00   0a   08
#> [17,]   00   d6   1a   08
#> [18,]   00   00   1a   08
#> [19,]   00   00   1a   08
#> [20,]   00   00   00   00
#> [21,]   00   00   1a   08
#> [22,]   00   00   00   00
#> [23,]   00   00   1a   08
#> [24,]   00   00   00   00
#> [25,]   00   00   1a   08
#> [26,]   00   00   00   00
#> [27,]   00   00   1a   08
#> [28,]   00   00   00   00
#> [29,]   01   1d   10   00
#> [30,]   00   00   0a   08
#> [31,]   00   fe   10   00
#> [32,]   00   00   0a   08
#> [33,]   00   aa   1a   08
#> [34,]   00   00   1a   08
#> [35,]   00   00   1a   08
#> [36,]   00   00   00   00
#> [37,]   00   00   1a   08
#> [38,]   00   00   00   00
#> [39,]   00   00   1a   08
#> [40,]   00   00   00   00
#> [41,]   00   00   1a   08
#> [42,]   00   00   00   00
#> [43,]   00   00   1a   08
#> [44,]   00   00   00   00
#> [45,]   00   71   10   00
#> [46,]   00   00   0a   08
#> [47,]   00   7f   10   00
#> [48,]   00   00   0a   08
#> [49,]   00   be   1a   08
#> [50,]   00   00   1a   08
#> [51,]   00   00   1a   08
#> [52,]   00   00   00   00
#> [53,]   00   00   1a   08
#> [54,]   00   00   00   00
#> [55,]   00   00   1a   08
#> [56,]   00   00   00   00
#> [57,]   00   00   1a   08
#> [58,]   00   00   00   00
#> [59,]   00   00   1a   08
#> [60,]   00   00   00   00
#> [61,]   00   7f   10   00
#> [62,]   00   00   0a   08
#> [63,]   00   8f   10   00
#> [64,]   00   00   0a   08

## idem for PTPattern #1:
as.raw(PTPattern(mod.intro, 1))
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#>  [1,]   00   d6   1a   08   00   d6   2c   40   01    e0    3f    06    00
#>  [2,]   00   00   1a   08   00   d6   2c   30   00    00    0a    01    00
#>  [3,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#>  [4,]   00   00   00   00   00   d6   20   00   00    00    0a    02    00
#>  [5,]   00   00   1a   08   00   d6   20   00   00    00    01    20    00
#>  [6,]   00   00   00   00   00   f0   4c   08   00    00    0a    02    00
#>  [7,]   00   00   1a   08   00   d6   20   00   00    00    02    20    00
#>  [8,]   00   00   00   00   00   f0   4c   08   00    00    0a    01    00
#>  [9,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [10,]   00   00   00   00   00   78   4c   08   00    00    0a    01    00
#> [11,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [12,]   00   00   00   00   00   8f   4c   08   00    00    0a    01    00
#> [13,]   00   8f   10   00   00   d6   20   00   00    00    0a    01    00
#> [14,]   00   00   0a   08   00   a0   4c   08   00    00    00    00    00
#> [15,]   00   a0   10   00   00   d6   20   00   00    00    00    00    00
#> [16,]   00   00   0a   08   00   f0   4c   08   00    00    00    00    00
#> [17,]   00   d6   1a   08   00   d6   2c   40   01    e0    3f    06    00
#> [18,]   00   00   1a   08   00   d6   2c   30   00    00    0a    01    00
#> [19,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [20,]   00   00   00   00   00   d6   20   00   00    00    0a    02    00
#> [21,]   00   00   1a   08   00   d6   20   00   00    00    01    20    01
#> [22,]   00   00   00   00   00   f0   4c   08   00    00    0a    02    00
#> [23,]   00   00   1a   08   00   d6   20   00   00    00    02    20    01
#> [24,]   00   00   00   00   00   f0   4c   08   00    00    0a    01    00
#> [25,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [26,]   00   00   00   00   00   78   4c   08   00    00    0a    01    00
#> [27,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [28,]   00   00   00   00   00   8f   4c   08   00    00    0a    01    00
#> [29,]   01   1d   10   00   00   d6   20   00   00    00    0a    01    00
#> [30,]   00   00   0a   08   01   40   4c   08   00    00    00    00    00
#> [31,]   00   fe   10   00   00   d6   20   00   00    00    00    00    00
#> [32,]   00   00   0a   08   01   1d   4c   08   00    00    00    00    00
#> [33,]   00   aa   1a   08   00   d6   2c   40   01    7d    30    00    00
#> [34,]   00   00   1a   08   00   d6   2c   30   00    00    0a    01    00
#> [35,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [36,]   00   00   00   00   00   d6   20   00   00    00    0a    02    00
#> [37,]   00   00   1a   08   00   d6   20   00   00    00    01    26    00
#> [38,]   00   00   00   00   00   be   4c   08   00    00    0a    02    00
#> [39,]   00   00   1a   08   00   d6   20   00   00    00    02    26    00
#> [40,]   00   00   00   00   00   aa   4c   08   00    00    0a    01    00
#> [41,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [42,]   00   00   00   00   00   be   4c   08   00    00    0a    01    00
#> [43,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [44,]   00   00   00   00   00   be   4c   08   00    00    0a    01    00
#> [45,]   00   71   10   00   00   d6   20   00   00    00    0a    01    00
#> [46,]   00   00   0a   08   00   be   4c   08   00    00    00    00    00
#> [47,]   00   7f   10   00   00   d6   20   00   00    00    00    00    00
#> [48,]   00   00   0a   08   01   53   4c   08   00    00    00    00    00
#> [49,]   00   be   1a   08   00   d6   2c   40   01    ac    30    00    00
#> [50,]   00   00   1a   08   00   d6   2c   30   00    00    0a    01    00
#> [51,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [52,]   00   00   00   00   00   d6   20   00   00    00    0a    02    00
#> [53,]   00   00   1a   08   00   d6   20   00   00    00    01    2b    00
#> [54,]   00   00   00   00   00   8f   4c   08   00    00    0a    02    00
#> [55,]   00   00   1a   08   00   d6   20   00   00    00    02    2b    00
#> [56,]   00   00   00   00   00   8f   4c   08   00    00    0a    01    00
#> [57,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [58,]   00   00   00   00   00   aa   4c   08   00    00    0a    01    00
#> [59,]   00   00   1a   08   00   d6   20   00   00    00    0a    01    00
#> [60,]   00   00   00   00   00   d6   4c   08   00    00    0a    01    00
#> [61,]   00   7f   10   00   00   d6   20   00   00    00    0a    01    00
#> [62,]   00   00   0a   08   00   8f   4c   08   00    00    00    00    00
#> [63,]   00   8f   10   00   00   a0   4c   08   00    00    00    00    00
#> [64,]   00   00   0a   08   00   d6   4c   08   00    00    00    00    00
#>       [,14] [,15] [,16]
#>  [1,]    f0    40    00
#>  [2,]    00    0a    02
#>  [3,]    d6    40    00
#>  [4,]    00    0a    02
#>  [5,]    be    40    00
#>  [6,]    00    0a    02
#>  [7,]    b4    40    00
#>  [8,]    00    0a    02
#>  [9,]    a0    40    00
#> [10,]    00    0a    02
#> [11,]    b4    40    00
#> [12,]    00    0a    02
#> [13,]    be    40    00
#> [14,]    00    0a    02
#> [15,]    d6    40    00
#> [16,]    00    0a    02
#> [17,]    f0    40    00
#> [18,]    00    0a    02
#> [19,]    be    40    00
#> [20,]    00    0a    02
#> [21,]    40    40    00
#> [22,]    00    0a    02
#> [23,]    1d    40    00
#> [24,]    00    0a    02
#> [25,]    f0    40    00
#> [26,]    00    0a    01
#> [27,]    00    00    00
#> [28,]    00    0a    01
#> [29,]    00    00    00
#> [30,]    00    0a    01
#> [31,]    00    00    00
#> [32,]    00    0a    01
#> [33,]    be    40    00
#> [34,]    00    0a    02
#> [35,]    aa    40    00
#> [36,]    00    0a    02
#> [37,]    97    40    00
#> [38,]    00    0a    02
#> [39,]    8f    40    00
#> [40,]    00    0a    02
#> [41,]    7f    40    00
#> [42,]    00    0a    02
#> [43,]    8f    40    00
#> [44,]    00    0a    02
#> [45,]    97    40    00
#> [46,]    00    0a    02
#> [47,]    aa    40    00
#> [48,]    00    0a    02
#> [49,]    d6    40    00
#> [50,]    00    0a    02
#> [51,]    be    40    00
#> [52,]    00    0a    02
#> [53,]    aa    40    00
#> [54,]    00    0a    02
#> [55,]    a0    40    00
#> [56,]    00    0a    02
#> [57,]    8f    40    00
#> [58,]    00    0a    02
#> [59,]    a0    40    00
#> [60,]    00    0a    02
#> [61,]    aa    40    00
#> [62,]    00    0a    02
#> [63,]    be    40    00
#> [64,]    00    0a    02

## replace raw data of PTCell 1, 1, 1
## with that of PTCell 2, 1, 1:
as.raw(PTCell(mod.intro, 1, 1, 1)) <-
  as.raw(PTCell(mod.intro, 2, 1, 1))