class RemiAudio::Drivers::Ao::AoDevice
Overview
The AoDevice
class is used to playback audio using libao.
As libao does not support output to Float32 directly, this class will convert the audio to the requested bit rate on-the-fly. It does this without any dithering. Additionally, only 8-bit, 16-bit, and 24-bit output is supported by this device.
Defined in:
remiaudio/drivers/ao.crConstructors
-
.new(newSampleRate : Int, newBitDepth : Int, newChannels : Int)
Creates a new
AoDevice
instance.
Class Method Summary
-
.getDriverID(name : String) : Int32 | Nil
Attempts to lookup the numeric driver ID for a given driver.
Instance Method Summary
-
#author : String
The author of the driver.
-
#availableOptions : Array(String)
The possible options for thsi driver.
-
#comment : String
A comment about the driver.
-
#driverID : Int32
The driver ID that will be requested when
#start
is called. -
#driverID=(id : Int32) : Nil
Sets the numeric driver ID that will be used when
#start
is called. -
#matrix : String
The layout of the channels.
-
#matrix=(value : String) : Nil
Sets the channel layout.
-
#name : String
The short name of the driver.
-
#preferredByteFormat : Format
The preferred byte ordering (endianness) for samples.
-
#priority : Int32
A positive integer ranking how likely it is for this driver to be the default.
-
#shortName : String
The short name of the driver.
-
#start : Nil
Opens the audio stream.
-
#stop : Nil
Closes the audio stream and frees resources.
-
#type : DriverType
The output type of the underlying libao driver.
-
#writeBuffer(buf : Array(Float32) | Slice(Float32)) : Nil
Plays back the audio in buf by sending it to the underlying backend.
-
#writeBuffer(buf : Array(Int16) | Slice(Int16)) : Nil
Plays back the audio in buf by sending it to the underlying backend.
Instance methods inherited from class RemiAudio::Drivers::AudioDevice
<<(buf : Array(Float32) | Slice(Float32)) : Nil<<(buf : Array(Int8) | Slice(Int8)) : Nil
<<(buf : Array(Int16) | Slice(Int16)) : Nil
<<(buf : Array(Int32) | Slice(Int32)) : Nil
<<(buf : Array(UInt8) | Slice(UInt8)) : Nil <<, bitDepth : UInt8 bitDepth, bufferSize : UInt32 bufferSize, bufferSize=(value : Int) : Nil bufferSize=, channels : UInt8 channels, expectedBufferSize : UInt32 expectedBufferSize, sampleRate : UInt32 sampleRate, start : Nil start, started? : Bool started?, stop : Nil stop, writeBuffer(buf : Array(Float32) | Slice(Float32)) : Nil
writeBuffer(buf : Array(Int8) | Slice(Int8)) : Nil
writeBuffer(buf : Array(Int16) | Slice(Int16)) : Nil
writeBuffer(buf : Array(Int32) | Slice(Int32)) : Nil
writeBuffer(buf : Array(UInt8) | Slice(UInt8)) : Nil writeBuffer, writeBufferI24(buf : Array(Int32) | Slice(Int32)) : Nil writeBufferI24
Constructor Detail
Creates a new AoDevice
instance.
Note that only 8-bit, 16-bit, and 24-bit samples are supported, so newBitDepth must be one of these values.
Class Method Detail
Attempts to lookup the numeric driver ID for a given driver. name should be the driver's short name. If the driver is not known, this returns nil.
You can read more about libao drivers here.
Instance Method Detail
The possible options for thsi driver. This isn't used directly by
RemiAudio at the moment, and is purely informational. This is
populated after calling #start
.
The driver ID that will be requested when #start
is called. This
cannot be changed once #start
has been called. You can use
AoDevice.getDriverId
to get the numeric ID for a driver.
You can read more about libao drivers
here.
Sets the numeric driver ID that will be used when #start
is called.
This cannot be changed after #start
is called.
You can read more about libao drivers
here.
The layout of the channels. This cannot be changed once #start
has
been called.
Sets the channel layout. This cannot be changed once #start
has
been called.
Some common examples of channel orderings:
"L,R"
: Stereo ordering in virtually all file formats"L,R,BL,BR"
: Quadraphonic ordering for most file formats"L,R,C,LFE,BR,BL"
: channel order of a 5.1 WAV or FLAC file"L,R,C,LFE,BR,BL,SL,SR"
: channel order of a 7.1 WAV or FLAC file"L,C,R,BR,BL,LFE"
: channel order of a six channel (5.1) Vorbis I file"L,C,R,BR,BL,SL,SR,LFE"
: channel order of an eight channel (7.1) Vorbis file"L,CL,C,R,RC,BC"
: channel order of a six channel AIFF[-C] file
The preferred byte ordering (endianness) for samples. Ideally,
samples sent to #writeBuffer
will be in the same format, but they
don't have to be. Using samples of a different endianness may result
in slightly higher CPU and memory usage by libao. This is populated
after calling #start
.
A positive integer ranking how likely it is for this driver to be the default.
Closes the audio stream and frees resources. This must be called when you are finished using the instance to ensure that the resources are properly freed and the audio device is properly closed.
Plays back the audio in buf by sending it to the underlying backend.
You MUST ALWAYS pass the correct buffer size to #writeBuffer
, as defined
by the value of #bufferSize
multiplied by the number of #channels
.
Note: if -Dremiaudio_wd40
is used at compile time, then the size of
buf is not checked for a valid size, and it is not checked if the
device has been started.
Plays back the audio in buf by sending it to the underlying backend.
You MUST ALWAYS pass the correct buffer size to #writeBuffer
, as defined
by the value of #bufferSize
multiplied by the number of #channels
.
Note: if -Dremiaudio_wd40
is used at compile time, then the size of
buf is not checked for a valid size, and it is not checked if the
device has been started.