Obtain an octave number from a period value or extract or replace a
note of a PTCell
object.
Usage
# S4 method for numeric
octave(x)
# S4 method for PTCell
octave(x)
# S4 method for PTCell,numeric
octave(x) <- value
Arguments
- x
Either a (
vector
of) numeric value(s), representing a period value. It can also be aPTCell
object.- value
A
numeric
value representing the octave number with which that of objectx
needs to be replaced. 0, 1 and 3 are valid octave numbers. Use zero to disable both the note and octave for objectx
.Note that the octave can only be set for
PTCell
s for which a note is already defined.
Value
For octave
, a numeric
value representing the octave number
is returned.
For octave<-
, a copy of PTCell
object x
in which the
octave number is replaced by value
is returned.
Details
Period values are used by ProTracker to set a playback sample rate
and in essence determine the key and octave in which a sound is played.
This method can be used to obtain the octave number associated with a
period value (according to the ProTracker period_table
,
assuming zero fineTune
). If the period value is not in the
period_table
, the octave number associated with the
period closest to this value in the table is returned.
The octave number can also be obtained or replaced for a
PTCell
object.
See also
Other period.operations:
noteToPeriod()
,
note()
,
periodToChar()
,
period_table
,
sampleRate
Other note.and.octave.operations:
noteToPeriod()
,
noteUp()
,
note()
,
periodToChar()
,
sampleRate
Examples
data("mod.intro")
## get the octave number of PTCell at pattern #3, track #2,
## row #1 from mod.intro (which is number 3):
octave(PTCell(mod.intro, 1, 2, 3))
#> [1] 3
## replace the octave number of PTCell at pattern #3, track #2,
## row #1 from mod.intro with 2:
octave(PTCell(mod.intro, 1, 2, 3)) <- 2
## get the octave numbers associated with the period
## values 200 up to 400:
octave(200:400)
#> [1] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2
#> [38] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
#> [75] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
#> [112] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
#> [149] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
#> [186] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2