Reads audio files from "wav" and "mp3" files, using tuneR::tuneR
methods. Commodore Amiga native formats "8svx" and "raw" can also be read.
Usage
# S4 method for class 'character'
read.sample(filename, what = c("wav", "mp3", "8svx", "raw"))Details
This method provides a wrapper for the tuneR::readWave and
tuneR::readMP3 methods from tuneR::tuneR. It also
provides the means to import audio from file formats native to the Commodore
Amiga. Simple 8svx files (also known
as "iff" files) can be read. This uses the AmigaFFH::read.iff method
from the AmigaFFH::AmigaFFH package.
It was also common practice to store audio samples as raw data on the
Commodore Amiga, where each byte simply represented a signed integer value
of the waveform.
All audio will be coerced to 8 bit mono with a maximum length of
2*0xffff = 131070 bytes (= samples) as per ProTracker standards.
Note
As per ProTracker standards, a sample should have an even length
(in bytes). If a sample file has an odd length, a raw 0x00 value
is added to the end.
See also
Other sample.operations:
PTSample-class,
PTSample-method,
fineTune(),
loopLength(),
loopSample(),
loopStart(),
loopState(),
name,
playSample(),
sampleLength(),
volume(),
waveform(),
write.sample()
Other io.operations:
read.module(),
write.module(),
write.sample()
Examples
data("mod.intro")
f <- tempfile(fileext = ".iff")
## create an audio file which we can then read:
write.sample(PTSample(mod.intro, 2), f, "8svx")
## read the created sample:
snare <- read.sample(f, "8svx")
print(snare)
#>
#> PTSample Object:
#> Sample name: a.k.a. freeze ii
#> Sample length (samples): 1930
#> Sample length (seconds): 0.116445510791833
#> Sample volume (0-64): 64
#> Loop start position: 0
#> Loop length: 2
#> Finetune: 0