Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

read.sample

Read an audio file and coerce to a PTSample object


Description

Reads audio files from "wav" and "mp3" files, using tuneR methods. Commodore Amiga native formats "8svx" and "raw" can also be read.

Usage

## S4 method for signature 'character'
read.sample(filename, what = c("wav", "mp3", "8svx", "raw"))

Arguments

filename

A character string representing the filename to be read.

what

A character string indicating what type of file is to be read. Can be one of the following: "wav" (default), "mp3", "8svx" or "raw". The AmigaFFH package needs to be installed in order to read 8svx files.

Details

This method provides a wrapper for the readWave and readMP3 methods from 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 read.iff method from the 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.

Value

Returns a PTSample object based on the file read.

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.

Author(s)

Pepijn de Vries

See Also

Other io.operations: read.module(), write.module(), write.sample()

Examples

## Not run: 
data("mod.intro")

## create an audio file which we can then read:
write.sample(PTSample(mod.intro, 2), "snaredrum.iff", "8svx")

## read the created sample:
snare <- read.sample("snaredrum.iff", "8svx")
print(snare)

## End(Not run)

ProTrackR

Manipulate and Play 'ProTracker' Modules

v0.3.7
GPL-3
Authors
Pepijn de Vries [aut, cre, dtc]
Initial release
2020-02-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.