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.cr

Constructors

Instance Method Summary

Instance methods inherited from class RemiAudio::Drivers::AudioDevice

<<(buf : Array(Float32) | Slice(Float32)) : 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

Constructor Detail

def self.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. 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.


[View source]

Instance Method Detail

def ditherer : RemiAudio::DSP::Ditherer | Nil #

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.


[View source]
def ditherer=(ditherer : RemiAudio::DSP::Ditherer | Nil) #

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.


[View source]
def host : String #

The remote hostname.


[View source]
def noiseShaping=(noiseShaping : Bool) #

Whether or not to use noise shaping when using a #ditherer.


[View source]
def noiseShaping? : Bool #

Whether or not to use noise shaping when using a #ditherer.


[View source]
def outFormat : RemiAudio::SampleFormat #

The format that audio will be converted to before transmission over the TCP connection.


[View source]
def port : UInt16 #

The remote port.


[View source]
def start : Nil #

Opens the audio stream. This must be called before #writeBuffer is called.


[View source]
def stop : Nil #

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.


[View source]
def writeBuffer(buf : Array(Float32) | Slice(Float32)) : Nil #

:inherit:


[View source]