WaveToIFF: Convert WaveMC objects into an Interchange File Format object

View source: R/iff.8svx.r

WaveToIFFR Documentation

Convert WaveMC objects into an Interchange File Format object

Description

Convert tuneR::WaveMC() objects (or objects that can be coerced to WaveMC objects) into an IFFChunk-class() object which can be stored as a valid Iterchange File Format (write.iff()).

Usage

WaveToIFF(
  x,
  loop.start = NA,
  octaves = 1,
  compress = c("sCmpNone", "sCmpFibDelta"),
  ...
)

Arguments

x

A tuneR::WaveMC() object that needs to be converted into an IFFChunk() object. x can also be any other class object that can be coerced into a tuneR::WaveMC() object. tuneR::Wave() and PTSample() objects are therefore also allowed.

loop.start

If the sample should be looped from a specific position to the end of the sample, this argument specifies the starting position in samples (with a base of 0) for looping. loop.start therefore should be a whole non-negative number. When set to NA or negative values, the sample will not be looped.

octaves

A whole positive numeric value indicating the number of octaves that should be stored in the resulting IFF chunk. The original wave will be resampled for each value larger than 1. Each subsequent octave will contain precisely twice as many samples as the previous octave.

compress

A character string indicating whether compression should be applied to the waveform. "sCmpNone" (default) applies no compression, "sCmpFibDelta" applies the lossy deltaFibonacciCompress()ion.

...

Currently ignored.

Details

tuneR::WaveMC() objects can be read from contemporary file containers with tuneR::readWave() or tuneR::readMP3(). With this function such objects can be converted into an IFFChunk-class() object which can be stored conform the Interchange File Format (write.iff()).

When x is not a pcm formatted 8-bit sample, x will first be normalised and scaled to a pcm-formatted 8-bit sample using tuneR::normalize(). If you don't like the result you need to convert the sample to 8-bit pcm yourself before calling this function.

Value

Returns an IFFChunk-class() object with a FORM container that contains an 8SVX waveform based on x.

Author(s)

Pepijn de Vries

References

https://en.wikipedia.org/wiki/8SVX

See Also

Other iff.operations: IFFChunk-class, as.raster.AmigaBasicShape(), getIFFChunk(), interpretIFFChunk(), rasterToIFF(), rawToIFFChunk(), read.iff(), write.iff()

Examples

## Not run: 
## First get an audio sample from the ProTrackR package
snare.samp <- ProTrackR::PTSample(ProTrackR::mod.intro, 2)

## The sample can easily be converted into an IFFChunk:
snare.iff <- WaveToIFF(snare.samp)

## You could also first convert the sample into a Wave object:
snare.wav <- as(snare.samp, "Wave")

## And then convert into an IFFChunk. The result is the same:
snare.iff <- WaveToIFF(snare.wav)

## You could also use a sine wave as input (although you will get some warnings).
## This will work because the vector of numeric data can be coerced to
## a WaveMC object
sine.iff <- WaveToIFF(sin((0:2000)/20))

## End(Not run)

AmigaFFH documentation built on June 22, 2024, 11:03 a.m.