Usage
# S4 method for PTSample
playSample(x, silence = 0, wait = T, note = "C-3", loop = 1, ...)
# S4 method for PTModule
playSample(x, silence = 0, wait = T, note = "C-3", loop = 1, ...)
Arguments
- x
Either a
PTSample
or aPTModule
object. In the latter case, all samples in the module will be played in order.- silence
Especially for short samples, the
audio::play
routine 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,x
is aPTModule
object, the silence will also be inserted in between samples.- wait
A
logical
value. When set toTRUE
the 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
character
string specifying the note to be used for calculating the playback sample rate (usingnoteToSampleRate
). It should start with the note (ranging fromA' up to
G') 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'. ThefineTune
as specified for the sample will also be used as an argument for calculating the playback rate. A customfinetune
can also be passed as an argument tonoteToSampleRate
.- loop
A positive
numeric
indicating 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 ofloopStart
position and theloopLength
. SeeloopStart
andloopLength
for 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 PTSample
s 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 (FALSE) {
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)
}