class RemiAudio::Drivers::PortAudio::PortDevice

Overview

The PortDevice class is used to playback audio using PortAudio.

PortAudio 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/portaudio.cr

Constructors

Instance Method Summary

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

def self.new(newSampleRate : Int, newBitDepth : Int, newChannels : Int) #

Creates a new PortDevice instance.

PortAudio 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 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 #

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]