class RemiAudio::Drivers::PulseAudio::PulseDevice

Overview

The PulseDevice class is used to playback audio using PulseAudio.

PulseAudio supports the output of Float32 audio natively, so the #bitDepth field is ignored by this class and is always set to 32.

Defined in:

remiaudio/drivers/pulse-simple.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(newSampleRate : Int, newBitDepth : Int, newChannels : Int) #

Creates a new PulseDevice instance.

PulseAudio supports the output of Float32 audio natively, so the #bitDepth field is ignored by this class and is always set to 32.


[View source]

Instance Method Detail

def programName : String #

The informational name of the program. This may be used by software such as volume controls to show the name of the program the stream belongs to.

This cannot be changed once #start is called.


[View source]
def programName=(value : String) : Nil #

Sets the informational name of the program. This may be used by software such as volume controls to show the name of the program the stream belongs to.

This cannot be changed once #start is called.


[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 streamName : String #

The informational name of the audio stream. This may be used by software such as volume controls to show the name of the audio stream.

This cannot be changed once #start is called.


[View source]
def streamName=(value : String) : Nil #

Sets the informational name of the audio stream. This may be used by software such as volume controls to show the name of the audio stream.

This cannot be changed once #start is called.


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

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.


[View source]