forked from MrBesen/soundboard
basic config working
This commit is contained in:
parent
56505a2e57
commit
610d0eee5f
|
@ -4,3 +4,6 @@
|
||||||
[submodule "miniaudio"]
|
[submodule "miniaudio"]
|
||||||
path = miniaudio
|
path = miniaudio
|
||||||
url = https://github.com/mackron/miniaudio.git
|
url = https://github.com/mackron/miniaudio.git
|
||||||
|
[submodule "Log"]
|
||||||
|
path = Log
|
||||||
|
url = https://git.okaestne.de/okaestne/Log.git
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 96d10d6e72ddaffd8b688db5ef2705e38aff3a75
|
|
@ -0,0 +1,36 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class Config {
|
||||||
|
public:
|
||||||
|
Config();
|
||||||
|
~Config();
|
||||||
|
|
||||||
|
bool hasChanged();
|
||||||
|
void load();
|
||||||
|
|
||||||
|
struct RootConfig {
|
||||||
|
struct AudioConfig {
|
||||||
|
std::vector<std::string> devices;
|
||||||
|
} audio;
|
||||||
|
|
||||||
|
struct ButtonConfig {
|
||||||
|
std::string name;
|
||||||
|
std::string file;
|
||||||
|
std::string key;
|
||||||
|
uint64_t offset;
|
||||||
|
uint64_t length;
|
||||||
|
|
||||||
|
bool isValid() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<ButtonConfig> buttons;
|
||||||
|
std::string audioPath;
|
||||||
|
} rootConfig;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string file = "soundboard.json";
|
||||||
|
};
|
|
@ -2,13 +2,14 @@
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QShortcut>
|
#include <vector>
|
||||||
#include "qxtglobalshortcut.h"
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "soundbutton.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class Soundboard; }
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
|
@ -20,17 +21,15 @@ public:
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void buttonPressed(unsigned int id);
|
void reloadConfig();
|
||||||
void buttonPressed0();
|
|
||||||
void buttonPressed1();
|
signals:
|
||||||
void shortcut();
|
void newStatusMessage(const QString&);
|
||||||
void shortcut2();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void playSound(unsigned int id);
|
|
||||||
|
|
||||||
Ui::MainWindow *ui;
|
Ui::Soundboard *ui;
|
||||||
QShortcut* sc;
|
std::vector<SoundButton*> soundbuttons;
|
||||||
QxtGlobalShortcut* globalShortcut;
|
Config config;
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -18,6 +18,7 @@ public:
|
||||||
bool addDefaultDevice();
|
bool addDefaultDevice();
|
||||||
bool addDeviceWithName(const std::string& name);
|
bool addDeviceWithName(const std::string& name);
|
||||||
void stopAll();
|
void stopAll();
|
||||||
|
void reset();
|
||||||
|
|
||||||
const static std::string FOLDER;
|
const static std::string FOLDER;
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "qxtglobalshortcut.h"
|
||||||
|
|
||||||
|
class SoundButton : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SoundButton(const std::string& filename, const std::string& name_ = "", const std::string& keycombo = "");
|
||||||
|
~SoundButton();
|
||||||
|
|
||||||
|
const std::string& getName() const;
|
||||||
|
const std::string& getFile() const;
|
||||||
|
const std::string& getKeyCombo() const;
|
||||||
|
|
||||||
|
QPushButton* getButton();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void play();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static uint64_t nextid;
|
||||||
|
uint64_t id;
|
||||||
|
std::string name;
|
||||||
|
std::string file;
|
||||||
|
std::string keycombo;
|
||||||
|
|
||||||
|
QxtGlobalShortcut* globalShortcut = nullptr;
|
||||||
|
QPushButton* button = nullptr;
|
||||||
|
};
|
|
@ -0,0 +1,60 @@
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static void readVector(std::vector<T>& v, const json& j) {
|
||||||
|
v.clear();
|
||||||
|
v.reserve(j.size());
|
||||||
|
std::copy(j.begin(), j.end(), std::insert_iterator<std::vector<T>>(v, v.begin()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Config::Config() {
|
||||||
|
}
|
||||||
|
|
||||||
|
Config::~Config() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, Config::RootConfig::AudioConfig& ac) {
|
||||||
|
readVector(ac.devices, j.value("devices", json::array()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, Config::RootConfig::ButtonConfig& bc) {
|
||||||
|
bc.name = j.value("name", "");
|
||||||
|
bc.file = j.value("file", "");
|
||||||
|
bc.key = j.value("key", "");
|
||||||
|
bc.offset = j.value("offset", 0);
|
||||||
|
bc.length = j.value("length", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, Config::RootConfig& rc) {
|
||||||
|
rc.audio = j.value<Config::RootConfig::AudioConfig>("audio", {});
|
||||||
|
json barr = j.value("buttons", json::array());
|
||||||
|
if(barr.is_array() && !barr.empty()) {
|
||||||
|
readVector(rc.buttons, barr);
|
||||||
|
}
|
||||||
|
rc.audioPath = j.value("audioPath", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Config::RootConfig::ButtonConfig::isValid() const {
|
||||||
|
return !file.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Config::load() {
|
||||||
|
std::ifstream stream(file);
|
||||||
|
json json;
|
||||||
|
if(stream) {
|
||||||
|
try {
|
||||||
|
stream >> json;
|
||||||
|
} catch(nlohmann::detail::parse_error& pe) {
|
||||||
|
std::cout << "json error: " << pe.what() << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootConfig = json;
|
||||||
|
}
|
|
@ -2,8 +2,14 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
#include <Log.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
Log::init();
|
||||||
|
Log::setColoredOutput(true);
|
||||||
|
Log::setConsoleLogLevel(Log::Level::TRACE);
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
|
@ -4,63 +4,56 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
#include <Log.h>
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Soundboard) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
Sound& sound = Sound::instance(); // init sound
|
reloadConfig();
|
||||||
sound.addDeviceWithName("VirtualMic");
|
|
||||||
sound.addDefaultDevice();
|
|
||||||
|
|
||||||
QPushButton* btn = ui->pushButton;
|
// init Buttons
|
||||||
QObject::connect(btn, SIGNAL( clicked() ), this, SLOT( buttonPressed0() ));
|
SoundButton* sb;
|
||||||
|
sb = new SoundButton("Uwu_voice-xjrU3N8M4eo-251.mp3", "UwU", "Shift+F1");
|
||||||
|
ui->gridLayout->addWidget(sb->getButton(), 0, 0);
|
||||||
|
soundbuttons.push_back(sb);
|
||||||
|
sb = new SoundButton("bonk.wav", "Bonk");
|
||||||
|
ui->gridLayout->addWidget(sb->getButton(), 0, 1);
|
||||||
|
soundbuttons.push_back(sb);
|
||||||
|
|
||||||
QPushButton* btn2 = ui->pushButton2;
|
QObject::connect(ui->reloadButton, SIGNAL( clicked() ), this, SLOT( reloadConfig() ));
|
||||||
QObject::connect(btn2, SIGNAL( clicked() ), this, SLOT( buttonPressed1() ));
|
QObject::connect(this, SIGNAL( newStatusMessage(const QString&) ), ui->statusbar, SLOT( showMessage(const QString&) ));
|
||||||
|
|
||||||
sc = new QShortcut(QKeySequence("Shift+1"), this, 0, 0, Qt::ApplicationShortcut);
|
|
||||||
QObject::connect(sc, SIGNAL( activated() ), this, SLOT( shortcut() ));
|
|
||||||
|
|
||||||
globalShortcut = new QxtGlobalShortcut(QKeySequence("Shift+F1"));
|
|
||||||
QObject::connect(globalShortcut, SIGNAL(activated()), this, SLOT( shortcut2() ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::string SOUNDS[2] {"Uwu_voice-xjrU3N8M4eo-251.mp3", "bonk.wav"};
|
|
||||||
static const unsigned int SOUNDSSIZE = 2;
|
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
delete ui;
|
delete ui;
|
||||||
|
|
||||||
Sound::deinit();
|
Sound::deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::buttonPressed(unsigned int id) {
|
void MainWindow::reloadConfig() {
|
||||||
std::cout << "Button Pressed: " << id << std::endl;
|
Log::info << "realodConfig()";
|
||||||
|
|
||||||
playSound(id);
|
QString loaded = QString::fromStdString("loading config");
|
||||||
}
|
emit newStatusMessage(loaded);
|
||||||
|
|
||||||
void MainWindow::buttonPressed0() {
|
config.load();
|
||||||
buttonPressed(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::buttonPressed1() {
|
Sound& sound = Sound::instance(); // init sound
|
||||||
buttonPressed(1);
|
sound.reset();
|
||||||
}
|
const std::vector<std::string>& devices = config.rootConfig.audio.devices;
|
||||||
|
for(const std::string& device : devices) {
|
||||||
|
Log::note << "loadAudio device: \"" << device << '"';
|
||||||
|
|
||||||
void MainWindow::shortcut() {
|
if(!sound.addDeviceWithName(device)) {
|
||||||
std::cout << "Shortcut Pressed" << std::endl;
|
Log::warn << "AudioDevice could not be loaded: \"" << device << '"';
|
||||||
|
QString done = QString::fromStdString("Sound Device: " + device + " not found!");
|
||||||
// playSound();
|
emit newStatusMessage(done);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
void MainWindow::shortcut2() {
|
|
||||||
std::cout << "Shortcut2 Pressed!!" << std::endl;
|
|
||||||
|
|
||||||
// playSound();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::playSound(unsigned int soundid) {
|
|
||||||
if(soundid < SOUNDSSIZE) {
|
|
||||||
Sound::instance().addPlayback(SOUNDS[soundid]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString done = QString::fromStdString("config loaded");
|
||||||
|
emit newStatusMessage(done);
|
||||||
|
|
||||||
|
Log::info << "realodConfig() done";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Diese Datei ist stark an den examples von miniaudio orientiert (vor allem simple_mixing.c). Die Struktur ähnelt sich daher möglicherweise.
|
// Diese Datei ist stark an den examples von miniaudio orientiert (vor allem simple_mixing.c). Die Struktur ähnelt sich daher möglicherweise.
|
||||||
|
|
||||||
|
|
||||||
#define MA_DEBUG_OUTPUT
|
//#define MA_DEBUG_OUTPUT
|
||||||
//#define MA_LOG_LEVEL MA_LOG_LEVEL_VERBOSE
|
//#define MA_LOG_LEVEL MA_LOG_LEVEL_VERBOSE
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -42,6 +42,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <Log.h>
|
||||||
|
|
||||||
Sound* Sound::inst = nullptr;
|
Sound* Sound::inst = nullptr;
|
||||||
const std::string Sound::FOLDER = "/home/yannis/prog/ts3/soundboardsounds/";
|
const std::string Sound::FOLDER = "/home/yannis/prog/ts3/soundboardsounds/";
|
||||||
|
@ -60,7 +61,7 @@ void Sound::deinit() {
|
||||||
inst = nullptr;
|
inst = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Sound deinited" << std::endl;
|
Log::info << "Sound deinited";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::addPlayback(const std::string& name, float volume) {
|
void Sound::addPlayback(const std::string& name, float volume) {
|
||||||
|
@ -78,7 +79,7 @@ bool Sound::addDefaultDevice() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sound::addDeviceWithName(const std::string& name) {
|
bool Sound::addDeviceWithName(const std::string& name) {
|
||||||
SoundDevice* sd = SoundDevice::createDevice(&context, name);
|
SoundDevice* sd = (name.empty() ? SoundDevice::createDevice(&context) : SoundDevice::createDevice(&context, name));
|
||||||
if(sd) {
|
if(sd) {
|
||||||
devices.push_back(sd);
|
devices.push_back(sd);
|
||||||
}
|
}
|
||||||
|
@ -91,9 +92,28 @@ void Sound::stopAll() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sound::reset() {
|
||||||
|
Log::info << "ResetAudio";
|
||||||
|
|
||||||
|
// deinit
|
||||||
|
stopAll();
|
||||||
|
for(SoundDevice* sd : devices) {
|
||||||
|
delete sd;
|
||||||
|
}
|
||||||
|
devices.clear();
|
||||||
|
ma_context_uninit(&context);
|
||||||
|
|
||||||
|
// reinit
|
||||||
|
if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) {
|
||||||
|
Log::error << "Failed to initialize Sound context.";
|
||||||
|
throw new std::exception();
|
||||||
|
}
|
||||||
|
Log::info << "ResetAudio done";
|
||||||
|
}
|
||||||
|
|
||||||
Sound::Sound() {
|
Sound::Sound() {
|
||||||
if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) {
|
if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) {
|
||||||
std::cout << "Failed to initialize Sound context." << std::endl;
|
Log::error << "Failed to initialize Sound context.";
|
||||||
throw new std::exception();
|
throw new std::exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
#include "soundbutton.h"
|
||||||
|
|
||||||
|
#include "sound.h"
|
||||||
|
|
||||||
|
uint64_t SoundButton::nextid = 0;
|
||||||
|
|
||||||
|
SoundButton::SoundButton(const std::string& filename, const std::string& name_, const std::string& keycombo) : id(nextid++), file(filename), keycombo(keycombo) {
|
||||||
|
name = (name_.empty() ? filename : name_);
|
||||||
|
|
||||||
|
button = new QPushButton(QString::fromStdString(name));
|
||||||
|
button->setObjectName(QString::fromStdString("soundButton" + std::to_string(id)));
|
||||||
|
button->setGeometry(QRect(10, 10, 100, 27));
|
||||||
|
|
||||||
|
globalShortcut = new QxtGlobalShortcut(QString::fromStdString(keycombo));
|
||||||
|
|
||||||
|
QObject::connect(globalShortcut, SIGNAL( activated() ), this, SLOT( play() ));
|
||||||
|
QObject::connect(button, SIGNAL( clicked() ), this, SLOT( play() ));
|
||||||
|
}
|
||||||
|
|
||||||
|
SoundButton::~SoundButton() {
|
||||||
|
delete globalShortcut;
|
||||||
|
delete button;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& SoundButton::getName() const {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& SoundButton::getFile() const {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& SoundButton::getKeyCombo() const {
|
||||||
|
return keycombo;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton* SoundButton::getButton() {
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoundButton::play() {
|
||||||
|
Sound::instance().addPlayback(file);
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <Log.h>
|
||||||
|
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
|
@ -87,9 +88,9 @@ SoundDevice* SoundDevice::createDevice(ma_context* ctx, const std::string& name)
|
||||||
ma_result result = ma_context_get_devices(ctx, &pPlaybackDeviceInfos, &playbackDeviceCount, NULL, 0);
|
ma_result result = ma_context_get_devices(ctx, &pPlaybackDeviceInfos, &playbackDeviceCount, NULL, 0);
|
||||||
int8_t choosenDevice = -1;
|
int8_t choosenDevice = -1;
|
||||||
|
|
||||||
std::cout << " " << playbackDeviceCount << " playback devices found:" << std::endl;
|
Log::info << " " << playbackDeviceCount << " playback devices found:";
|
||||||
for(uint8_t i = 0; i < playbackDeviceCount; i++) {
|
for(uint8_t i = 0; i < playbackDeviceCount; i++) {
|
||||||
std::cout << " " << (int) i << ": " << pPlaybackDeviceInfos[i].name << std::endl;
|
Log::info << " " << (int) i << ": " << pPlaybackDeviceInfos[i].name;
|
||||||
|
|
||||||
if(pPlaybackDeviceInfos[i].name == name) {
|
if(pPlaybackDeviceInfos[i].name == name) {
|
||||||
choosenDevice = i;
|
choosenDevice = i;
|
||||||
|
@ -97,7 +98,7 @@ SoundDevice* SoundDevice::createDevice(ma_context* ctx, const std::string& name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(choosenDevice == -1) {
|
if(choosenDevice == -1) {
|
||||||
std::cout << "Device \"" << name << "\" not found!" << std::endl;
|
Log::info << "Device \"" << name << "\" not found!";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,13 +120,13 @@ SoundDevice* SoundDevice::createDevice(ma_context* ctx, const ma_device_id* did)
|
||||||
deviceConfig.pUserData = sd;
|
deviceConfig.pUserData = sd;
|
||||||
|
|
||||||
if (ma_device_init(ctx, &deviceConfig, &sd->device) != MA_SUCCESS) {
|
if (ma_device_init(ctx, &deviceConfig, &sd->device) != MA_SUCCESS) {
|
||||||
std::cout << "Failed to open sound device." << std::endl;
|
Log::error << "Failed to open sound device.";
|
||||||
|
|
||||||
delete sd;
|
delete sd;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Sound playback device \"" << sd->device.playback.name << "\" initilized." << std::endl;
|
Log::info << "Sound playback device \"" << sd->device.playback.name << "\" initilized.";
|
||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ void SoundDevice::stop() {
|
||||||
ma_mutex_unlock(data.mutex);
|
ma_mutex_unlock(data.mutex);
|
||||||
|
|
||||||
if(deviceRunning)
|
if(deviceRunning)
|
||||||
std::cout << "Sound playback device \"" << device.playback.name << "\" stopped." << std::endl;
|
Log::info << "Sound playback device \"" << device.playback.name << "\" stopped.";
|
||||||
|
|
||||||
deviceRunning = false;
|
deviceRunning = false;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +154,7 @@ void SoundDevice::addPlayback(const std::string& name, float volume) {
|
||||||
Playback* pb = new Playback();
|
Playback* pb = new Playback();
|
||||||
|
|
||||||
if (ma_decoder_init_file((Sound::FOLDER + name).c_str(), NULL, &(pb->decoder)) != MA_SUCCESS) {
|
if (ma_decoder_init_file((Sound::FOLDER + name).c_str(), NULL, &(pb->decoder)) != MA_SUCCESS) {
|
||||||
std::cout << "Sound datei: " << name << " konnte nicht geladen werden!" << std::endl;
|
Log::info << "Sound datei: " << name << " konnte nicht geladen werden!";
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +174,7 @@ void SoundDevice::startDevice() {
|
||||||
if (deviceRunning) return;
|
if (deviceRunning) return;
|
||||||
|
|
||||||
if (ma_device_start(&device) != MA_SUCCESS) {
|
if (ma_device_start(&device) != MA_SUCCESS) {
|
||||||
std::cout << "Failed to start sound device \"" << device.playback.name << "\"" << std::endl;
|
Log::error << "Failed to start sound device \"" << device.playback.name << "\"";
|
||||||
stop();
|
stop();
|
||||||
ma_device_uninit(&device);
|
ma_device_uninit(&device);
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
|
@ -181,7 +182,7 @@ void SoundDevice::startDevice() {
|
||||||
|
|
||||||
deviceRunning = true;
|
deviceRunning = true;
|
||||||
|
|
||||||
std::cout << "Sound device \"" << device.playback.name << "\" started." << std::endl;
|
Log::info << "Sound device \"" << device.playback.name << "\" started.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundDevice::cleanupDecoders() {
|
void SoundDevice::cleanupDecoders() {
|
||||||
|
@ -202,5 +203,5 @@ void SoundDevice::cleanupDecoders() {
|
||||||
ma_mutex_unlock(data.mutex);
|
ma_mutex_unlock(data.mutex);
|
||||||
|
|
||||||
if (count)
|
if (count)
|
||||||
std::cout << "removed " << count << " decoder" << std::endl;
|
Log::debug << "removed " << count << " decoder";
|
||||||
}
|
}
|
||||||
|
|
13
testqt.pro
13
testqt.pro
|
@ -21,13 +21,19 @@ SOURCES += \
|
||||||
src/main.cpp \
|
src/main.cpp \
|
||||||
src/mainwindow.cpp \
|
src/mainwindow.cpp \
|
||||||
src/sound.cpp \
|
src/sound.cpp \
|
||||||
src/sounddevice.cpp
|
src/sounddevice.cpp \
|
||||||
|
src/soundbutton.cpp \
|
||||||
|
src/config.cpp \
|
||||||
|
Log/Log.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
include/mainwindow.h \
|
include/mainwindow.h \
|
||||||
include/sound.h \
|
include/sound.h \
|
||||||
include/sounddevice.h \
|
include/sounddevice.h \
|
||||||
miniaudio/miniaudio.h
|
include/soundbutton.h \
|
||||||
|
miniaudio/miniaudio.h \
|
||||||
|
include/config.h \
|
||||||
|
Log/Log.h
|
||||||
|
|
||||||
MOC_DIR = generated/
|
MOC_DIR = generated/
|
||||||
UI_DIR = ui/
|
UI_DIR = ui/
|
||||||
|
@ -40,7 +46,8 @@ TRANSLATIONS += \
|
||||||
testqt_de_DE.ts
|
testqt_de_DE.ts
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/include/ \
|
INCLUDEPATH += $$PWD/include/ \
|
||||||
$$PWD/miniaudio/
|
$$PWD/miniaudio/ \
|
||||||
|
$$PWD/Log/
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
|
|
@ -1,56 +1,45 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>MainWindow</class>
|
<class>Soundboard</class>
|
||||||
<widget class="QMainWindow" name="MainWindow">
|
<widget class="QMainWindow" name="Soundboard">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>778</width>
|
<width>824</width>
|
||||||
<height>613</height>
|
<height>675</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>Soundboard</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QWidget" name="gridLayoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>330</x>
|
<x>10</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>791</width>
|
||||||
|
<height>561</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMaximumSize</enum>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="reloadButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<width>151</width>
|
<width>141</width>
|
||||||
<height>19</height>
|
<height>27</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Hello, world!</string>
|
<string>reload Config</string>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton" name="pushButton">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>30</y>
|
|
||||||
<width>371</width>
|
|
||||||
<height>531</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>UwU</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton" name="pushButton2">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>400</x>
|
|
||||||
<y>30</y>
|
|
||||||
<width>381</width>
|
|
||||||
<height>531</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Bonk</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -59,7 +48,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>778</width>
|
<width>824</width>
|
||||||
<height>24</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in New Issue