Skip to contents

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

name

A vector of length 22 of class raw, representing the name of the PTSample. It is often used to include descriptive information in a PTModule. The name of a sample can be extracted or replaced with the name method.

finetune

Single value of class raw. The loNybble of the raw 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 the period_table. The fine tune value can be extracted or replace with the fineTune 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 the volume method.

wloopstart

A vector of length 2 of class raw. The raw data represent a single unsigned number representing the starting position of a loop in the sample. It should have a value of 0 when there is no loop. Its value could range from 0 up to 0xffff. 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 the sampleLength. Its value can be extracted or replaced with the loopStart method.

wlooplen

A vector of length 2 of class raw. The raw 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 of 2 when there is no loop. Its value could range from 2 up to 2*0xffff (= 131070) and can only be even (it can be 0 when the sample is empty). The sum of the loop start position and the loop length should not exceed the sampleLength. Its value can be extracted or replaced with the loopLength method.

left

Object of class numeric representing the waveform of the left channel. Should be integer values ranging from 0 up to 255. It can be extracted or replaced with the waveform method.

right

Object of class numeric representing the right channel. This slot is inherited from the tuneR::Wave class and should be numeric(0) for all PTSamples, as they are all mono.

stereo

Object of class logical whether this is a stereo representation. This slot is inherited from the tuneR::Wave class. As PTSamples are always mono, this slot should have the value FALSE.

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 the tuneR::Wave class. As PTSamples 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 the tuneR::Wave class, for PTSamples its value should always be TRUE.

Author

Pepijn de Vries