jackclient

Client that dumps samples directly to the jack client with the jack package.

Data:

SERVER

After initializing, JackClient will register itself with this variable.

FS

Sampling rate of the active server

BLOCKSIZE

Blocksize, or the amount of samples processed by jack per each JackClient.process() call.

QUEUE

Queue to be loaded with frames of BLOCKSIZE audio.

PLAY

Event used to trigger loading samples from QUEUE, ie.

STOP

Event that is triggered on the end of buffered audio.

Q_LOCK

Lock that enforces a single writer to the QUEUE at a time.

CONTINUOUS

Event that (when set) signals the sound server should play some sound continuously rather than remain silent by default (eg.

CONTINUOUS_QUEUE

Queue that

CONTINUOUS_LOOP

Event flag that is set when frames dropped into the CONTINUOUS_QUEUE should be looped (eg.

Classes:

JackClient([name])

Client that dumps frames of audio directly into a running jackd client.

SERVER = None

After initializing, JackClient will register itself with this variable.

Type

JackClient

FS = None

Sampling rate of the active server

Type

int

BLOCKSIZE = None

Blocksize, or the amount of samples processed by jack per each JackClient.process() call.

Type

int

QUEUE = None

Queue to be loaded with frames of BLOCKSIZE audio.

Type

multiprocessing.Queue

PLAY = None

Event used to trigger loading samples from QUEUE, ie. playing.

Type

multiprocessing.Event

STOP = None

Event that is triggered on the end of buffered audio.

Note

NOT an event used to stop audio.

Type

multiprocessing.Event

Q_LOCK = None

Lock that enforces a single writer to the QUEUE at a time.

Type

multiprocessing.Lock

CONTINUOUS = None

Event that (when set) signals the sound server should play some sound continuously rather than remain silent by default (eg. play a background sound).

Type

multiprocessing.Event

CONTINUOUS_QUEUE = None

Queue that

Type

multiprocessing.Queue

CONTINUOUS_LOOP = None

Event flag that is set when frames dropped into the CONTINUOUS_QUEUE should be looped (eg. in the case of stationary background noise), otherwise they are played and then discarded (ie. the sound is continuously generating and submitting samples)

Type

multiprocessing.Event

class JackClient(name='jack_client')[source]

Bases: multiprocessing.context.Process

Client that dumps frames of audio directly into a running jackd client.

When first initialized, sets module level variables above.

Variables
  • name (str) – name of client, default “jack_client”

  • q (Queue) – Queue that stores buffered frames of audio

  • q_lock (Lock) – Lock that manages access to the Queue

  • play_evt (multiprocessing.Event) – Event used to trigger loading samples from QUEUE, ie. playing.

  • stop_evt (multiprocessing.Event) – Event that is triggered on the end of buffered audio.

  • quit_evt (multiprocessing.Event) – Event that causes the process to be terminated.

  • client (jack.Client) – Client to interface with jackd

  • blocksize (int) – The blocksize - ie. samples processed per JackClient.process() call.

  • fs (int) – Sampling rate of client

  • zero_arr (numpy.ndarray) – cached array of zeroes used to fill jackd pipe when not processing audio.

  • continuous_cycle (itertools.cycle) – cycle of frames used for continuous sounds

Parameters

name

Methods:

boot_server()

Called by JackClient.run() to boot the server upon starting the process.

run()

Start the process, boot the server, start processing frames and wait for the end.

quit()

Set the JackClient.quit_evt

process(frames)

Process a frame of audio.

boot_server()[source]

Called by JackClient.run() to boot the server upon starting the process.

Activates the client and connects it to the number of outports determined by prefs.NCHANNELS

jack.Client s can’t be kept alive, so this must be called just before processing sample starts.

run()[source]

Start the process, boot the server, start processing frames and wait for the end.

quit()[source]

Set the JackClient.quit_evt

process(frames)[source]

Process a frame of audio.

If the JackClient.play_evt is not set, fill port buffers with zeroes.

Otherwise, pull frames of audio from the JackClient.q until it’s empty.

When it’s empty, set the JackClient.stop_evt and clear the JackClient.play_evt .

Warning

Handling multiple outputs is a little screwy right now. v0.2 effectively only supports one channel output.

Parameters

frames – number of frames (samples) to be processed. unused. passed by jack client