cl out123
1.0.0Bindings to libout123, providing cross-platform audio output.
Table of Contents
About cl-out123
This is a bindings library to libout123 which allows easy cross-platform audio playback.
How To
Precompiled versions of the underlying library are included in this. If you want to build it manually however, refer to the mpg123 page.
Load the system through ASDF or Quicklisp:
(ql:quickload :cl-out123)
Create a new output object:
(defvar *out* (make-instance 'cl-out123:output))
This will initialise a standard output handler object for you, based on some hopefully sane defaults. We can now look at a list of possible drivers:
(cl-out123:drivers *out*)
If we're fine with the automatic default or now have a backend we know we want to use, we can connect to it:
(cl-out123:connect *out* :driver "pulse")
Now that we have a stable connection to the sound system, we can query it for possible output formats:
(cl-out123:formats *out* '(44100) 1 2)
Finally once we have figured out a proper format to use, or again are fine with the default, we can start playback to the device:
(cl-out123:start *out* :rate 44100 :channels 2 :encoding :int16)
Now buffered audio data that conforms to the format we picked can be sent to be played back using play
or play-directly
:
(cl-out123:play *out* #(...))
It will return you the amount of bytes it actually managed to play back. If need be, playback can also be pause
d, resume
d, and stop
ped. Currently buffered data can be drop
ped, or drain
ed too to allow you to synchronise things.
Once we're done, simply stop
the output object:
(cl-out123:stop *out*)
If for some reason you find yourself needing to change output format or device after having initialised your output already, you can reconfigure it using reinitialize-instance
. This will cause your current playback to end if it is currently running, but should otherwise phase over smoothly.
(reinitialize-instance *out* :driver "alsa")
There is no need to explicitly deallocate or clean up data. As soon as the output object is garbage collected, the cleanup will be handled for you automatically. If you would like to explicitly close the connection anyway:
(cl-out123:disconnect *out*)
And that's pretty much all there is to it. The heavy burden falls onto you to get the audio data ready in the proper format for it to be played back. The actual transfer process to the sound system should be easy with this library.
System Information
Definition Index
-
CL-OUT123-CFFI
- ORG.SHIRAKUMO.FRAF.OUT123.CFFI
No documentation provided.-
EXTERNAL SPECIAL-VARIABLE *STATIC*
Variable containing a pathname to the static directory.
-
EXTERNAL CLASS FMT
No documentation provided. -
EXTERNAL CLASS HANDLE
No documentation provided. -
EXTERNAL CONDITION ERROR
No documentation provided. -
EXTERNAL FUNCTION BUFFERED
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION CLOSE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION CONTINUE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION DEL
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION DRAIN
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION DRIVER-INFO
- HANDLE
- DRIVER
- DEVICE
- &REST
No documentation provided. -
EXTERNAL FUNCTION DRIVERS
- HANDLE
- NAMES
- DESCR
- &REST
No documentation provided. -
EXTERNAL FUNCTION DROP
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION ENC-BYNAME
- NAME
- &REST
No documentation provided. -
EXTERNAL FUNCTION ENC-LIST
- ENCLIST
- &REST
No documentation provided. -
EXTERNAL FUNCTION ENC-LONGNAME
- ENCODING
- &REST
No documentation provided. -
EXTERNAL FUNCTION ENC-NAME
- ENCODING
- &REST
No documentation provided. -
EXTERNAL FUNCTION ENCODINGS
- HANDLE
- RATE
- CHANNELS
- &REST
No documentation provided. -
EXTERNAL FUNCTION ENCSIZE
- ENCODING
- &REST
No documentation provided. -
EXTERNAL FUNCTION ERRCODE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION ERROR
- DATUM
- &REST
- ARGUMENTS
- &REST
Invoke the signal facility on a condition formed from DATUM and ARGUMENTS. If the condition is not handled, the debugger is invoked.
-
EXTERNAL FUNCTION FMT-CHANNELS
- POINTER-TO-FMT
- &REST
No documentation provided. -
EXTERNAL FUNCTION (SETF FMT-CHANNELS)
- VALUE
- POINTER-TO-FMT
- &REST
No documentation provided. -
EXTERNAL FUNCTION FMT-ENCODING
- POINTER-TO-FMT
- &REST
No documentation provided. -
EXTERNAL FUNCTION (SETF FMT-ENCODING)
- VALUE
- POINTER-TO-FMT
- &REST
No documentation provided. -
EXTERNAL FUNCTION FMT-RATE
- POINTER-TO-FMT
- &REST
No documentation provided. -
EXTERNAL FUNCTION (SETF FMT-RATE)
- VALUE
- POINTER-TO-FMT
- &REST
No documentation provided. -
EXTERNAL FUNCTION FORMATS
- HANDLE
- RATES
- RATECOUNT
- MINCHANNELS
- MAXCHANNELS
- FMTLIST
- &REST
No documentation provided. -
EXTERNAL FUNCTION GETFORMAT
- HANDLE
- RATE
- CHANNELS
- ENCODING
- FRAMESIZE
- &REST
No documentation provided. -
EXTERNAL FUNCTION GETPARAM
- HANDLE
- CODE
- RET-VALUE
- RET-FVALUE
- RET-SVALUE
- &REST
No documentation provided. -
EXTERNAL FUNCTION GETPARAM-FLOAT
- HANDLE
- CODE
- VALUE
- &REST
No documentation provided. -
EXTERNAL FUNCTION GETPARAM-INT
- HANDLE
- CODE
- VALUE
- &REST
No documentation provided. -
EXTERNAL FUNCTION GETPARAM-STRING
- HANDLE
- CODE
- VALUE
- &REST
No documentation provided. -
EXTERNAL FUNCTION NDRAIN
- HANDLE
- BYTES
- &REST
No documentation provided. -
EXTERNAL FUNCTION NEW
No documentation provided. -
EXTERNAL FUNCTION OPEN
- HANDLE
- DRIVER
- DEVICE
- &REST
No documentation provided. -
EXTERNAL FUNCTION PARAM
- HANDLE
- CODE
- VALUE
- FVALUE
- SVALUE
- &REST
No documentation provided. -
EXTERNAL FUNCTION PARAM-FLOAT
- HANDLE
- CODE
- VALUE
- &REST
No documentation provided. -
EXTERNAL FUNCTION PARAM-FROM
- HANDLE
- HANDLE-FROM
- &REST
No documentation provided. -
EXTERNAL FUNCTION PARAM-INT
- HANDLE
- CODE
- VALUE
- &REST
No documentation provided. -
EXTERNAL FUNCTION PARAM-STRING
- HANDLE
- CODE
- VALUE
- &REST
No documentation provided. -
EXTERNAL FUNCTION PAUSE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION PLAIN-STRERROR
- ERRCODE
- &REST
No documentation provided. -
EXTERNAL FUNCTION PLAY
- HANDLE
- BUFFER
- BYTES
- &REST
No documentation provided. -
EXTERNAL FUNCTION SET-BUFFER
- HANDLE
- BUFFER-BYTES
- &REST
No documentation provided. -
EXTERNAL FUNCTION START
- HANDLE
- RATE
- CHANNELS
- ENCODING
- &REST
No documentation provided. -
EXTERNAL FUNCTION STOP
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION STRERROR
- HANDLE
- &REST
No documentation provided. -
EXTERNAL OPTIMIZER ERROR
No documentation provided. -
EXTERNAL TRANSFORM ERROR
No documentation provided.
-
CL-OUT123
- ORG.SHIRAKUMO.FRAF.OUT123
No documentation provided.-
EXTERNAL CLASS OUTPUT
Class representing an output to a sound playback device. This holds all the necessary state and information in order to connect and play back audio data to a device. Some options can only be changed by closing and opening a new connection to the backend. In order to do this, you can use REINITIALIZE-INSTANCE. It will attempt to preserve state across reinitialisation, but pending sound data will be disposed off immediately as to not block. See HANDLE See PLAYING See CONNECTED See DRIVER See DEVICE See RATE See CHANNELS See ENCODING See OUTPUT-TO See PRELOAD See GAIN See DEVICE-BUFFER See NAME See OUTPUT-LOCK
-
EXTERNAL CONDITION ALREADY-CONNECTED
Condition signalled if an attempt is made to connect again while the output is still connected. See OUTPUT-ERROR
-
EXTERNAL CONDITION BUFFER-SET-FAILED
Condition signalled if the setting of the background buffer fails. See ERROR-STRING-ERROR See BYTES
-
EXTERNAL CONDITION CONNECTION-FAILED
Condition signalled if the connection of an output to its device fails. See ERROR-STRING-ERROR See DRIVER See DEVICE
-
EXTERNAL CONDITION CREATION-FAILURE
Condition signalled in the case the allocation of the output handler fails. See OUTPUT-ERROR
-
EXTERNAL CONDITION ERROR-STRING-ERROR
Error condition superclass for errors that have an error-string from the out123 library. See ERROR-STRING See OUTPUT-ERROR
-
EXTERNAL CONDITION FAILED-DRIVER-INFO
No documentation provided. -
EXTERNAL CONDITION FAILED-DRIVER-LISTING
Condition signalled if the listing of available drivers fails for some reason. See OUTPUT-ERROR
-
EXTERNAL CONDITION FAILED-FORMAT-LISTING
Condition signalled if the listing of available formats fails for some reason. See OUTPUT-ERROR
-
EXTERNAL CONDITION FAILED-PLAYBACK-FORMAT
No documentation provided. -
EXTERNAL CONDITION NOT-CONNECTED
Condition signalled if an operation is attempted that requires the output to be connected, but it isn't. See OUTPUT-ERROR
-
EXTERNAL CONDITION OUTPUT-ERROR
Error condition superclass for all errors related to this library. See OUTPUT
-
EXTERNAL CONDITION PLAYBACK-FAILED
Condition signalled if the playback of a buffer fails. See ERROR-STRING-ERROR See BYTES
-
EXTERNAL CONDITION START-FAILED
Condition signalled if starting the device fails. See ERROR-STRING-ERROR See RATE See CHANNELS See ENCODING
-
EXTERNAL FUNCTION BUFFERED
- OUTPUT
- &REST
Returns the number of bytes that currently reside in the internal buffer. This number changes constantly as audio is played back. This is setfable. Once set, a fork occurs to spawn a "thread" to process the buffer in in the background. See the <out123.h> file for more information. See OUTPUT
-
EXTERNAL FUNCTION (SETF BUFFERED)
- BYTES
- OUTPUT
- &REST
No documentation provided. -
EXTERNAL FUNCTION CONNECT
- OUTPUT
- &KEY
- DRIVER
- DEVICE
- &REST
Connects the output to the requested driver and device. The output must not be connected already. If the connection was successful, the output's DRIVER and DEVICE are updated to reflect the ones that were actually chosen by the backend. This might differ from what you requested. This function is safe to be called from multiple threads, as it will mutually exclude them through a lock. See OUTPUT See DRIVER See DEVICE See CONNECTED
-
EXTERNAL FUNCTION DEVICE-DEFAULT-NAME
- &OPTIONAL
- IDENT
- &REST
Attempts to return a somewhat sensible name to use for our application.
-
EXTERNAL FUNCTION DISCONNECT
- OUTPUT
- &REST
Disconnects the output from its driver and device. If the output is already disconnected, this does nothing. If there is still audio data to be played on the buffer, then this will block until it is finished. If you wish to abort immediately, This function is safe to be called from multiple threads, as it will mutually exclude them through a lock. call DROP first. See OUTPUT See DROP See CONNECTED
-
EXTERNAL FUNCTION DRAIN
- OUTPUT
- &REST
-
EXTERNAL FUNCTION DRIVER-INFO
- OUTPUT
- &REST
-
EXTERNAL FUNCTION DRIVERS
- OUTPUT
- &REST
Returns a list of drivers with their name and description. You can use this to determine the available drivers and pick a suitable backend based on that. See OUTPUT
-
EXTERNAL FUNCTION DROP
- OUTPUT
- &REST
Drops all remaining output from the internal buffers. This function is safe to be called from multiple threads, as it will mutually exclude them through a lock. See OUTPUT
-
EXTERNAL FUNCTION ENCODINGS
- OUTPUT
- RATE
- CHANNELS
- &REST
Returns a list of the possible encodings for the output rate and channel count you specified. The output must be connected and will be stopped if it is playing. See OTUPUT
-
EXTERNAL FUNCTION FORMATS
- OUTPUT
- RATES
- MIN-CHANNELS
- MAX-CHANNELS
- &REST
Returns a list of possible formats for the requested rates and channels. RATES should be a list of integers. The output must be connected and will be stopped if it is playing. Each item in the list is a plist with :RATE, :CHANNELS, and :ENCODINGS as keys.
-
EXTERNAL FUNCTION MAKE-OUTPUT
- DRIVER
- &REST
- ARGS
- &KEY
- &ALLOW-OTHER-KEYS
- &REST
No documentation provided. -
EXTERNAL FUNCTION NDRAIN
- OUTPUT
- BYTES
- &REST
Blocks until either all or bytes number of bytes have been played back. Implictly resumes playback if it is paused first and then pauses it again if there are no remaining bytes to be played back. This function is safe to be called from multiple threads, as it will mutually exclude them through a lock. See PLAYING See OUTPUT See DRAIN
-
EXTERNAL FUNCTION PAUSE
- OUTPUT
- &REST
-
EXTERNAL FUNCTION PLAY
- OUTPUT
- BYTES
- &OPTIONAL
- COUNT
- &REST
Send the octet-vector or array-pointer to out123 to be played back on the output. If you need low latency, then this is definitely not the function for you. The buffer is converted into a foreign byte array before being sent off. Returns the number of bytes that were actually played back. This function is safe to be called from multiple threads, as it will mutually exclude them through a lock. See PLAY-DIRECTLY See OUTPUT
-
EXTERNAL FUNCTION PLAY-DIRECTLY
- OUTPUT
- BUFFER
- BYTES
- &REST
Directly sends the given buffer to out123 to be played back on the output. BUFFER must be a pointer to a foreign byte array of at least BYTES size. Returns the number of bytes that were actually played back. This does not catch errors. If you need to check for errors, see CL-OUT123-CFFI:ERRCODE. This does not care for synchronisation or mutual exclusion. If you call this simultaneously from multiple threads, things /will/ crash and burn horribly. See CL-OUT123-CFFI:ERRCODE See HANDLE See OUTPUT
-
EXTERNAL FUNCTION PLAYBACK-FORMAT
- OUTPUT
- &REST
-
EXTERNAL FUNCTION RESUME
- OUTPUT
- &REST
-
EXTERNAL FUNCTION START
- OUTPUT
- &KEY
- RATE
- CHANNELS
- ENCODING
- &REST
Starts playback to the connected output. The output must be connected and must not have been started before. If the start was successful, the output's RATE, CHANNELS, ENCODING, and FRAMESIZE are updated to reflect the values that were actually chosen by the backend. This might differ from what you requested. This function is safe to be called from multiple threads, as it will mutually exclude them through a lock. See OUTPUT See RATE See CHANNELS See ENCODING See FRAMESIZE See PLAYING
-
EXTERNAL FUNCTION STOP
- OUTPUT
- &REST
-
EXTERNAL GENERIC-FUNCTION BYTES
- CONDITION
- &REST
No documentation provided. -
EXTERNAL GENERIC-FUNCTION CHANNELS
- CONDITION
- &REST
-
EXTERNAL GENERIC-FUNCTION CONNECTED
- OBJECT
- &REST
Returns T if the output is connected to a device.
-
EXTERNAL GENERIC-FUNCTION DEVICE
- CONDITION
- &REST
-
EXTERNAL GENERIC-FUNCTION DEVICE-BUFFER
- OBJECT
- &REST
Returns the number of seconds that the device buffer should hold. Can be set as an initarg on the output. Allowed values are: T for the default that the backend will choose for itself. REAL for the approximate amount of seconds of buffering. Should not be more than 0.5. See OUTPUT
-
EXTERNAL GENERIC-FUNCTION DRIVER
- CONDITION
- &REST
-
EXTERNAL GENERIC-FUNCTION ENCODING
- CONDITION
- &REST
-
EXTERNAL GENERIC-FUNCTION ERROR-STRING
- CONDITION
- &REST
Returns the error string from the out123 library for the error we encountered. See ERROR-STRING-ERROR
-
EXTERNAL GENERIC-FUNCTION GAIN
- OBJECT
- &REST
Returns an integer representing the output device gain. This is driver-specific. Can be set as an initarg on the output. See OUTPUT
-
EXTERNAL GENERIC-FUNCTION HANDLE
- OBJECT
- &REST
Returns the pointer to the actual handle object that the output object encapsulates. You should not need this unless you are working with the internals of the library. See OUTPUT
-
EXTERNAL GENERIC-FUNCTION NAME
- OBJECT
- &REST
Returns the name used to identify the output in the audio playback device, if permitted. Can be set as an initarg on the otuput. The default value is calculated by DEVICE-DEFAULT-NAME See OUTPUT See DEVICE-DEFAULT-NAME
-
EXTERNAL GENERIC-FUNCTION OUTPUT
- CONDITION
- &REST
Returns the output object associated with the condition. See OUTPUT-ERROR
-
EXTERNAL GENERIC-FUNCTION OUTPUT-TO
- OBJECT
- &REST
Returns a list of special flags that tell the backend (if possible) where to output to. Can be set as an initarg on the output. The flags in the list can be one of :HEADPHONES :INTERNAL-SPEAKER :LINE-OUT See OUTPUT
-
EXTERNAL GENERIC-FUNCTION PLAYING
- OBJECT
- &REST
Returns T if the output is currently playing audio.
-
EXTERNAL GENERIC-FUNCTION PRELOAD
- OBJECT
- &REST
Returns the percentage of data that is preloaded into the device buffer. Can be set as an initarg on the output. Allowed values are: T for the default that the backend will choose for itself. NIL for no preloading, aka 0.0. REAL for the approximate fraction that should be preloaded [0,1]. See OUTPUT
-
EXTERNAL GENERIC-FUNCTION RATE
- CONDITION
- &REST
-
EXTERNAL MACRO WITH-PLAYBACK
- OUTPUT
- &KEY
- RATE
- CHANNELS
- ENCODING
- &REST
- &BODY
- BODY
- &REST