Skip to contents

Appends a specified PTPattern to a PTModule.

Usage

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

Arguments

x

A PTModule object to which a PTPattern is to be appended.

pattern

A PTPattern object which is to be appended to the PTModule x.

Value

Returns a PTModule, to which the PTPattern is appended.

Details

Depending on the trackerFlag, a ProTracker module can hold either 64 or 100 pattern tables. As long as the number of pattern tables is below this maximum, new pattern tables can be added to the module with this function.

The patternOrder table should hold the maximum index of the available pattern tables in a module, otherwise, the module is not valid. As the maximum index increases, by appending a pattern table, the patternOrder table should be updated. The appendPattern method does this automatically, by replacing the first non-unique index in the order table, outside the current order table's length, with the new maximum index. If this is not possible, the highest element in the order table is set to hold the maximum index.

Note

As per ProTracker specification, the pattern indices stored in the PTModule and obtained with patternOrder start at 0. Whereas R starts indexing at 1. Beware of this discrepancy.

Author

Pepijn de Vries

Examples

data("mod.intro")

## append an empty pattern to mod.intro

mod.intro <- appendPattern(mod.intro, new("PTPattern"))

## append a copy of pattern # 1 (this is pattern #0 in the
## patternOrder table) to mod.intro

mod.intro <- appendPattern(mod.intro, PTPattern(mod.intro, 1))