Extract or replace a PTSample waveform
Extract or replace the waveform of a PTSample
object. The
waveform is represented by a vector
of numeric values ranging from
0 up to 255.
## S4 method for signature 'PTSample' waveform(sample, start.pos = 1, stop.pos = sampleLength(sample), loop = TRUE) ## S4 replacement method for signature 'PTSample' waveform(sample) <- value
sample |
A |
start.pos |
A |
stop.pos |
A |
loop |
A |
value |
A Use |
Sample waveforms are stored as 8 bit signed short integer values ranging
from -128 up to +127 in original ProTracker files. However, as the
PTSample
class extends the Wave
class,
the waveforms are represented by integer values ranging from 0 up to 255
in the ProTrackR package. As per ProTracker specifications,
samples are of 8 bit mono quality and can only have an even length with
a maximum of 2*0xffff
= 131070
. This method can be used to
extract a waveform or replace it.
For waveform
, the waveform of sample
is returned
as a vector
of numeric
values ranging from 0 up to 255.
If 'loop
' is set to FALSE
and the starting position is beyond the sample length, NA
values
are returned. If 'loop
' is set to TRUE
and the starting
position is beyond the sample loop (if present, see
loopState
), the waveform is modulated between the loop
positions.
For waveform<-
, a copy of object sample
is returned in which
the waveform has been replaced with value
.
Pepijn de Vries
Other integer.operations:
nybbleToSignedInt()
,
nybble()
,
rawToSignedInt()
,
rawToUnsignedInt()
,
signedIntToNybble()
,
signedIntToRaw()
,
unsignedIntToRaw()
Other sample.operations:
PTSample-class
,
PTSample-method
,
fineTune()
,
loopLength()
,
loopSample()
,
loopStart()
,
loopState()
,
name
,
playSample()
,
read.sample()
,
sampleLength()
,
volume()
,
write.sample()
data("mod.intro") ## Loop sample #1 of mod.intro beyond it's ## length of 1040 samples: wav1 <- waveform(PTSample(mod.intro, 1), 1, 5000) ## get the waveform from sample #2 ## of mod.intro: wav2 <- waveform(PTSample(mod.intro, 2)) ## create an echo effect using ## the extracted waveform: wav2 <- c(wav2, rep(128, 1000)) + c(rep(128, 1000), wav2)*0.25 - 25 ## assign this echoed sample to ## sample #2 in mod.intro: waveform(PTSample(mod.intro, 2)) <- wav2 ## Blank out sample #1 in mod.intro: waveform(PTSample(mod.intro, 1)) <- NA
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.