class RemiAudio::Formats::WavFile
- RemiAudio::Formats::WavFile
- RemiAudio::Formats::AudioFile
- Reference
- Object
Overview
A virtual representation of a RIFF WAVE file (.wav).
RIFF WAVE (usually just called "wave") is, as the name suggests, based on the RIFF file format. It is an extremely common format that originated with IBM and Microsoft.
The official specification supports more encodings, as well as "extensible
WAVEs". This library does not support these. See WavEncoding
for a list
of supported encodings, and WAV_SUPPORTED_INT_BIT_DEPTHS
and
WAV_SUPPORTED_FLOAT_BIT_DEPTHS
for supported bit depths.
Defined in:
remiaudio/formats/wav.crConstructors
-
.create(io : IO, *, sampleRate : Int = 44100, bitDepth : Int = 16, channels : Int32 = 2, encoding : WavEncoding = WavEncoding::Lpcm) : WavFile
Creates a new
WavFile
that that is backed by io and returns the new instance. -
.create(filename : Path | String, *, sampleRate : Int = 44100, bitDepth : Int = 16, channels : Int = 2, encoding : WavEncoding = WavEncoding::Lpcm) : WavFile
Creates a new
WavFile
that is backed by a new file on disk. - .new(io : IO, *, sampleRate : UInt32 = 44100_u32, bitDepth : UInt8 = 16_u8, channels : UInt32 = 2_u32, encoding : WavEncoding = WavEncoding::Lpcm)
-
.new(*, sampleRate : UInt32 = 44100_u32, bitDepth : UInt8 = 16_u8, channels : UInt32 = 2_u32, encoding : WavEncoding = WavEncoding::Lpcm)
Creates a new
WavFile
that is backed by a fresh::IO::Memory
. -
.open(io : IO) : WavFile
Creates a new
WavFile
by reading the existing RIFF WAVE data from io. -
.open(filename : Path | String) : WavFile
Creates a new
WavFile
by reading the existing RIFF WAVE data from the given file.
Class Method Summary
-
.create(io : IO, *, sampleRate : Int = 44100, bitDepth : Int = 16, channels : Int32 = 2, encoding : WavEncoding = WavEncoding::Lpcm, &)
Creates a new
WavFile
that that is backed by io and yields the new instance to the block. -
.create(filename : Path | String, *, sampleRate : Int = 44100, bitDepth : Int = 16, channels : Int = 2, encoding : WavEncoding = WavEncoding::Lpcm, &)
Creates a new
WavFile
that is backed by a new file on disk, then yields it to the block. -
.open(io : IO, &)
Creates a new
WavFile
by reading the existing RIFF WAVE data from io, then yields it to the block. -
.open(filename : Path | String, &)
Creates a new
WavFile
by reading the existing RIFF WAVE data from the file, then yields it to the block.
Instance Method Summary
-
#copyTo(dest : IO) : Nil
Writes the current state of this file to dest.
-
#encoding : WavEncoding
The
WavEncoding
that the samples in this instance uses. -
#flush : Nil
:inherited:
-
#read(dest : Array(Float64)) : Int32
:inherited:
-
#readSamplesToEnd : SampleData
:inherited:
-
#sampleFormat : SampleFormat
:inherited:
Instance methods inherited from class RemiAudio::Formats::AudioFile
<<(sample : Float64) : self
<<,
bitDepth : UInt8
bitDepth,
channels : UInt32
channels,
close : Nil
close,
copyTo(dest : IO) : Nil
copyTo,
each(& : Float64 -> ) : Nil
each,
eachSample(& : Sample -> ) : Nil
eachSample,
flush : Nil
flush,
io : IO
io,
mono? : Bool
mono?,
numSamples : UInt64
numSamples,
pos : UInt64
pos,
pos=(value : Int) : Nil
pos=,
read(pos : Int) : Float64read(dest : Array(Float64)) : Int32
read : Float64 read, read? : Float64 | Nil read?, readSample(pos : Int) : Sample
readSample : Sample readSample, readSample? : Sample | Nil readSample?, readSamples(dest : SampleData) : Int32 readSamples, readSamplesToEnd : SampleData readSamplesToEnd, readToEnd : Array(Float64) readToEnd, rewind : Nil rewind, sampleFormat : SampleFormat sampleFormat, sampleRate : UInt32 sampleRate, stereo? : Bool stereo?, toEnd : Nil toEnd, withExcursion(newSamplePos : Int32, &) withExcursion, write(value : Float64) : self
write(samples : Array(Float64)) : self write, writeSample(value : Sample) : self writeSample, writeSamples(samples : SampleData) : self writeSamples
Constructor methods inherited from class RemiAudio::Formats::AudioFile
open(io : IO) : AudioFileopen(filename : Path | String) : AudioFile open
Class methods inherited from class RemiAudio::Formats::AudioFile
open(io : IO, &) : Nilopen(filename : Path | String, &) : Nil open, test(filename : Path | String) : Type | Nil test
Constructor Detail
Creates a new WavFile
that that is backed by io and returns the new
instance. Skeleton RIFF file data is immediately written into io.
Creates a new WavFile
that is backed by a new file on disk.
This always opens the file with the mode "w+b"
(i.e. existing files are
overwritten/truncated). Skeleton RIFF file data is immediately written
into the file.
Creates a new WavFile
that is backed by a fresh ::IO::Memory
.
Creates a new WavFile
by reading the existing RIFF WAVE data from io.
Samples will be streamed from io as needed.
Creates a new WavFile
by reading the existing RIFF WAVE data from the
given file. The file is always opened with the mode "r+b"
. Samples
will be streamed from the file as needed.
Class Method Detail
Creates a new WavFile
that that is backed by io and yields the new
instance to the block. Skeleton RIFF file data is immediately written
into io. The WavFile
instance will be flushed and closed once the
block exits.
Creates a new WavFile
that is backed by a new file on disk, then yields
it to the block. This automatically closes the AuFile
and the
underlying file before the block returns.
This always opens the file with the mode "w+b"
(i.e. existing files are
overwritten/truncated). Skeleton RIFF file data is immediately written
into the file.
Creates a new WavFile
by reading the existing RIFF WAVE data from io,
then yields it to the block. Samples will be streamed from io as
needed. This will NOT automatically close the WavFile
before
returning in case you have passed an io that cannot does not support
writing.
Creates a new WavFile
by reading the existing RIFF WAVE data from the
file, then yields it to the block. The file is always opened with the
mode "r+b"
. Samples will be streamed from io as needed. This
will automatically close the WavFile
and underlying ::IO
before
returning.
Instance Method Detail
Writes the current state of this file to dest. This will automatically
call #flush
before writing.