abstract class RemiAudio::Formats::AudioFile
- RemiAudio::Formats::AudioFile
- Reference
- Object
Overview
Base class for all PCM- and IEEE Float-based audio file formats.
Direct Known Subclasses
Defined in:
remiaudio/formats/audiofile.crConstructors
Class Method Summary
- .open(io : IO, &) : Nil
- .open(filename : Path | String, &) : Nil
- .test(filename : Path | String) : Type | Nil
Instance Method Summary
-
#<<(sample : Float64) : self
Same as
#write. -
#<<(sample : Float32) : self
Same as
#write. -
#bitDepth : UInt8
The bit depth of this instance.
-
#channels : UInt32
The number of channels this instance has.
-
#close : Nil
Flushes the underlying
IOthen closes it. -
#copyTo(dest : IO) : Nil
Writes the current state of this file to dest.
-
#each(& : Float64 -> ) : Nil
Loops over all of the samples within this instance, yielding each one to the block as a
::Float64sample value. -
#eachF32(& : Float32 -> ) : Nil
Loops over all of the samples within this instance, yielding each one to the block as a
::Float32sample value. -
#eachSample(& : Sample -> ) : Nil
Loops over all of the samples within this instance, yielding each one to the block as a
RemiAudio::Samplevalue. -
#flush : Nil
Flushes the underlying
IOand updates any header fields. -
#io : IO
The underlying IO.
-
#mono? : Bool
Returns
trueif this is a monaural audio file, orfalseotherwise. -
#numSamples : UInt64
The current number of samples.
-
#pos : UInt64
Returns the current sample position.
-
#pos=(value : Int) : Nil
Sets the current sample position.
-
#read(pos : Int) : Float64
Reads a single sample from an arbitrary point in the file and returns it as a
::Float64sample value. -
#read(dest : Array(Float64)) : Int32
Reads up to
dest.sizesamples as::Float64sample values into dest. -
#read(dest : Array(Float32)) : Int32
Reads up to
dest.sizesamples as::Float32sample values into dest. -
#read : Float64
Reads a single sample and returns it as a
::Float64sample value. -
#read? : Float64 | Nil
Attempts to read a single sample, returning it as a
::Float64sample value on success, ornilif no more samples can be read. -
#readF32 : Float32
Reads a single sample and returns it as a
::Float32sample value. -
#readF32? : Float32 | Nil
Attempts to read a single sample, returning it as a
::Float32sample value on success, ornilif no more samples can be read. -
#readSample(pos : Int) : Sample
Reads a single sample from an arbitrary point in the file.
-
#readSample : Sample
Reads a single sample and returns it as a
RemiAudio::Samplesample value. -
#readSample? : Sample | Nil
Attempts to read a single sample, returning it as a
RemiAudio::Samplesample value on success, ornilif no more samples can be read. -
#readSamples(dest : SampleData) : Int32
Reads up to
dest.sizesamples asRemiAudio::Samplevalues into dest. -
#readSamplesToEnd : SampleData
Reads all remaining samples, returning them as
RemiAudio::SampleData. -
#readToEnd : Array(Float64)
Reads all remaining samples, returning them as
::Float64sample values. -
#readToEndF32 : Array(Float32)
Reads all remaining samples, returning them as
::Float32sample values. -
#rewind : Nil
Rewinds the internal read cursor to the beginning of the sample data.
-
#sampleFormat : SampleFormat
Returns a
RemiAudio::SampleFormatappropriate for this file. -
#sampleRate : UInt32
The sample rate of this instance.
-
#stereo? : Bool
Returns
trueif this is a stereo audio file, orfalseotherwise. -
#toEnd : Nil
Seeks to the end of the samples.
-
#withExcursion(newSamplePos : Int32, &)
Temporary seeks to the given sample number, yields the block, then returns to the previous sample number.
-
#write(value : Float64) : self
Writes a single sample, then returns
self. -
#write(value : Float32) : self
Writes a single sample, then returns
self. -
#write(samples : Array(Float64)) : self
Writes samples, then returns
self. -
#write(samples : Array(Float32)) : self
Writes samples, then returns
self. -
#writeSample(value : Sample) : self
Writes a single sample, then returns
self. -
#writeSamples(samples : SampleData) : self
Writes samples, then returns
self.
Constructor Detail
Class Method Detail
Instance Method Detail
Writes the current state of this file to dest. This will automatically
call #flush before writing.
Loops over all of the samples within this instance, yielding each one to
the block as a ::Float64 sample value.
This will call #withExcursion to set the position to the first sample,
so once the block finishes, the internal read cursor will be back at its
original position.
Loops over all of the samples within this instance, yielding each one to
the block as a ::Float32 sample value.
This will call #withExcursion to set the position to the first sample,
so once the block finishes, the internal read cursor will be back at its
original position.
Loops over all of the samples within this instance, yielding each one to
the block as a RemiAudio::Sample value.
This will call #withExcursion to set the position to the first sample,
so once the block finishes, the internal read cursor will be back at its
original position.
Returns the current sample position. This is different than calling
io.pos in that this is based on samples, not necessarily bytes.
Sets the current sample position. This is different than calling io.pos = value in that this is based on samples, not necessarily bytes.
This will raise an ::ArgumentError if value is less than zero.
Reads a single sample from an arbitrary point in the file and returns it
as a ::Float64 sample value. This does not change the current read
position, thus allowing random access reading.
Reads up to dest.size samples as ::Float64 sample values into dest.
The actual number of samples read is then returned.
Reads up to dest.size samples as ::Float32 sample values into dest.
The actual number of samples read is then returned.
Reads a single sample and returns it as a ::Float64 sample value. If no
more samples are available, this raises an ::IO::EOFError.
Attempts to read a single sample, returning it as a ::Float64 sample
value on success, or nil if no more samples can be read.
Reads a single sample and returns it as a ::Float32 sample value. If no
more samples are available, this raises an ::IO::EOFError.
Attempts to read a single sample, returning it as a ::Float32 sample
value on success, or nil if no more samples can be read.
Reads a single sample from an arbitrary point in the file. This does not change the current read position, thus allowing random access reading.
Reads a single sample and returns it as a RemiAudio::Sample sample
value. If no more samples are available, this raises an ::IO::EOFError.
Attempts to read a single sample, returning it as a RemiAudio::Sample
sample value on success, or nil if no more samples can be read.
Reads up to dest.size samples as RemiAudio::Sample values into dest.
The actual number of samples read is then returned.
Reads all remaining samples, returning them as RemiAudio::SampleData.
Reads all remaining samples, returning them as ::Float64 sample values.
Reads all remaining samples, returning them as ::Float32 sample values.
Returns a RemiAudio::SampleFormat appropriate for this file.
Seeks to the end of the samples. Writing a sample after this will add a new sample into this instance.
Temporary seeks to the given sample number, yields the block, then returns to the previous sample number. This returns the final value in the block.