as.raw {ProTrackR}R Documentation

Extract and replace raw data

Description

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 signature 'PTCell'
as.raw(x)

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

## S4 method for signature 'PTTrack'
as.raw(x)

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

## S4 method for signature 'PTPattern'
as.raw(x)

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

## S4 method for signature '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).

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.

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.

Author(s)

Pepijn de Vries

See Also

Other raw.operations: nybbleToSignedInt(), nybble(), rawToCharNull(), rawToPTModule(), rawToSignedInt(), rawToUnsignedInt(), signedIntToNybble(), signedIntToRaw(), unsignedIntToRaw()

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))

## idem for PTTrack #1 of pattern #1:
as.raw(PTTrack(mod.intro, 1, 1))

## idem for PTPattern #1:
as.raw(PTPattern(mod.intro, 1))

## 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))


[Package ProTrackR version 0.4.3 Index]