class RemiAudio::Drivers::Tcp::TcpDevice
Overview
The TcpDevice
allows for raw audio to be sent over a TCP connection.
Audio input is always expected to be 32-bit floating point, but a
TcpDevice
can be configured to convert this to other formats before
transmitting the audio over the connection. This can optionally be done
with a RemiAudio::DSP::Ditherer
for higher quality.
Defined in:
remiaudio/drivers/tcp.crConstructors
-
.new(inSampleRate : Int, outFormat : RemiAudio::SampleFormat, inChannels : Int, *, host : String, port : UInt16)
Creates a new
TcpDevice
instance that will send audio to the given host and port.
Instance Method Summary
-
#bufferSize=(value : Int) : Nil
Sets the buffer size.
-
#ditherer : RemiAudio::DSP::Ditherer | Nil
When non-nil, then dithering will be used to convert the audio to the chosen
#outFormat
before transmission. -
#ditherer=(ditherer : RemiAudio::DSP::Ditherer | Nil)
When non-nil, then dithering will be used to convert the audio to the chosen
#outFormat
before transmission. -
#host : String
The remote hostname.
-
#noiseShaping=(noiseShaping : Bool)
Whether or not to use noise shaping when using a
#ditherer
. -
#noiseShaping? : Bool
Whether or not to use noise shaping when using a
#ditherer
. -
#outFormat : RemiAudio::SampleFormat
The format that audio will be converted to before transmission over the TCP connection.
-
#port : UInt16
The remote port.
-
#start : Nil
Opens the audio stream.
-
#stop : Nil
Closes the audio stream and frees resources.
-
#writeBuffer(buf : Array(Float32) | Slice(Float32)) : Nil
:inherit:
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 TcpDevice
instance that will send audio to the given host
and port. The *outFormat` parameter is used to determine what format the
audio is converted to before being transmitted over the connection; the
input format is always 32-bit floating point.
The inSampleRate and *inChannelparameters are stored in
#sampleRateand
#channels`, respectively, and are just for informational purposes.
They are otherwise unused by this class.
Instance Method Detail
Sets the buffer size. This dictates what size of array you must pass into
#writeBuffer
. This is per-channel, so if this is 2048 and there are two
channels, then you need an array of 4096 elements for a buffer.
This MUST NOT change after the driver has been started, and you MUST
ALWAYS pass the correct buffer size to #writeBuffer
. Any attempt to
change this after starting the device will raise an AudioDeviceError
.
When non-nil, then dithering will be used to convert the audio to the
chosen #outFormat
before transmission. If this is nil
, then no
dithering is performaned during the conversion. If the output format is
already RemiAudio::SampleFormat:F32
, then this does nothing.
When non-nil, then dithering will be used to convert the audio to the
chosen #outFormat
before transmission. If this is nil
, then no
dithering is performaned during the conversion. If the output format is
already RemiAudio::SampleFormat:F32
, then this does nothing.
Whether or not to use noise shaping when using a #ditherer
.
The format that audio will be converted to before transmission over the TCP connection.
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.