cl-qoa
2024-10-12
An implementation of the Quite Okay Audio format.
Upstream URL
Author
Yukari Hafner <shinmera@tymoon.eu>
Maintainer
Yukari Hafner <shinmera@tymoon.eu>
License
zlib
# About cl-qoa
This is an implementation of the ''Quite OK Audio''(https://qoaformat.org) format, modelled after the reference implementation.
## How To
First, raw-decode a file from any storage supported by ''binary-structures''(https://shinmera.github.io/binary-structures/), like a stream, file, or raw pointer.
:: common lisp
(org.shirakumo.qoa:read-file file)
::
Now with the file in memory, you can decode it to a sample buffer:
:: common lisp
(org.shirakumo.qoa:decode-file *)
::
It will return the raw ``signed-byte 16`` buffer. You can also use ``decode-to-buffer`` to decode the audio piecemeal. To query the file attributes, you can use ``channels`` and ``samplerate``.
Similarly, you can encode a sample buffer into a QOA file.
:: common lisp
(org.shirakumo.qoa:encode-from-buffer samples)
::
Which can then be written out to any supported storage backend again.
:: common lisp
(org.shirakumo.qoa:write-file * file)
::
In both cases, samples are stored interleaved. You can get the channel order for each particular count of channels with the ``channel-layout`` function.
If you just need to convert a WAV file, you can use the ``convert-wav`` function. It requires the samples to be in SINT16 format and will error on any other format. If you need to convert samplerates or sample format, you can use a tool like ffmpeg to pre-convert it.
:: common lisp
(let ((path "myfile.wav"))
(uiop:run-program (list "ffmpeg" "-i" (uiop:native-namestring path)
"-c:a" "pcm_s16le" "-y" (uiop:native-namestring path)))
(org.shirakumo.qoa:convert-wav path))
::