View Source ExJack.Server (ex_jack v0.1.0)
A GenServer module that interfaces with JACK audio API I/O.
There are two methods for outputting sound to JACK:
- Calling
send_frames/1
- Setting an output function using
set_output_func/1
, which JACK calls every time it wants frames.
At the moment, there is only one method of retrieving input data, which is to set
an input callback using set_input_func/1
.
Latency will obviously vary and if you have a busy machine, expect xruns. xruns, which is shorthand for overruns and underruns, occur when you either send too many frames or not enough frames. If the CPU is busy doing some other work and neglects to send frames to the soundcard, the soundcard buffer runs out of frames to play. An underrun will then occur. You could send too many frames to the soundcard. If you send more than its buffers can hold, the data will be lost. This is an overrun.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Sends a list of frames for JACK to play during its next cycle.
Set the callback function that will receive input data from JACK each cycle.
Set the callback function that JACK will call when it requests more frames.
Start the server.
Link to this section Types
@type frames_t() :: [float()]
@type t() :: %ExJack.Server{ current_frame: pos_integer(), handler: any(), input_func: input_func_t(), output_func: output_func_t(), shutdown_handler: any() }
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec send_frames(frames_t()) :: :ok
Sends a list of frames for JACK to play during its next cycle.
@spec set_input_func(input_func_t()) :: :ok
Set the callback function that will receive input data from JACK each cycle.
The output of the function is currently not used for anything.
@spec set_output_func(output_func_t()) :: :ok
Set the callback function that JACK will call when it requests more frames.
@spec start_link(options_t()) :: GenServer.server()
Start the server.
JACK NIF will start a thread that runs the JACK client.
It will auto-connect to two standard channels which you can modify through JACK.
parameters
Parameters
- name: Used to name the JACK node (suffixed with
:in
and:out
)
e.g. If you pass %{name: "HelloWorld"}
, you can interface with this
connection within JACK through HelloWorld:in
and HelloWorld:out
.