QAudioCoder
A simple Qt-based library for encoding, decoding and converting audio files and buffers.
Install / Use
/learn @visore/QAudioCoderREADME
==========================================================================================
QAudioCoder
==========================================================================================
A Qt-based C++ library for audio decoding, encoding and audio file conversion.
Last Release: 20 July 2012 Latest version: 0.1.0 Developer: Christoph Stallmann, University of Pretoria
========================================================================================== About
QAudioCoder is a Qt library for decoding and encoding raw audio samples. The library also provides functionality to directly decode or encode audio files and convert between different formats. On start-up QAudioCoder searches a number of predefined locations for codec libraries. If these libraries are available the functionality is being made public through QAudioCoders interface. QAudioCoder includes libresample developed by Dominic Mazzoni.
========================================================================================== License
QAudioCoder is distributed under the Lesser GNU General Public License (LGPL) version 3 (LGPLv3). Copyright © 2012 Christoph Stallmann, University of Pretoria.
Please refer to License.txt and Copyright.txt for further information.
========================================================================================== Requirements
QAudioCoder requires CMake (2.8.8 or later) for makefile generation and Qt (5.0 or later). Any native compilers should do, recommended are g++ for Linux/Mac and MinGW for Windows.
========================================================================================== Codecs & Formats
QAudioCoder currently only supports the following sample sizes:
- 8bit
- 16bit
- 32bit
QAudioCoder currently supports the following audio formats:
- WAVE (always available)
- MP3 (available if the Lame library is available)
- FLAC (available if the Flac library is available)
========================================================================================== Compiling
The simplest way of compiling QAudioCoder is to run the following command:
<sh> build/os/os-build-architecture options
where os is your operating system (Linux, Windows or Mac) and architecture is 32bit or 64bit. You can specify any of the following options in any order:
- configure: configure cmake
- build: compile QAudioCoder
- install: install the library
Linux example: "sh build/linux/linux-build-32bit configure build install package"
Or you can manually build as follows:
With Qt installed in the default location
- cd code
- mkdir build
- cd build
- cmake ..
- make
With Qt installed in a custom location
- cd code
- mkdir build
- cd build
- ccmake ..
- press 'c', 'c' and then 'g' (change Qt path if needed)
- make
========================================================================================== Search Paths, File Names & Extensions
QAudioCoder will search the following paths: <current dir> is the calling application's path
- <current dir>
- <current dir>/libraries
- <current dir>/library
- <current dir>/Libraries
- <current dir>/Library
- <current dir>/lib
- <current dir>/Lib
- <current dir>/libs
- <current dir>/Libs
Additionally the following OS-specific paths are searched:
Windows:
- C:\Program Files
- C:\Program Files (x86)
Mac:
- /lib
- /lib64
- /usr/lib
- /usr/lib64
- /usr/local/lib
- /usr/local/lib64
Linux:
- /lib
- /lib64
- /usr/lib
- /usr/lib64
- /usr/local/lib
- /usr/local/lib64
- /usr/lib/i386-linux-gnu
- /usr/lib/x86_64-linux-gnu
In every of these directories QAudioCoder will search for the library: <path> is all of the above directories <name> is the name of the library <extension> is the library file extension
- <path>/<name>.<extension>
- <path>/lib<name>.<extension>
- <path>/<name>/<name>.<extension>
- <path>/<name>/lib<name>.<extension>
- <path>/lib<name>/<name>.<extension>
- <path>/lib<name>/lib<name>.<extension>
The following names are used:
Lame library:
- mp3lame
- lame;
Flac library:
- FLAC
- flac
- Flac
The following extensions are used:
- <no extension> (All systems)
- .a (All systems)
- .lib (All systems)
- .dll (Windows only)
- .so (Linux and Mac)
- .dylib (Mac only)
If the library is located anywhere else, the following functions can be used:
void QAudioCoder::addSearchPath(QString path); void QAudioCoder::addFileName(QString coder, QString name); void QAudioCoder::addFileExtension(QString coder, QString extension);
========================================================================================== Usage
There are three examples under the example directory. You can execute the examples from the directory by using the command: ./<name>
The following examples are available:
- play: Open an audio file, decode it and play it to the default output device.
- record: Record audio from the default input device, encode it and save it to a file.
- convert: Convert and audio file to another format.
========================================================================================== Headers
- WAVE: The default 44-byte RIFF-WAVE header is used. Currently only raw PCM as WAVE data is allowed. Any other formats are not supported.
- MP3: The Lame tag, an extension of the Xing header, is used for MP3 headers.
- FLAC: The default Flac headers are used.
========================================================================================== The Main Class
QAudioCoder is the interface that should be used for all decoding, encoding and conversions. See the examples directory for advanced illustrations.
signals:
void progressed(qreal percentage);
void finished();
private slots:
void setError(QCoder::Error error);
public:
-
QAudioCoder()
Constructor for creating a QAudioCoder object.
-
void failed(QCoder::Error error)
Signal emitted if the processing failed. The following errors are emitted:
1. NoError - No error 2. UnknownError - Unknown error 3. InputFileError - The input file could not be accessed 4. OutputFileError - The output file could not be accessed 5. DecoderInitializationError - Decoder could not be initialized 6. EncoderInitializationError - Encoder could not be initialized 7. DecoderFinalizationError - Decoder could not be finalized and closed 8. EncoderFinalizationError - Encoder could not be finalized and closed 9. DecodingError - The provided data could not be decoded 10. EncodingError - The provided data could not be encoded 11. LibraryFileError - The codec library could not be accessed 12. LibraryVersionError - The codec library has an incompatible version 13. UnsupportedCodecError - The codec is not supported 14. UnavailableCodecError - The codec is supported, but there is a problem with the supporting library 15. UnsupportedInputCodecError - The same as 13, but focuses on the input data 16. UnavailableInputCodecError - The same as 14, but focuses on the input data 17. UnsupportedOutputCodecError - The same as 13, but focuses on the output data 18. UnavailableOutputCodecError - The same as 14, but focuses on the output data 19. InputSampleSizeError - The input sample size is not valid 20. InputSampleTypeError - The input sample type is not valid 21. InputSampleRateError - The input sample rate is not valid 22. InputBitrateError - The input bitrate is not valid 23. InputChannelError - The input channel count is not valid 24. OutputSampleSizeError - The output sample size is not valid 25. OutputSampleTypeError - The output sample type is not valid 26. OutputSampleRateError - The output sample rate is not valid 27. OutputBitrateError - The output bitrate is not valid 28. OutputChannelError - The output channel count is not valid -
QCoder::Error error()
Returns the error code from 2.
-
QString errorString()
Returns a human-readable string for the error codes above.
-
void addSearchPath(QString path)
Add an additional location to search for the libraries.
Eg: coder.addSearchPath("/usr/my_custom_libs");
-
void addFileName(QString coder, QString name)
Add an additional name for a library. The first parameter is the codec name and the second parameter the new library file name. Please note that QAudioCoder will automatically add "lib" to the front and support a number of file extensions.
Eg: The library nam
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
