class RemiAudio::Formats::AuFile

Overview

A virtual representation of an Au file (.au/.snd).

Au files originated from Sun and store data in liner PCM, IEEE Float, µLaw, or ALaw format. Their data is stored in big endian format.

The official specification supports more encodings, some of which are specific to certain platforms. This library does not support these. See AuEncoding for a list of supported encodings.

Defined in:

remiaudio/formats/au.cr

Constructors

Class Method Summary

Instance Method Summary

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) : Float64
read(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) : AudioFile
open(filename : Path | String) : AudioFile
open

Class methods inherited from class RemiAudio::Formats::AudioFile

open(io : IO, &) : Nil
open(filename : Path | String, &) : Nil
open
, test(filename : Path | String) : Type | Nil test

Constructor Detail

def self.create(io : IO, *, sampleRate : Int = 44100, channels : Int = 2, encoding : AuEncoding = AuEncoding::Lpcm16bit, note : String | Nil = nil) : AuFile #

Creates a new AuFile that that is backed by io and returns the new instance. A skeleton Au header data is immediately written into io.


[View source]
def self.create(io : IO, *, sampleRate : Int = 44100, channels : Int = 2, encoding : AuEncoding = AuEncoding::Lpcm16bit, note : String | Nil = nil, &) : AuFile #

Creates a new AuFile that that is backed by io and yields the new instance to the block. A skeleton Au header data is immediately written into io. The AuFile instance will be flushed and closed once the block exits.


[View source]
def self.create(filename : Path | String, *, sampleRate : Int = 44100, channels : Int = 2, encoding : AuEncoding = AuEncoding::Lpcm16bit, note : String | Nil = nil) : AuFile #

Creates a new AuFile 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). A skeleton Au header data is immediately written into the file.


[View source]
def self.new(io : IO, *, sampleRate : UInt32 = 44100_u32, channels : UInt32 = 2_u32, encoding : AuEncoding = AuEncoding::Lpcm16bit, note : String | Nil = nil) #

Creates a new, blank AuFile that is backed by the given ::IO. This will immediately write a skeleton Au header into io.


[View source]
def self.new(*, sampleRate : UInt32 = 44100_u32, channels : UInt32 = 2_u32, encoding : AuEncoding = AuEncoding::Lpcm16bit, note : String | Nil = nil) #

Creates a new, blank AuFile that is backed by a fresh ::IO::Memory. This will immediately write a skeleton Au header into #io


[View source]
def self.open(io : IO) : AuFile #

Creates a new AuFile by reading the existing Au data from io. Samples will be streamed from io as needed.


[View source]
def self.open(filename : Path | String) : AuFile #

Creates a new AuFile by reading the existing Au data from the given file. The file is always opened with the mode "r+b". Samples will be streamed from the file as needed.


[View source]

Class Method Detail

def self.create(filename : Path | String, *, sampleRate : Int = 44100, channels : Int = 2, encoding : AuEncoding = AuEncoding::Lpcm16bit, note : String | Nil = nil, &) #

Creates a new AuFile 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). A skeleton Au header data is immediately written into the file.


[View source]
def self.open(io : IO, &) #

Creates a new AuFile by reading the existing Au data from io, then yields it to the block. Samples will be streamed from io as needed. This will NOT automatically close the AuFile before returning in case you have passed an io that cannot does not support writing.


[View source]
def self.open(filename : Path | String, &) #

Creates a new AuFile by reading the existing Au 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 AuFile and underlying ::IO before returning.


[View source]

Instance Method Detail

def copyTo(dest : IO) : Nil #
Description copied from class RemiAudio::Formats::AudioFile

Writes the current state of this file to dest. This will automatically call #flush before writing.


[View source]
def encoding : AuEncoding #

The AuEncoding that the samples in this instance uses.


[View source]
def flush : Nil #

:inherited:


[View source]
def note : String | Nil #

The annotation string for this instance, or nil if there is none.


[View source]
def read(dest : Array(Float64)) : Int32 #

:inherited:


[View source]
def readSamplesToEnd : SampleData #

:inherited:


[View source]
def sampleFormat : SampleFormat #

:inherited:


[View source]