Xalsa v0.1.0 Xalsa View Source

Elixir ALSA connector. The Xalsa module implements the API. The client may send any number of frames as a binary array of 32 bit floats and may optionally receive back a notification in form of a :ready4more message 5-10 ms before all frames are consumed by the ALSA driver.

The :xalsa application needs to be started before calling the API. Also check the config/config.exs file on how to configure PCM devices for xalsa.

Link to this section Summary

Types

The sample rate is set in the application environment (config file for the application).

Functions

Reset the max prepare time gauges to 0

Convert a list of (Erlang) floats to a binary of 32 bit (C) floats

Flush any :ready4more messages from the xalsa server in input queue. Returns true if there were any.

The maximum buffer prepare time in µs, for all started pcm cards, since application start or last reset.

Total number of channels for all PCM devices together.

Lists the PCM names and their number of channels respectively.

Return the number of frames that the ALSA driver consumes per callback cycle.

The sample rate, number of frames per second

Send frames in a binary array of frame:32/float-native. If the notify flag is true a :ready4more message will be sent to the process in the from argument when the process frames are due to be consumed within 5-10 ms. This so that the process may synthesize/produce more frames.

The client will wait until :ready4more notification is sent from xalsa server.

Link to this section Types

Link to this type

rates() View Source
rates() :: 44100 | 48000 | 96000 | 192_000

The sample rate is set in the application environment (config file for the application).

Link to this section Functions

Link to this function

clear_max_mix_time() View Source
clear_max_mix_time() :: :ok

Reset the max prepare time gauges to 0

Link to this function

float_list_to_binary(fl) View Source
float_list_to_binary([float()]) :: binary()

Convert a list of (Erlang) floats to a binary of 32 bit (C) floats

Link to this function

flush_ready4more() View Source
flush_ready4more() :: boolean()

Flush any :ready4more messages from the xalsa server in input queue. Returns true if there were any.

Link to this function

max_mix_time() View Source
max_mix_time() :: [pos_integer()]

The maximum buffer prepare time in µs, for all started pcm cards, since application start or last reset.

Examples

iex> Xalsa.max_mix_time()
[254]
Link to this function

no_of_channels() View Source
no_of_channels() :: pos_integer()

Total number of channels for all PCM devices together.

Lists the PCM names and their number of channels respectively.

Example

iex> Xalsa.pcms()
["plughw:1,0": 2]
Link to this function

period_size() View Source
period_size() :: pos_integer()

Return the number of frames that the ALSA driver consumes per callback cycle.

The sample rate, number of frames per second

Link to this function

send_frames(frames, channel, notify \\ false, from \\ self()) View Source
send_frames(
  frames :: binary(),
  channel :: pos_integer(),
  notify :: boolean(),
  from :: pid()
) :: :ok

Send frames in a binary array of frame:32/float-native. If the notify flag is true a :ready4more message will be sent to the process in the from argument when the process frames are due to be consumed within 5-10 ms. This so that the process may synthesize/produce more frames.

Link to this function

wait_ready4more() View Source
wait_ready4more() :: :ok

The client will wait until :ready4more notification is sent from xalsa server.