Verified Commit 38c2795f authored by Phobos D'thorga's avatar Phobos D'thorga 🐲
Browse files

Merge branch 'develop'

parents c35bf4d4 96450be0
Pipeline #1040 passed with stages
in 27 minutes and 16 seconds
......@@ -40,16 +40,32 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR) # This version is needed to properly search for libpthreads
# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/Useful-Variables#system-compiler-information
if(${CMAKE_VERSION} VERSION_GREATER "3.15.0")
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0020 NEW)
cmake_policy(SET CMP0025 NEW)
#
# https://cmake.org/cmake/help/latest/policy/CMP0054.html
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.1.0")
cmake_policy(SET CMP0054 NEW)
endif()
CMAKE_POLICY(SET CMP0020 NEW)
cmake_policy(SET CMP0074 NEW)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0087 NEW)
cmake_policy(SET CMP0025 NEW)
#
# https://cmake.org/cmake/help/latest/policy/CMP0074.html
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
cmake_policy(SET CMP0074 NEW)
endif()
#
# https://cmake.org/cmake/help/git-stage/policy/CMP0087.html
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
cmake_policy(SET CMP0087 NEW)
endif()
#
# https://cmake.org/cmake/help/git-stage/policy/CMP0091.html
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.15.0")
cmake_policy(SET CMP0091 NEW)
endif()
#
# RPATH is aimed at Linux installations primarily
......@@ -880,26 +896,6 @@ if (ENBL_VALGRIND_SUPPORT)
add_definitions(-DGK_ENBL_VALGRIND_SUPPORT)
endif()
#
# https://gist.github.com/giraldeau/546ba5512a74dfe9d8ea0862d66db412
#
# qt5_create_translation(QM_FILES ${GALAXY_UI_CPP} SmallWorldDeluxe_en_US.ts SmallWorldDeluxe_de_DE.ts) # Create the translation files for Small World Deluxe!
#
# Only call lrelease on each translation files to create qm files.
# This command assumes that the ts files already exists (manually created).
#
# qt5_add_translation(QM_FILES SmallWorldDeluxe_en_US.ts SmallWorldDeluxe_de_DE.ts)
#
# The qm files are generated in the build tree, but the qrc file is inside the
# source directory and the path to resources are relative to the location of
# the qrc file itself. We use configure_file() to copy the qrc file in the build
# directory such that it can find the qm translations files. The qrc file is
# copied if it doesn't exist in the destination or if it is modified.
#
# configure_file(translations.qrc ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
#
# Build Small World Deluxe as a static package!
#
......@@ -925,20 +921,38 @@ endif(GFYRE_BUILD_SHARED)
set_property(TARGET galaxy PROPERTY AUTOMOC ON)
target_link_libraries(galaxy PUBLIC ${GK_EXTRA_LIBS} ICU::i18n ICU::data ICU::uc OpenSSL::SSL Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Network Qt5::Multimedia Qt5::SerialPort Qt5::PrintSupport Qt5::Xml Qt5::TextToSpeech Qt5::Test QXmpp::QXmpp Threads::Threads SingleApplication::SingleApplication sentry::sentry Opus::opus leveldb kissfft ${LIBS})
#
# Qt Translations
#
qt5_create_translation(QM_FILES ${GALAXY_UI_CPP} ${UI_HEADERS} ${GALAXY_OBJ_HEADERS} gk_english.ts)
#
# The qm files are generated in the build tree, but the qrc file is inside the
# source directory and the path to resources are relative to the location of
# the qrc file itself. We use configure_file() to copy the qrc file in the build
# directory such that it can find the qm translations files. The qrc file is
# copied if it doesn't exist in the destination or if it is modified.
#
# configure_file(translations.qrc ${CMAKE_BINARY_DIR} COPYONLY)
qt5_add_binary_resources(resources src/sworld_res.qrc OPTIONS -no-compress)
add_dependencies(galaxy resources)
set(SWRLD_EXEC ${SWRLD_EXEC}
src/main.cpp)
add_executable(smallworld WIN32 ${SWRLD_EXEC})
if(WIN32 OR MSYS OR MINGW)
add_executable(smallworld WIN32 ${SWRLD_EXEC})
elseif(LINUX)
add_executable(smallworld ${SWRLD_EXEC})
else()
message(FATAL_ERROR "Unsupported operating system detected! Please check back at the official code repository for further updates. Thank you.")
endif()
target_compile_options(smallworld PRIVATE -fPIC)
target_compile_definitions(galaxy PRIVATE -DUSE_KISS_FFT)
target_link_libraries(smallworld PRIVATE galaxy)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
#
# Copy the crashpad handler to the root of the binary build directory, for easy access!
# https://cmake.org/cmake/help/latest/module/FetchContent.html
......@@ -961,7 +975,29 @@ else()
${CMAKE_CURRENT_BINARY_DIR}/libcrashpad_handler_lib.a)
endif()
INSTALL(TARGETS smallworld)
if(WIN32 OR MSYS OR MINGW)
if (EXISTS "$ENV{SystemDrive}/Program Files")
INSTALL(TARGETS smallworld
CONFIGURATIONS Debug
RUNTIME DESTINATION Debug/bin
LIBRARY DESTINATION Debug/lib)
INSTALL(TARGETS smallworld
CONFIGURATIONS Release
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib)
endif()
elseif (LINUX)
INSTALL(TARGETS smallworld
CONFIGURATIONS Debug
RUNTIME DESTINATION Debug/bin
LIBRARY DESTINATION Debug/lib)
INSTALL(TARGETS smallworld
CONFIGURATIONS Release
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib)
else()
message(FATAL_ERROR "Unsupported operating system detected! Please check back at the official code repository for further updates. Thank you.")
endif()
SET(CMAKE_C_FLAGS_DEBUG_INIT "-g")
SET(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
......
#### Introduction
We readily admit that [Small World Deluxe](https://code.gekkofyre.io/amateur-radio/small-world-deluxe) uses a large and wide variety of third-party libraries and tools. It is a sincere belief of ours that if a large amount of programming time can be saved by the usage of a third-party library and therefore by not 'reinventing the wheel', so to say, then we'll readily seek out one to fill that gap. This has many advantages, particularly including a rapid development style of coding.
Please check back to this page often as we are always updating it, through the removal and addition of various dependencies, as well as new and more thoroughly updated installation instructions. Additions for other, various `*nix` distros will be included over time too. If you wish for a particular operating system and/or distro to be included, then please [feel free to open an issue within our Issue Tracker](https://code.gekkofyre.io/amateur-radio/small-world-deluxe/-/issues).
#### Microsoft Windows (MinGW via MSYS2)
The instructions for performing a compilation with [MSYS2](https://www.msys2.org/) under Microsoft Windows are more-or-less finished at this stage. It is the author's preference of this Wiki that the MinGW (i.e. [MSYS2](https://www.msys2.org/) in this case) development platform is used where possible, especially over instances where [Cygwin](https://www.cygwin.com/) could be used. This is due to the fact that `Small World Deluxe` has been optimized from the ground-up for MSYS2 on Microsoft Windows systems.
* `base-devel`
* `mingw-w64-x86_64-toolchain`
* `mingw-w64-x86_64-qt5-static`
* `mingw-w64-x86_64-kdeclarative-qt5`
* `mingw-w64-x86_64-qwt`
* `mingw-w64-x86_64-uasm`
* `icu-devel`
* `cmake`
* `mingw-w64-x86_64-extra-cmake-modules`
* `zlib-devel`
* `openssl-devel`
* `mingw-w64-x86_64-snappy`
* `mingw-w64-x86_64-libusb-compat-git `
* `mingw-w64-x86_64-hidapi`
* `mingw-w64-x86_64-libvorbis`
* `mingw-w64-x86_64-opus`
* `mingw-w64-x86_64-libopusenc`
* `mingw-w64-x86_64-libsndfile`
* `mingw-w64-x86_64-qxmpp`
* `mingw-w64-x86_64-enchant`
* `mingw-w64-x86_64-nuspell`
Once you have compiled [Boost C++](#compilation-of-boost-c-under-mingw-via-msys2), [Hamlib](#compilation-of-hamlib-under-mingw-via-msys2), and then [Codec2](#compilation-of-codec2-under-mingw-via-msys2) for the [MSYS2](https://www.msys2.org/) subsystem, you may proceed with the compilation and installation of `Small World Deluxe` itself! [CMake](https://cmake.org/) is required for this operation and we recommend that you create a separate `build` directory for the compilation (as shown below). Once the dependencies have all been set up, you only need to execute the following commands under an MSYS2 shell, from within the root of the `Small World Deluxe` project directory:
```bash
sh bootstrap.sh
mkdir build && cd build
cmake -G "Unix Makefiles" ..
mingw32-make -j$(nproc)
mingw32-make install
```
You will then be able to find all the required files within the 'build' folder, but otherwise, feel free to contact us if you have any issues!
------
##### Compilation of `Boost C++` libraries under MinGW via MSYS2
It seems that the [Boost C++ libraries](https://www.boost.org/) which are part of MSYS2's repositories are not directly compatible with `Small World Deluxe` and as such, you will have to compile this set of libraries by hand instead. But not to worry! The process is very simple with the provided instructions ahead.
You will firstly have to [download the latest version](https://www.boost.org/) of these libraries (preferably in the [7-Zip format](https://www.7-zip.org/) if possible) before extracting the source code to your 'Home' directory (i.e. `C:\msys64\home\${username}\` as an example), where upon you'll then launch `mingw64.exe` from the root directory of your MSYS2 installation. Run the following commands, in sequence, as they complete within the terminal window:
```bash
cd boost_${version}
sh bootstrap.sh
./b2 install --prefix=/mingw64 toolset=gcc address-model=64 instruction-set=native link=static threading=multi runtime-link=shared variant=release --build-type=complete
```
That's all which is required!
##### Compilation of `Hamlib` under MinGW via MSYS2
**UPDATE**: You can simply download the MinGW binaries from [Hamlib's official website](https://hamlib.github.io/) now instead (you will wish to use the provided `gcc` library) and add the paths to your environmental variables. This will be recognized by `Small World Deluxe`'s build scripts and compilation should proceed freely! This is much easier than having to go through the alternative route below.
As mentioned above, the second, alternative route is to compile `Hamlib` yourself straight from its source code via `MSYS2` which can be better in some situations, and lead to fewer errors provided you know what you're doing. To start off, you will need to firstly download the latest version from [Hamlib's official website](https://hamlib.github.io/) and then decompress the source code archive before `cd`'ing into the said directory. You will then need to execute the following commands in order of each other to compile and install the source code:
```bash
mkdir build && cd build
./../configure --disable-shared CFLAGS="-fdata-sections -ffunction-sections" LDFLAGS="-Wl,--gc-sections" --prefix="C:/msys64/mingw64"
mingw32-make
mingw32-make install
```
The process should be rather straightforward but if you have any issues and/or questions, then please do not hesitate to ask about them within our [official Issue Tracker](https://code.gekkofyre.io/amateur-radio/small-world-deluxe/-/issues).
##### Compilation of `Codec2` under MinGW via MSYS2
Unlike the aforementioned `Hamlib`, there are no ready-to-use binary sources for `Codec2` and you will need to perform a compilation of the most up-to-date sources instead. This is because of how frequently `Codec2` is updated on a continual basis. Thankfully, it's not too difficult to compile and with some determination, you will be going in no time! To start with, you will need to [grab the latest sources for Codec2 from the official GitHub repository](https://github.com/drowe67/codec2).
Once the sources have been extracted into the applicable home directory of your [MSYS2 installation](https://www.msys2.org/), you will then want to open the `mingw64.exe` shell in order to make an `x86_64` compilation. You may then navigate to the root of the `Codec2` sources where you'll create a `build` directory before `cd`'ing into it, and then executing the following commands in order:
```bash
mkdir build && cd build
cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=NO -DCMAKE_INSTALL_PREFIX="/mingw64" ..
mingw32-make
mingw32-make install
```
The operation is now complete! If you encountered any problems and/or have questions, then please open them within our [official Issue Tracker](https://code.gekkofyre.io/amateur-radio/small-world-deluxe/-/issues), thank you. Otherwise, you may now progress towards the compilation of `Small World Deluxe` itself!
------
#### Microsoft Windows (Native MSVC++)
Currently, compilation is no longer at all possible with MSVC++ in any shape or form. We apologize for this but it's due to the fact that we now have support for the [Codec2 libraries](https://github.com/drowe67/codec2) and they themselves do not have any plans for this compiler as of writing (September 2020). Ask them instead if you would like this to be supported, as we sure would :)
------
#### Linux (Debian-based)
If you are using a Linux-based system to compile `Small World Deluxe`, you will require the following libraries (a Debian-based distro is used in this example for the package naming nomenclature):
- `cmake`
- `cmake-data`
- `extra-cmake-modules`
- `libpthread-stubs0-dev` (or something along those lines)
- `libboost-all-dev`
- `zlib1g-dev`
- `libasound2-dev`
- `libcodec2-0.9`
- `libsnappy-dev`
- `libusb-dev`
- `libusb-1.0-0-dev`
- `libhidapi-libusb0`
- `libudev-dev`
- `udev`
- `libvorbis-dev`
- `libogg-dev`
- `libopus-dev`
- `libsndfile1`
- `libcurl4`
- `libsndfile1-dev`
- `libssl-dev`
- `libcurl4-openssl-dev`
- `libenchant-2-dev`
And the following is a *recommended* list of the required packages in regards to the `Qt5` library for a Debian-based system since we use that project for the GUI and primary internals of `Small World Deluxe`. Not all of these packages will be required and we appreciate suggestions on how to clean up the list, but for now, we like to be extra sure by covering all of our bases:
- `qtcreator`
- `qtcreator-data`
- `qtcreator-doc`
- `qt5-default`
- `qttools5-dev`
- `libqwt-qt5-dev`
- `qtmultimedia5-dev`
- `libqt5svg5-dev`
- `libqt5serialbus5-dev`
- `libqt5serialport5-dev`
- `libqt5texttospeech5-dev`
Lastly, you will require the [CMake cross-platform family of tools](https://cmake.org/) to build, test, and package `Small World Deluxe`. We chose this particular software project due to the immense and easily available support for its massive variety of operating systems and system architectures, which simply isn't available with many other options out there. You will find the `CMakeLists.txt` within the root directory of the `Small World Deluxe` project itself.
Before you can finally go on towards the compilation of `Small World Deluxe` though, you must compile three, last libraries by hand since they are either not typically offered by most package managers within Linux, or are too old of version. Please see the [compilation of `libopusenc`](#compilation-of-libopusenc-for-linux-based-systems), [`QXmpp`](#compilation-of-qxmpp-for-linux-based-systems), and then [`Hamlib`](#compilation-of-hamlib-for-linux-based-systems) for for this. Before beginning the compilation of these, be sure to execute `sh bootstrap.sh` in the root of `Small World Deluxe` beforehand. This will download all the needed, extra files from all the required Git repositories.
Once the aforementioned three libraries are compiled by hand, you may begin with `Small World Deluxe`. Start by `cd`'ing into the root of the source directory before executing the following commands:
```bash
sh bootstrap.sh
mkdir build && cd build
cmake -G "Unix Makefiles" ..
make -j$(nproc)
sudo make install
```
That's it! You may now begin using `Small World Deluxe` but please note we are very much in the pre-alpha stages right now, and there is much development going on. The look and feel of the application may change somewhat as the months wear on.
##### Compilation of `libopusenc` for Linux-based systems
This is a required dependency for if you are using `Small World Deluxe` under a Linux-based system and a manual compilation is usually required since this component is typically not found in most repository managers. Thankfully, a compilation of this library is straightforward and easy, you just need to `cd src/contrib/libopusenc/` from the root of the `Small World Deluxe` project itself, whereupon you will execute the following commands to begin compilation and then, installation:
```bash
sh autogen.sh
./configure --enable-static --enable-shared
make -j$(nproc)
sudo make install
```
And that's it! Please feel free to [open an issue with us](https://code.gekkofyre.io/amateur-radio/small-world-deluxe/-/issues) if you have encountered any problems and require further assistance.
##### Compilation of `Nuspell` for Linux-based systems
If you are to have spelling and grammar checking with `Small World Deluxe` for the outgoing chat functions, then compilation of this library is a must. Otherwise, you may feel free to skip it. But regardless of your choice concerning this library, compilation is straightforward and easy so you may as well do it anyway. You can start by navigating to the source directory with `cd src/contrib/nuspell`, whereupon you will execute the following commands to begin compilation and then, installation:
```bash
mkdir build && cd build
cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON ..
make -j$(nproc)
sudo make install
```
Nothing more is required for this particular library! You may move onto the next one, [which is `QXmpp`](#compilation-of-qxmpp-for-linux-based-systems) if you are following these instructions sequentially.
##### Compilation of `QXmpp` for Linux-based systems
This too is a required dependency and while it is typically provided with most package managers under Linux, unlike `libopusenc`, the versions that are easily available are too old for what `Small World Deluxe` requires and will work with. To start with, you just need to `cd src/contrib/qxmpp` from the root of the `Small World Deluxe` project itself, whereupon you will execute the following commands to begin compilation and then, installation:
```bash
sudo apt-get remove --purge libqxmpp-dev libqxmpp1 -y
mkdir build && cd build
cmake -G "Unix Makefiles" ..
make -j$(nproc)
sudo make install
```
Now there's only one more library to compile and then we are done! Move onto the compilation of `Hamlib` before we can finally begin the building of `Small World Deluxe` at last.
##### Compilation of `Hamlib` for Linux-based systems
`Hamlib` is the last of the dependencies that are required to be compiled for Linux-based systems and again is for the same reason as `QXmpp` above; it's readily available through most package managers but the versions offered are typically too old for what's required by `Small World Deluxe` since we are creating tools that work with the most bleeding edge of software. To start with, you just need to `cd src/contrib/Hamlib` from the root of the `Small World Deluxe` project itself, whereupon you will execute the following commands to begin compilation and then, installation:
```bash
sudo apt-get remove --purge libhamlib++-dev libhamlib-dev libhamlib2++c2 libhamlib2
sh bootstrap
./configure --enable-static --enable-shared --with-xml-support --with-cxx-binding --with-libusb
make -j$(nproc)
sudo make install
```
You are now done and complete! Please let us know if we've missed anything, as we wish for this to be a complete list.
#### Linux (Arch/Pacman-based)
The instructions for Linux distributions based on [pacman](https://wiki.archlinux.org/title/pacman) (such as [Arch Linux](https://archlinux.org/) or [Manjaro Linux](https://manjaro.org/)) are quite similar to those of that based on Debian-oriented distros, only in this instance, you substitute `apt-get` for `pacman` instead along with the packages which are unique to this environment.
NOTE: We do not have a complete dependency list yet for this flavour of Linux, so please only compile `Small World Deluxe` via `Arch Linux` at your own risk! We therefore only offer bare-bones support so far for `pacman`-based distributions.
That said, we have thus far found that `Small World Deluxe` compiles best with `GCC`/`G++` within this flavour of Linux, based on our own experiences with `Manjaro Linux`. You may therefore want to configure your environment to use such for compiling in order to avoid any extraneous errors. We would very much appreciate any feedback on your experiences with `Arch Linux` and related in regards to `Small World Deluxe`, so please share for the benefit of the greater community!
Lastly, we do use an Arch Linux-based [Docker image](https://hub.docker.com/u/gekkofyre) for compiling `Small World Deluxe` via our [GitLab Runner](https://docs.gitlab.com/runner/) (i.e. Continuous Integration/Deployment) services and related (such as [Jenkins](https://www.jenkins.io/) for Artifactory management). It is semi-regularly kept up-to-date and might be an excellent resource if you, as the end-user, wish to reverse engineer the script otherwise until we provide further support in this area. Or in any case, public binaries for `Small World Deluxe` itself once it becomes stable enough.
\ No newline at end of file
......@@ -67,6 +67,7 @@
#include <iostream>
#include <exception>
#include <streambuf>
#include <QDir>
#include <QList>
#include <QIcon>
#include <QString>
......@@ -74,6 +75,7 @@
#include <QVariant>
#include <QtGlobal>
#include <QPointer>
#include <QFileInfo>
#include <QDateTime>
#include <QHostInfo>
#include <QByteArray>
......@@ -141,6 +143,8 @@ namespace GekkoFyre {
#define GK_XMPP_MAM_BACKLOG_BULK_FETCH_COUNT (125)
#define GK_XMPP_MAM_BACKLOG_FINE_FETCH_COUNT (1)
#define GK_XMPP_MAM_MIN_DATETIME_YEARS (-15)
#define GK_XMPP_MAN_SLEEP_DATETIME_MILLISECS (1000)
#define GK_XMPP_MAM_THREAD_SLEEP_MILLISECS (3000)
#define GK_DEFAULT_XMPP_SERVER_PORT (5222)
......@@ -181,8 +185,9 @@ namespace GekkoFyre {
#define AUDIO_OPUS_FRAMES_PER_BUFFER (960) // This is specific to the Opus multimedia encoding/decoding library.
#define AUDIO_OPUS_MAX_FRAMES_PER_BUFFER (1276)
#define AUDIO_OPUS_INT_SIZE (2)
#define AUDIO_OPUS_MAX_FRAME_SIZE (1276)
#define AUDIO_OPUS_FILE_PTR_READ_SIZE (256) // To be used with `fread` <http://www.cplusplus.com/reference/cstdio/fread/>.
#define AUDIO_OPUS_DEFAULT_SAMPLE_RATE (48000) // The default sampling rate to use when encoding/decoding with Ogg Opus audio (measured in kHz).
#define AUDIO_ENCODING_VAR_PRIME_SLEEP_MILLISECS (1000) // The amount of time to wait for (in milliseconds) while the buffers prime themselves, before continuing with the rest of the encoding functions!
#define AUDIO_SINE_WAVE_PLAYBACK_SECS (3) // Play the sine wave test sample for three seconds!
#define AUDIO_VU_METER_UPDATE_MILLISECS (125) // How often the volume meter should update, in milliseconds.
......@@ -198,6 +203,10 @@ namespace GekkoFyre {
#define AUDIO_PLAYBACK_CODEC_OPUS_IDX (1)
#define AUDIO_PLAYBACK_CODEC_FLAC_IDX (2)
#define AUDIO_RECORDING_DEF_BITRATE (192)
#define AUDIO_RECORDING_SOURCE_INPUT_IDX (0)
#define AUDIO_RECORDING_SOURCE_OUTPUT_IDX (1)
//
// Mostly regarding FFTW functions
//
......@@ -343,8 +352,14 @@ namespace General {
constexpr char gk_sentry_env[] = "development"; // TODO: Make sure to change this upon releasing a proper version of Small World Deluxe!
constexpr char gk_sentry_project_name[] = "small-world-deluxe"; // The actual name of the project as it is both registered and appears within Sentry itself; it is critical that this is set correctly!
namespace Logging {
constexpr char dateTimeFormatting[] = "yyyy-MM-dd hh:mm:ss";
}
namespace Xmpp {
constexpr char captchaNamespace[] = "urn:xmpp:captcha";
constexpr char dateTimeFormatting[] = "yyyy-MM-dd hh:mm:ss";
namespace GoogleLevelDb {
constexpr char jidLookupKey[] = "GkXmppStoredJid";
constexpr char keyToConvXmlStream[] = "GkXmlStream";
......@@ -754,7 +769,8 @@ namespace Database {
enum AudioPlaybackDlg {
GkAudioDlgLastFolderBrowsed,
GkRecordDlgLastFolderBrowsed
GkRecordDlgLastFolderBrowsed,
GkRecordDlgLastCodecSelected
};
enum general_stat_cfg {
......@@ -865,7 +881,7 @@ namespace Database {
bool is_enabled; // Whether this device (as the `QAudioInput` or `QAudioOutput`) is enabled as the primary choice by the end-user, for example, with regards to the spectrograph / waterfall.
GkAudioSource audio_src; // Is the audio device in question an input? Output if FALSE, UNSURE if either.
QAudioFormat user_settings; // The user defined settings for this particular audio device.
quint32 chosen_sample_rate; // The chosen sample rate, as configured by the end-user.
quint32 chosen_sample_rate; // The chosen sample rate, as configured by the end-user. TODO: Replace this with `user_settings` instead!
GkAudioChannels sel_channels; // The selected audio channel configuration.
};
}
......@@ -1057,6 +1073,12 @@ namespace Spectrograph {
}
namespace GkAudioFramework {
enum GkClearForms {
Playback,
Recording,
All
};
struct GkRecord {
float *buffer;
size_t bufferBytes;
......@@ -1092,6 +1114,13 @@ namespace GkAudioFramework {
loopback
};
enum GkAudioRecordStatus {
Active,
Finished,
Paused,
Defunct
};
enum Bitrate {
LosslessCompressed,
LosslessUncompressed,
......@@ -1105,7 +1134,7 @@ namespace GkAudioFramework {
};
struct AudioFileInfo {
boost::filesystem::path audio_file_path; // The path to the audio file itself, if known.
QFileInfo audio_file_path; // The path to the audio file itself, if known.
bool is_output; // Are we dealing with this as an input or output file?
QString track_title; // The title of the audio track (i.e. metadata) within the audio file itself, if there is such information present.
QString file_size_hr; // The human-readable form of the file-size parameter.
......
......@@ -630,6 +630,9 @@ void GkLevelDb::write_audio_playback_dlg_settings(const QString &value, const Au
case AudioPlaybackDlg::GkRecordDlgLastFolderBrowsed:
batch.Put("GkRecordDlgLastFolderBrowsed", value.toStdString());
break;
case AudioPlaybackDlg::GkRecordDlgLastCodecSelected:
batch.Put("GkRecordDlgLastCodecSelected", value.toStdString());
break;
default:
throw std::runtime_error(tr("Invalid key has been provided for writing Audio Playback settings relating to Google LevelDB!").toStdString());
}
......@@ -2648,6 +2651,9 @@ QString GkLevelDb::read_audio_playback_dlg_settings(const AudioPlaybackDlg &key)
case AudioPlaybackDlg::GkRecordDlgLastFolderBrowsed:
status = db->Get(read_options, "GkRecordDlgLastFolderBrowsed", &value);
break;
case AudioPlaybackDlg::GkRecordDlgLastCodecSelected:
status = db->Get(read_options, "GkRecordDlgLastCodecSelected", &value);
break;
default:
throw std::runtime_error(tr("Invalid key has been provided for reading Audio Playback dialog settings relating to Google LevelDB!").toStdString());
}
......
......@@ -61,7 +61,7 @@ extern "C"
{
#endif
#include <opus.h>
#include "src/contrib/opus/include/opus.h"
#ifdef __cplusplus
} // extern "C"
......
This diff is collapsed.
......@@ -44,26 +44,34 @@
#include "src/defines.hpp"
#include "src/dek_db.hpp"
#include "src/gk_logger.hpp"
#include "src/gk_string_funcs.hpp"
#include <sndfile.h>
#include <sndfile.hh>
#include <opus/opusenc.h>
#include <boost/filesystem.hpp>
#include <mutex>
#include <thread>
#include <cstdio>
#include <memory>
#include <string>
#include <QFile>
#include <QObject>
#include <QBuffer>
#include <QPointer>
#include <QSaveFile>
#include <QIODevice>
#include <QByteArray>
#include <QAudioInput>
#include <QAudioOutput>
#include <QAudioFormat>
namespace fs = boost::filesystem;
namespace sys = boost::system;
#ifdef __cplusplus
extern "C"
{
#endif
#include <opus/opusenc.h>
#ifdef __cplusplus
}
#endif
namespace GekkoFyre {
......@@ -119,30 +127,34 @@ class GkAudioEncoding : public QObject {
Q_OBJECT
public:
explicit GkAudioEncoding(const QPointer<QBuffer> &audioInputBuf, const QPointer<QBuffer> &audioOutputBuf,
QPointer<GekkoFyre::GkLevelDb> database, QPointer<QAudioOutput> audioOutput,
QPointer<QAudioInput> audioInput, const GekkoFyre::Database::Settings::Audio::GkDevice &output_device,
const GekkoFyre::Database::Settings::Audio::GkDevice &input_device,
QPointer<GekkoFyre::GkEventLogger> eventLogger, QObject *parent = nullptr);
explicit GkAudioEncoding(QPointer<GekkoFyre::GkLevelDb> database, QPointer<QAudioOutput> audioOutput,
QPointer<QAudioInput> audioInput, QPointer<QBuffer> audioInputBuf,
QPointer<GekkoFyre::StringFuncs> stringFuncs, QPointer<GekkoFyre::GkEventLogger> eventLogger,
QObject *parent = nullptr);
~GkAudioEncoding() override;
QString codecEnumToStr(const GkAudioFramework::CodecSupport &codec);
[[nodiscard]] GekkoFyre::GkAudioFramework::GkAudioRecordStatus getRecStatus() const;
public slots:
void startCaller(const fs::path &media_path, const GekkoFyre::Database::Settings::Audio::GkDevice &audio_dev_info,
const qint32 &bitrate, const GekkoFyre::GkAudioFramework::CodecSupport &codec_choice,
const qint32 &frame_size = AUDIO_FRAMES_PER_BUFFER, const qint32 &application = OPUS_APPLICATION_AUDIO);
void startCaller(const QFileInfo &media_path, const qint32 &bitrate, const GekkoFyre::GkAudioFramework::CodecSupport &codec_choice,
const GekkoFyre::Database::Settings::GkAudioSource &audio_source, const qint32 &frame_size = AUDIO_FRAMES_PER_BUFFER,
const qint32 &application = OPUS_APPLICATION_AUDIO);
void stopEncode();
void processAudioInEncode();
void processAudioOutEncode();
void setRecStatus(const GekkoFyre::GkAudioFramework::GkAudioRecordStatus &status);
void procAudioInBuffer();
private slots:
void stopCaller();
void handleError(const QString &msg, const GekkoFyre::System::Events::Logging::GkSeverity &severity);
void encodeOpus();
void encodeVorbis();
void encodeFLAC();
void encodeOpus(const qint32 &bitrate, qint32 sample_rate, const GekkoFyre::Database::Settings::GkAudioSource &audio_src,
const QFileInfo &media_path, const qint32 &frame_size = AUDIO_OPUS_FRAMES_PER_BUFFER);
void encodeVorbis(const qint32 &bitrate, qint32 sample_rate, const GekkoFyre::Database::Settings::GkAudioSource &audio_src,
const QFileInfo &media_path, const qint32 &frame_size = AUDIO_FRAMES_PER_BUFFER);
void encodeFLAC(const qint32 &bitrate, qint32 sample_rate, const GekkoFyre::Database::Settings::GkAudioSource &audio_src,
const QFileInfo &media_path, const qint32 &frame_size = AUDIO_FRAMES_PER_BUFFER);
signals:
void pauseEncode();
......@@ -151,46 +163,52 @@ signals:
void error(const QString &msg, const GekkoFyre::System::Events::Logging::GkSeverity &severity);
void initialize();
void recStatus(const GekkoFyre::GkAudioFramework::GkAudioRecordStatus &status);
void bytesRead(const qint64 &bytes, const bool &uncompressed = false);
private:
QPointer<GekkoFyre::GkLevelDb> gkDb;
QPointer<GekkoFyre::StringFuncs> gkStringFuncs;
QPointer<GekkoFyre::GkEventLogger> gkEventLogger;
//
// QAudioSystem initialization and buffers
//
GekkoFyre::Database::Settings::Audio::GkDevice gkInputDev;
GekkoFyre::Database::Settings::Audio::GkDevice gkOutputDev;
QPointer<QAudioInput> gkAudioInput;
QPointer<QAudioOutput> gkAudioOutput;