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.
PTSamples can be imported and exported using the
read.sample and write.sample methods respectively.
tuneR::Wave objects and raw data can be coerced to
PTSamples with the PTSample-method.
Slots
nameA
vectorof 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 thenamemethod.finetuneSingle value of class
raw. TheloNybbleof therawvalue, 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 thefineTunemethod.volumeSingle 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 thevolumemethod.wloopstartA
vectorof length 2 of classraw. Therawdata represent a single unsigned number representing the starting position of a loop in the sample. It should have a value of0when there is no loop. Its value could range from0up 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 theloopStartmethod.wlooplenA
vectorof length 2 of classraw. Therawdata 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 of2when there is no loop. Its value could range from2up to2*0xffff(=131070) and can only be even (it can be0when 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 theloopLengthmethod.leftObject of class
numericrepresenting the waveform of the left channel. Should beintegervalues ranging from 0 up to 255. It can be extracted or replaced with thewaveformmethod.rightObject of class
numericrepresenting the right channel. This slot is inherited from thetuneR::Waveclass and should benumeric(0)for allPTSamples, as they are all mono.stereoObject of class
logicalwhether this is a stereo representation. This slot is inherited from thetuneR::Waveclass. AsPTSamples are always mono, this slot should have the valueFALSE.samp.rateObject of class
numericrepresenting the sampling rate.bitObject of class
numericrepresenting the bit-wise quality. This slot is inherited from thetuneR::Waveclass. AsPTSamples are always of 8 bit quality, the value of this slot should always be 8.pcmObject of class
logicalindicating whether wave format is PCM. This slot is inherited from thetuneR::Waveclass, forPTSamples its value should always beTRUE.
See also
Other sample.operations:
PTSample-method,
fineTune(),
loopLength(),
loopSample(),
loopStart(),
loopState(),
name,
playSample(),
read.sample(),
sampleLength(),
volume(),
waveform(),
write.sample()