PTSample-class {ProTrackR} | R Documentation |
The PTSample class
Description
This class holds audio fragments with meta-information, to be used in
PTModule
objects.
Details
This class holds audio fragments with meta-information (so-called samples),
to be used in PTModule
objects. This class extends
the tuneR::Wave
class from tuneR::tuneR
. It therewith inherits
all properties and cool methods available from the tuneR::tuneR
package.
This allows you, for instance, to generate power spectra (tuneR::powspec
)
of them. You can also plot the waveform with the plot-Wave
method.
See tuneR::tuneR
for all possibilities with tuneR::Wave
objects.
If you want you can also explicitly coerce PTSample
to
tuneR::Wave
objects like this: as(new("PTSample"), "Wave")
.
The PTSample
class has some slots that are additional to the
tuneR::Wave
class, as ProTracker requires additional information on
the sample with respect to its name, fine tune, volume and loop positions.
The PTSample
class restricts the enherited tuneR::Wave
class such that it will only hold 8 bit, mono, pcm waves with a maximum of
2*0xffff = 131070
samples, as per ProTracker standards. The length should
always be even.
PTSample
s can be imported and exported using the
read.sample
and write.sample
methods respectively.
tuneR::Wave
objects and raw
data can be coerced to
PTSample
s with the PTSample-method
.
Slots
name
A
vector
of length 22 of classraw
, representing the name of thePTSample
. It is often used to include descriptive information in aPTModule
. The name of a sample can be extracted or replaced with thename
method.finetune
Single value of class
raw
. TheloNybble
of theraw
value, represents the sample fine tune value ranging from -8 up to 7. This value is used to tweak the playback sample rate, in order to tune it. Negative values will lower the sample rate of notes, positive values will increase the sample rate of notes. Period values corresponding to specific notes and fine tune values are stored in theperiod_table
. The fine tune value can be extracted or replace with thefineTune
method.volume
Single value of class
raw
. The raw data corresponds with the default playback volume of the sample. It ranges from 0 (silent) up to 64 (maximum volume). The volume value can be extracted or replaced with thevolume
method.wloopstart
A
vector
of length 2 of classraw
. Theraw
data represent a single unsigned number representing the starting position of a loop in the sample. It should have a value of0
when there is no loop. Its value could range from0
up to0xffff
. To get the actual position in bytes the value needs to be multiplied with 2 and can therefore only be can only be even. The sum of the loop start position and the loop length should not exceed thesampleLength
. Its value can be extracted or replaced with theloopStart
method.wlooplen
A
vector
of length 2 of classraw
. Theraw
data represent a single unsigned number representing the length of a loop in the sample. To get the actual length in bytes, this value needs to be multiplied by 2 and can therefore only be even. It should have a value of2
when there is no loop. Its value could range from2
up to2*0xffff
(=131070
) and can only be even (it can be0
when the sample is empty). The sum of the loop start position and the loop length should not exceed thesampleLength
. Its value can be extracted or replaced with theloopLength
method.left
Object of class
numeric
representing the waveform of the left channel. Should beinteger
values ranging from 0 up to 255. It can be extracted or replaced with thewaveform
method.right
Object of class
numeric
representing the right channel. This slot is inherited from thetuneR::Wave
class and should benumeric(0)
for allPTSample
s, as they are all mono.stereo
Object of class
logical
whether this is a stereo representation. This slot is inherited from thetuneR::Wave
class. AsPTSample
s are always mono, this slot should have the valueFALSE
.samp.rate
Object of class
numeric
representing the sampling rate.bit
Object of class
numeric
representing the bit-wise quality. This slot is inherited from thetuneR::Wave
class. AsPTSample
s are always of 8 bit quality, the value of this slot should always be 8.pcm
Object of class
logical
indicating whether wave format is PCM. This slot is inherited from thetuneR::Wave
class, forPTSample
s its value should always beTRUE
.
Author(s)
Pepijn de Vries
See Also
Other sample.operations:
PTSample-method
,
fineTune()
,
loopLength()
,
loopSample()
,
loopStart()
,
loopState()
,
name
,
playSample()
,
read.sample()
,
sampleLength()
,
volume()
,
waveform()
,
write.sample()