Usage
# S4 method for class 'PTSample'
playSample(x, silence = 0, wait = TRUE, note = "C-3", loop = 1, ...)
# S4 method for class 'PTModule'
playSample(x, silence = 0, wait = TRUE, note = "C-3", loop = 1, ...)Arguments
- x
Either a
PTSampleor aPTModuleobject. In the latter case, all samples in the module will be played in order.- silence
Especially for short samples, the
audio::playroutine can be a bit buggy: playing audible noise, ticks or parts from other samples at the end of the sample. By adding silence after the sample, this problem is evaded. Use this argument to specify the duration of this silence in seconds. When,xis aPTModuleobject, the silence will also be inserted in between samples.- wait
A
logicalvalue. When set toTRUEthe playing routine will wait with executing any code until the playing is finished. When set toFALSE, subsequent R code will be executed while playing.- note
A
characterstring specifying the note to be used for calculating the playback sample rate (usingnoteToSampleRate). It should start with the note (ranging fromA' up toG') optionally followed by a hash sign (#') if a note is sharp (or a dash (-') if it's not) and finally the octave number (ranging from 1 up to 3). A valid notation would for instance be 'F#3'. ThefineTuneas specified for the sample will also be used as an argument for calculating the playback rate. A customfinetunecan also be passed as an argument tonoteToSampleRate.- loop
A positive
numericindicating the duration of a looped sample in seconds. A looped sample will be played at least once, even if the specified duration is less than the sum ofloopStartposition and theloopLength. SeeloopStartandloopLengthfor details on how to set (or disable) a loop.- ...
Further arguments passed on to
noteToSampleRate. Can be used to change the video mode, or finetune argument for the call to that method.
Details
This method plays PTSamples and such samples from
PTModule objects, using the audio::play method
from the audio package. Default fineTune and volume
as specified for the PTSample will be applied when playing
the sample.
See also
Other sample.operations:
PTSample-class,
PTSample-method,
fineTune(),
loopLength(),
loopSample(),
loopStart(),
loopState(),
name,
read.sample(),
sampleLength(),
volume(),
waveform(),
write.sample()
Other sample.rate.operations:
sampleRate
Examples
if (interactive()) {
data("mod.intro")
## play all samples in mod.intro:
playSample(mod.intro, 0.2, loop = 0.5)
## play a chromatic scale using sample number 3:
for (note in c("A-2", "A#2", "B-2", "C-3", "C#3",
"D-3", "D#3", "E-3", "F-3", "F#3",
"G-3", "G#3"))
{
playSample(PTSample(mod.intro, 3), note = note, silence = 0.05, loop = 0.4)
}
## play the sample at a rate based on a specific
## video mode and finetune:
playSample(PTSample(mod.intro, 3), video = "NTSC", finetune = -5)
}