PKAudio 0.3 review

Download
by rbytes.net on

PKAudio library is a high performance signal/audio processing library that allows stream objects to be created and mixed without inte

License: GPL (GNU General Public License)
File size: 0K
Developer: Patrick Stinson
0 stars award from rbytes.net

PKAudio library is a high performance signal/audio processing library that allows stream objects to be created and mixed without interrupting the main stream of audio.

The core library runs in pkaudiod, an executable that runs with realtime or high priority, and a single client can communicate with it via a tcp socket.

A python client is provided, and can be used to write clients in other languages if necessary. The API is small and the protocol is simple.

Installation:

There are two parts to pkaudio: the pkaudiod daemon executable and the python module to communicate with it. The daemon is written in C++ and is configured and compiled like and other make program. To install everything, all you have to do is use the install.py python script like any other extension module. Here are the simplest install instructions:

cd < source dir >
python install.py [-h]

Usage:

If Jack support is compiled into pkaudio, make sure you start the jack daemon before running pkaudiod. If you don't, there will be no audio output. You can start the jack server with at least something like this (-r 44100 is required):

jackd -d alsa -r 44100

The pkaudiod executable is installed in your path and can be executed explicitly from the command line, or implicitly with the python module:

pkaudiod --realtime

The "--realtime" option tells pkaudiod to run with realtime priority, or the highest priority possible if realtime shceduling is not available in the kernel. Most systems will only allow processes to be scheduled with realtime priority if they are executed by the superuser "root". If you want to run the daemon with realtime priority as a normal user, you have to set the owner of the file to 'root', and the suid bit to on, like this (this is automatically done in the install.py script):

su
chown root `which pkaudiod`
chmod +s `which pkaudiod`

The daemon will tell you if it is running with realtime priority, or if it is running with increased priority.

Using the Python Module:

A good way to learn how to use the python module is to look at test_unittest.py. But, the following code will start the pkaudiod daemon as a child process and play a wav file:

import time
import pkaudio
pkaudio.connect(startserver=1)

sid = pkaudio.createModule('Sample',
'/home/ajole/wav/loops/Document 1.wav')
sample = pkaudio.getModuleInfo(sid)
mixer = pkaudio.getMainMixer(0)
pkaudio.getModuleInfo(mixer)
pkaudio.connectToMixer(mixer, sample['outs'][0])
pkaudio.setProperty(sid, 'playing', pkaudio.TRUE)
pkaudio.setProperty(sid, 'looping', pkaudio.TRUE)
time.sleep(100)

Fortunately, all of this can be accomplished with the higher-level PKAudio module:

import time
import PKAudio

PKAudio.start_server()
d = PKAudio.Driver()
s = PKAudio.Sample("/home/me/my.wav")
m = d.getMixer(0)
m.connect(s.outputPort())
s.play()
while not s.atEnd():
time.sleep(1)

PKAudio 0.3 keywords