mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-12-24 18:08:27 +01:00
Moved menus to their own respective files
This commit is contained in:
parent
5fedda08d7
commit
2c4d7cbf09
@ -13,11 +13,13 @@ add_definitions(-DSDRPP_IS_CORE)
|
||||
# Main code
|
||||
file(GLOB SRC "src/*.cpp")
|
||||
file(GLOB GUI "src/gui/*.cpp")
|
||||
file(GLOB MENUS "src/gui/menus/*.cpp")
|
||||
file(GLOB DIALOGS "src/gui/dialogs/*.cpp")
|
||||
file(GLOB SIGPATH "src/signal_path/*.cpp")
|
||||
file(GLOB IMGUI "src/imgui/*.cpp")
|
||||
|
||||
# Add code to dyn lib
|
||||
add_library(sdrpp_core SHARED ${SRC} ${GUI} ${SIGPATH} ${IMGUI})
|
||||
add_library(sdrpp_core SHARED ${SRC} ${GUI} ${MENUS} ${DIALOGS} ${SIGPATH} ${IMGUI})
|
||||
set_target_properties(sdrpp_core PROPERTIES PREFIX "")
|
||||
|
||||
# Include core headers
|
||||
|
57
core/src/gui/dialogs/credits.cpp
Normal file
57
core/src/gui/dialogs/credits.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include <gui/dialogs/credits.h>
|
||||
#include <imgui.h>
|
||||
#include <gui/icons.h>
|
||||
|
||||
namespace credits {
|
||||
ImFont* bigFont;
|
||||
|
||||
void init() {
|
||||
// TODO: Have a font manager instead
|
||||
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
||||
}
|
||||
|
||||
void show() {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 20.0f));
|
||||
ImGui::OpenPopup("Credits");
|
||||
ImGui::BeginPopupModal("Credits", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove);
|
||||
|
||||
ImGui::PushFont(bigFont);
|
||||
ImGui::Text("SDR++ ");
|
||||
ImGui::PopFont();
|
||||
ImGui::SameLine();
|
||||
ImGui::Image(icons::LOGO, ImVec2(128, 128));
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::Text("This software is brought to you by\n\n");
|
||||
|
||||
ImGui::Columns(3, "CreditColumns", true);
|
||||
|
||||
// Contributors
|
||||
ImGui::Text("Contributors");
|
||||
ImGui::BulletText("Ryzerth (Creator)");
|
||||
ImGui::BulletText("aosync");
|
||||
ImGui::BulletText("Benjamin Kyd");
|
||||
ImGui::BulletText("Tobias Mädel");
|
||||
ImGui::BulletText("Raov");
|
||||
ImGui::BulletText("Howard0su");
|
||||
|
||||
// Libraries
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text("Libraries");
|
||||
ImGui::BulletText("SoapySDR (PothosWare)");
|
||||
ImGui::BulletText("Dear ImGui (ocornut)");
|
||||
ImGui::BulletText("spdlog (gabime)");
|
||||
ImGui::BulletText("json (nlohmann)");
|
||||
ImGui::BulletText("portaudio (PA Comm.)");
|
||||
|
||||
// Patrons
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text("Patrons");
|
||||
ImGui::BulletText("SignalsEverywhere");
|
||||
|
||||
ImGui::EndPopup();
|
||||
ImGui::PopStyleVar(1);
|
||||
}
|
||||
}
|
6
core/src/gui/dialogs/credits.h
Normal file
6
core/src/gui/dialogs/credits.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace credits {
|
||||
void init();
|
||||
void show();
|
||||
}
|
@ -8,7 +8,6 @@ fftwf_plan p;
|
||||
float* tempData;
|
||||
float* uiGains;
|
||||
char buf[1024];
|
||||
ImFont* bigFont;
|
||||
|
||||
int fftSize = 8192 * 8;
|
||||
|
||||
@ -37,7 +36,6 @@ void fftHandler(dsp::complex_t* samples) {
|
||||
dsp::NullSink sink;
|
||||
int devId = 0;
|
||||
int srId = 0;
|
||||
watcher<int> bandplanId(0, true);
|
||||
watcher<uint64_t> freq((uint64_t)90500000);
|
||||
int demod = 1;
|
||||
watcher<float> vfoFreq(92000000.0f);
|
||||
@ -50,14 +48,12 @@ watcher<float> bw(8000000.0f, true);
|
||||
int sampleRate = 8000000;
|
||||
bool playing = false;
|
||||
watcher<bool> dcbias(false, false);
|
||||
watcher<bool> bandPlanEnabled(true, false);
|
||||
bool showCredits = false;
|
||||
std::string audioStreamName = "";
|
||||
std::string sourceName = "";
|
||||
int menuWidth = 300;
|
||||
bool grabbingMenu = false;
|
||||
int newWidth = 300;
|
||||
bool showWaterfall = true;
|
||||
int fftHeight = 300;
|
||||
bool showMenu = true;
|
||||
|
||||
@ -109,48 +105,6 @@ void loadSourceConfig(std::string name) {
|
||||
bw.val = sampleRate;
|
||||
}
|
||||
|
||||
void loadAudioConfig(std::string name) {
|
||||
json audioSettings = core::configManager.conf["audio"][name];
|
||||
std::string devName = audioSettings["device"];
|
||||
auto _devIt = std::find(audio::streams[name]->audio->deviceNames.begin(), audio::streams[name]->audio->deviceNames.end(), devName);
|
||||
|
||||
// If audio device doesn't exist anymore
|
||||
if (_devIt == audio::streams[name]->audio->deviceNames.end()) {
|
||||
audio::streams[name]->audio->setToDefault();
|
||||
int deviceId = audio::streams[name]->audio->getDeviceId();
|
||||
audio::setAudioDevice(name, deviceId, audio::streams[name]->audio->devices[deviceId].sampleRates[0]);
|
||||
audio::streams[name]->sampleRateId = 0;
|
||||
audio::streams[name]->volume = audioSettings["volume"];
|
||||
audio::streams[name]->audio->setVolume(audio::streams[name]->volume);
|
||||
return;
|
||||
}
|
||||
int deviceId = std::distance(audio::streams[name]->audio->deviceNames.begin(), _devIt);
|
||||
float sr = audioSettings["sampleRate"];
|
||||
auto _srIt = std::find(audio::streams[name]->audio->devices[deviceId].sampleRates.begin(), audio::streams[name]->audio->devices[deviceId].sampleRates.end(), sr);
|
||||
|
||||
// If sample rate doesn't exist anymore
|
||||
if (_srIt == audio::streams[name]->audio->devices[deviceId].sampleRates.end()) {
|
||||
audio::streams[name]->sampleRateId = 0;
|
||||
audio::setAudioDevice(name, deviceId, audio::streams[name]->audio->devices[deviceId].sampleRates[0]);
|
||||
audio::streams[name]->volume = audioSettings["volume"];
|
||||
audio::streams[name]->audio->setVolume(audio::streams[name]->volume);
|
||||
return;
|
||||
}
|
||||
|
||||
int samplerateId = std::distance(audio::streams[name]->audio->devices[deviceId].sampleRates.begin(), _srIt);
|
||||
audio::streams[name]->sampleRateId = samplerateId;
|
||||
audio::setAudioDevice(name, deviceId, audio::streams[name]->audio->devices[deviceId].sampleRates[samplerateId]);
|
||||
audio::streams[name]->deviceId = deviceId;
|
||||
audio::streams[name]->volume = audioSettings["volume"];
|
||||
audio::streams[name]->audio->setVolume(audio::streams[name]->volume);
|
||||
}
|
||||
|
||||
void saveAudioConfig(std::string name) {
|
||||
core::configManager.conf["audio"][name]["device"] = audio::streams[name]->audio->deviceNames[audio::streams[name]->deviceId];
|
||||
core::configManager.conf["audio"][name]["volume"] = audio::streams[name]->volume;
|
||||
core::configManager.conf["audio"][name]["sampleRate"] = audio::streams[name]->sampleRate;
|
||||
}
|
||||
|
||||
void setVFO(float freq);
|
||||
|
||||
// =======================================================
|
||||
@ -264,7 +218,16 @@ void windowInit() {
|
||||
spdlog::info("Initializing SoapySDR");
|
||||
soapy.init();
|
||||
|
||||
credits::init();
|
||||
|
||||
audiomenu::init();
|
||||
bandplanmenu::init();
|
||||
displaymenu::init();
|
||||
|
||||
gui::menu.registerEntry("Source", sourceMenu, NULL);
|
||||
gui::menu.registerEntry("Audio", audiomenu::draw, NULL);
|
||||
gui::menu.registerEntry("Band Plan", bandplanmenu::draw, NULL);
|
||||
gui::menu.registerEntry("Display", displaymenu::draw, NULL);
|
||||
|
||||
gui::freqSelect.init();
|
||||
|
||||
@ -281,8 +244,6 @@ void windowInit() {
|
||||
mod::initAPI(&gui::waterfall);
|
||||
mod::loadFromList(ROOT_DIR "/module_list.json");
|
||||
|
||||
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
||||
|
||||
// Load last source configuration
|
||||
core::configManager.aquire();
|
||||
uint64_t frequency = core::configManager.conf["frequency"];
|
||||
@ -340,26 +301,6 @@ void windowInit() {
|
||||
gui::waterfall.setWaterfallMin(fftMin);
|
||||
gui::waterfall.setFFTMax(fftMax);
|
||||
gui::waterfall.setWaterfallMax(fftMax);
|
||||
|
||||
bandPlanEnabled.val = core::configManager.conf["bandPlanEnabled"];
|
||||
bandPlanEnabled.markAsChanged();
|
||||
|
||||
std::string bandPlanName = core::configManager.conf["bandPlan"];
|
||||
auto _bandplanIt = bandplan::bandplans.find(bandPlanName);
|
||||
if (_bandplanIt != bandplan::bandplans.end()) {
|
||||
bandplanId.val = std::distance(bandplan::bandplans.begin(), bandplan::bandplans.find(bandPlanName));
|
||||
|
||||
if (bandPlanEnabled.val) {
|
||||
gui::waterfall.bandplan = &bandplan::bandplans[bandPlanName];
|
||||
}
|
||||
else {
|
||||
gui::waterfall.bandplan = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
bandplanId.val = 0;
|
||||
}
|
||||
bandplanId.markAsChanged();
|
||||
|
||||
|
||||
gui::freqSelect.setFrequency(frequency);
|
||||
@ -373,30 +314,9 @@ void windowInit() {
|
||||
gui::waterfall.centerFreqMoved = false;
|
||||
gui::waterfall.selectFirstVFO();
|
||||
|
||||
for (auto [name, stream] : audio::streams) {
|
||||
if (core::configManager.conf["audio"].contains(name)) {
|
||||
bool running = audio::streams[name]->running;
|
||||
audio::stopStream(name);
|
||||
loadAudioConfig(name);
|
||||
if (running) {
|
||||
audio::startStream(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
audioStreamName = audio::getNameFromVFO(gui::waterfall.selectedVFO);
|
||||
if (audioStreamName != "") {
|
||||
volume = &audio::streams[audioStreamName]->volume;
|
||||
}
|
||||
|
||||
menuWidth = core::configManager.conf["menuWidth"];
|
||||
newWidth = menuWidth;
|
||||
|
||||
showWaterfall = core::configManager.conf["showWaterfall"];
|
||||
if (!showWaterfall) {
|
||||
gui::waterfall.hideWaterfall();
|
||||
}
|
||||
|
||||
fftHeight = core::configManager.conf["fftHeight"];
|
||||
gui::waterfall.setFFTHeight(fftHeight);
|
||||
|
||||
@ -541,14 +461,6 @@ void drawWindow() {
|
||||
sigpath::signalPath.setDCBiasCorrection(dcbias.val);
|
||||
}
|
||||
|
||||
if (bandplanId.changed() && bandPlanEnabled.val) {
|
||||
gui::waterfall.bandplan = &bandplan::bandplans[bandplan::bandplanNames[bandplanId.val]];
|
||||
}
|
||||
|
||||
if (bandPlanEnabled.changed()) {
|
||||
gui::waterfall.bandplan = bandPlanEnabled.val ? &bandplan::bandplans[bandplan::bandplanNames[bandplanId.val]] : NULL;
|
||||
}
|
||||
|
||||
int _fftHeight = gui::waterfall.getFFTHeight();
|
||||
if (fftHeight != _fftHeight) {
|
||||
fftHeight = _fftHeight;
|
||||
@ -599,7 +511,8 @@ void drawWindow() {
|
||||
if (audioStreamName != "") {
|
||||
core::configManager.aquire();
|
||||
if (!core::configManager.conf["audio"].contains(audioStreamName)) {
|
||||
saveAudioConfig(audioStreamName);
|
||||
//saveAudioConfig(audioStreamName);
|
||||
// TODO: FIX THIS SHIT
|
||||
}
|
||||
audio::streams[audioStreamName]->audio->setVolume(*volume);
|
||||
core::configManager.conf["audio"][audioStreamName]["volume"] = *volume;
|
||||
@ -674,100 +587,6 @@ void drawWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ImGui::CollapsingHeader("Audio", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
int count = 0;
|
||||
int maxCount = audio::streams.size();
|
||||
for (auto const& [name, stream] : audio::streams) {
|
||||
int deviceId;
|
||||
float vol = 1.0f;
|
||||
deviceId = stream->audio->getDeviceId();
|
||||
|
||||
ImGui::SetCursorPosX((menuColumnWidth / 2.0f) - (ImGui::CalcTextSize(name.c_str()).x / 2.0f));
|
||||
ImGui::Text(name.c_str());
|
||||
|
||||
ImGui::PushItemWidth(menuColumnWidth);
|
||||
bool running = stream->running;
|
||||
if (ImGui::Combo(("##_audio_dev_0_"+ name).c_str(), &stream->deviceId, stream->audio->devTxtList.c_str())) {
|
||||
audio::stopStream(name);
|
||||
audio::setAudioDevice(name, stream->deviceId, stream->audio->devices[deviceId].sampleRates[0]);
|
||||
if (running) {
|
||||
audio::startStream(name);
|
||||
}
|
||||
stream->sampleRateId = 0;
|
||||
|
||||
// Create config if it doesn't exist
|
||||
core::configManager.aquire();
|
||||
if (!core::configManager.conf["audio"].contains(name)) {
|
||||
saveAudioConfig(name);
|
||||
}
|
||||
core::configManager.conf["audio"][name]["device"] = stream->audio->deviceNames[stream->deviceId];
|
||||
core::configManager.conf["audio"][name]["sampleRate"] = stream->audio->devices[stream->deviceId].sampleRates[0];
|
||||
core::configManager.release(true);
|
||||
}
|
||||
if (ImGui::Combo(("##_audio_sr_0_" + name).c_str(), &stream->sampleRateId, stream->audio->devices[deviceId].txtSampleRates.c_str())) {
|
||||
audio::stopStream(name);
|
||||
audio::setSampleRate(name, stream->audio->devices[deviceId].sampleRates[stream->sampleRateId]);
|
||||
if (running) {
|
||||
audio::startStream(name);
|
||||
}
|
||||
|
||||
// Create config if it doesn't exist
|
||||
core::configManager.aquire();
|
||||
if (!core::configManager.conf["audio"].contains(name)) {
|
||||
saveAudioConfig(name);
|
||||
}
|
||||
core::configManager.conf["audio"][name]["sampleRate"] = stream->audio->devices[deviceId].sampleRates[stream->sampleRateId];
|
||||
core::configManager.release(true);
|
||||
}
|
||||
if (ImGui::SliderFloat(("##_audio_vol_0_" + name).c_str(), &stream->volume, 0.0f, 1.0f, "")) {
|
||||
stream->audio->setVolume(stream->volume);
|
||||
|
||||
// Create config if it doesn't exist
|
||||
core::configManager.aquire();
|
||||
if (!core::configManager.conf["audio"].contains(name)) {
|
||||
saveAudioConfig(name);
|
||||
}
|
||||
core::configManager.conf["audio"][name]["volume"] = stream->volume;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
count++;
|
||||
if (count < maxCount) {
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
ImGui::Spacing();
|
||||
}
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Band Plan", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
ImGui::PushItemWidth(menuColumnWidth);
|
||||
if (ImGui::Combo("##_4_", &bandplanId.val, bandplan::bandplanNameTxt.c_str())) {
|
||||
core::configManager.aquire();
|
||||
core::configManager.conf["bandPlan"] = bandplan::bandplanNames[bandplanId.val];
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
if (ImGui::Checkbox("Enabled", &bandPlanEnabled.val)) {
|
||||
core::configManager.aquire();
|
||||
core::configManager.conf["bandPlanEnabled"] = bandPlanEnabled.val;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
bandplan::BandPlan_t plan = bandplan::bandplans[bandplan::bandplanNames[bandplanId.val]];
|
||||
ImGui::Text("Country: %s (%s)", plan.countryName.c_str(), plan.countryCode.c_str());
|
||||
ImGui::Text("Author: %s", plan.authorName.c_str());
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Display", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
if (ImGui::Checkbox("Show waterfall", &showWaterfall)) {
|
||||
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
||||
}
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
||||
if(ImGui::CollapsingHeader("Debug")) {
|
||||
ImGui::Text("Frame time: %.3f ms/frame", 1000.0f / ImGui::GetIO().Framerate);
|
||||
ImGui::Text("Framerate: %.1f FPS", ImGui::GetIO().Framerate);
|
||||
@ -846,48 +665,7 @@ void drawWindow() {
|
||||
ImGui::End();
|
||||
|
||||
if (showCredits) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 20.0f));
|
||||
ImGui::OpenPopup("Credits");
|
||||
ImGui::BeginPopupModal("Credits", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove);
|
||||
|
||||
ImGui::PushFont(bigFont);
|
||||
ImGui::Text("SDR++ ");
|
||||
ImGui::PopFont();
|
||||
ImGui::SameLine();
|
||||
ImGui::Image(icons::LOGO, ImVec2(128, 128));
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::Text("This software is brought to you by\n\n");
|
||||
|
||||
ImGui::Columns(3, "CreditColumns", true);
|
||||
|
||||
// Contributors
|
||||
ImGui::Text("Contributors");
|
||||
ImGui::BulletText("Ryzerth (Creator)");
|
||||
ImGui::BulletText("aosync");
|
||||
ImGui::BulletText("Benjamin Kyd");
|
||||
ImGui::BulletText("Tobias Mädel");
|
||||
ImGui::BulletText("Raov");
|
||||
ImGui::BulletText("Howard0su");
|
||||
|
||||
// Libraries
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text("Libraries");
|
||||
ImGui::BulletText("SoapySDR (PothosWare)");
|
||||
ImGui::BulletText("Dear ImGui (ocornut)");
|
||||
ImGui::BulletText("spdlog (gabime)");
|
||||
ImGui::BulletText("json (nlohmann)");
|
||||
ImGui::BulletText("portaudio (PA Comm.)");
|
||||
|
||||
// Patrons
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text("Patrons");
|
||||
ImGui::BulletText("SignalsEverywhere");
|
||||
|
||||
ImGui::EndPopup();
|
||||
ImGui::PopStyleVar(1);
|
||||
credits::show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include <config.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
#include <core.h>
|
||||
#include <gui/menus/display.h>
|
||||
#include <gui/menus/bandplan.h>
|
||||
#include <gui/menus/audio.h>
|
||||
#include <gui/dialogs/credits.h>
|
||||
|
||||
#define WINDOW_FLAGS ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBackground
|
||||
|
||||
|
139
core/src/gui/menus/audio.cpp
Normal file
139
core/src/gui/menus/audio.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
#include <gui/menus/audio.h>
|
||||
#include <gui/bandplan.h>
|
||||
#include <gui/gui.h>
|
||||
#include <core.h>
|
||||
#include <signal_path/audio.h>
|
||||
|
||||
namespace audiomenu {
|
||||
// Note: Those are supposed to be the ones from the volume slider
|
||||
std::string audioStreamName;
|
||||
float* volume;
|
||||
|
||||
void loadAudioConfig(std::string name) {
|
||||
json audioSettings = core::configManager.conf["audio"][name];
|
||||
std::string devName = audioSettings["device"];
|
||||
auto _devIt = std::find(audio::streams[name]->audio->deviceNames.begin(), audio::streams[name]->audio->deviceNames.end(), devName);
|
||||
|
||||
// If audio device doesn't exist anymore
|
||||
if (_devIt == audio::streams[name]->audio->deviceNames.end()) {
|
||||
audio::streams[name]->audio->setToDefault();
|
||||
int deviceId = audio::streams[name]->audio->getDeviceId();
|
||||
audio::setAudioDevice(name, deviceId, audio::streams[name]->audio->devices[deviceId].sampleRates[0]);
|
||||
audio::streams[name]->sampleRateId = 0;
|
||||
audio::streams[name]->volume = audioSettings["volume"];
|
||||
audio::streams[name]->audio->setVolume(audio::streams[name]->volume);
|
||||
return;
|
||||
}
|
||||
int deviceId = std::distance(audio::streams[name]->audio->deviceNames.begin(), _devIt);
|
||||
float sr = audioSettings["sampleRate"];
|
||||
auto _srIt = std::find(audio::streams[name]->audio->devices[deviceId].sampleRates.begin(), audio::streams[name]->audio->devices[deviceId].sampleRates.end(), sr);
|
||||
|
||||
// If sample rate doesn't exist anymore
|
||||
if (_srIt == audio::streams[name]->audio->devices[deviceId].sampleRates.end()) {
|
||||
audio::streams[name]->sampleRateId = 0;
|
||||
audio::setAudioDevice(name, deviceId, audio::streams[name]->audio->devices[deviceId].sampleRates[0]);
|
||||
audio::streams[name]->volume = audioSettings["volume"];
|
||||
audio::streams[name]->audio->setVolume(audio::streams[name]->volume);
|
||||
return;
|
||||
}
|
||||
|
||||
int samplerateId = std::distance(audio::streams[name]->audio->devices[deviceId].sampleRates.begin(), _srIt);
|
||||
audio::streams[name]->sampleRateId = samplerateId;
|
||||
audio::setAudioDevice(name, deviceId, audio::streams[name]->audio->devices[deviceId].sampleRates[samplerateId]);
|
||||
audio::streams[name]->deviceId = deviceId;
|
||||
audio::streams[name]->volume = audioSettings["volume"];
|
||||
audio::streams[name]->audio->setVolume(audio::streams[name]->volume);
|
||||
}
|
||||
|
||||
void saveAudioConfig(std::string name) {
|
||||
core::configManager.conf["audio"][name]["device"] = audio::streams[name]->audio->deviceNames[audio::streams[name]->deviceId];
|
||||
core::configManager.conf["audio"][name]["volume"] = audio::streams[name]->volume;
|
||||
core::configManager.conf["audio"][name]["sampleRate"] = audio::streams[name]->sampleRate;
|
||||
}
|
||||
|
||||
void init() {
|
||||
for (auto [name, stream] : audio::streams) {
|
||||
if (core::configManager.conf["audio"].contains(name)) {
|
||||
bool running = audio::streams[name]->running;
|
||||
audio::stopStream(name);
|
||||
loadAudioConfig(name);
|
||||
if (running) {
|
||||
audio::startStream(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
audioStreamName = audio::getNameFromVFO(gui::waterfall.selectedVFO);
|
||||
if (audioStreamName != "") {
|
||||
volume = &audio::streams[audioStreamName]->volume;
|
||||
}
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvailWidth();
|
||||
int count = 0;
|
||||
int maxCount = audio::streams.size();
|
||||
for (auto const& [name, stream] : audio::streams) {
|
||||
int deviceId;
|
||||
float vol = 1.0f;
|
||||
deviceId = stream->audio->getDeviceId();
|
||||
|
||||
ImGui::SetCursorPosX((menuColumnWidth / 2.0f) - (ImGui::CalcTextSize(name.c_str()).x / 2.0f));
|
||||
ImGui::Text(name.c_str());
|
||||
|
||||
ImGui::PushItemWidth(menuColumnWidth);
|
||||
bool running = stream->running;
|
||||
if (ImGui::Combo(("##_audio_dev_0_"+ name).c_str(), &stream->deviceId, stream->audio->devTxtList.c_str())) {
|
||||
audio::stopStream(name);
|
||||
audio::setAudioDevice(name, stream->deviceId, stream->audio->devices[deviceId].sampleRates[0]);
|
||||
if (running) {
|
||||
audio::startStream(name);
|
||||
}
|
||||
stream->sampleRateId = 0;
|
||||
|
||||
// Create config if it doesn't exist
|
||||
core::configManager.aquire();
|
||||
if (!core::configManager.conf["audio"].contains(name)) {
|
||||
saveAudioConfig(name);
|
||||
}
|
||||
core::configManager.conf["audio"][name]["device"] = stream->audio->deviceNames[stream->deviceId];
|
||||
core::configManager.conf["audio"][name]["sampleRate"] = stream->audio->devices[stream->deviceId].sampleRates[0];
|
||||
core::configManager.release(true);
|
||||
}
|
||||
if (ImGui::Combo(("##_audio_sr_0_" + name).c_str(), &stream->sampleRateId, stream->audio->devices[deviceId].txtSampleRates.c_str())) {
|
||||
audio::stopStream(name);
|
||||
audio::setSampleRate(name, stream->audio->devices[deviceId].sampleRates[stream->sampleRateId]);
|
||||
if (running) {
|
||||
audio::startStream(name);
|
||||
}
|
||||
|
||||
// Create config if it doesn't exist
|
||||
core::configManager.aquire();
|
||||
if (!core::configManager.conf["audio"].contains(name)) {
|
||||
saveAudioConfig(name);
|
||||
}
|
||||
core::configManager.conf["audio"][name]["sampleRate"] = stream->audio->devices[deviceId].sampleRates[stream->sampleRateId];
|
||||
core::configManager.release(true);
|
||||
}
|
||||
if (ImGui::SliderFloat(("##_audio_vol_0_" + name).c_str(), &stream->volume, 0.0f, 1.0f, "")) {
|
||||
stream->audio->setVolume(stream->volume);
|
||||
|
||||
// Create config if it doesn't exist
|
||||
core::configManager.aquire();
|
||||
if (!core::configManager.conf["audio"].contains(name)) {
|
||||
saveAudioConfig(name);
|
||||
}
|
||||
core::configManager.conf["audio"][name]["volume"] = stream->volume;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
count++;
|
||||
if (count < maxCount) {
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
ImGui::Spacing();
|
||||
}
|
||||
ImGui::Spacing();
|
||||
}
|
||||
};
|
6
core/src/gui/menus/audio.h
Normal file
6
core/src/gui/menus/audio.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace audiomenu {
|
||||
void init();
|
||||
void draw(void* ctx);
|
||||
};
|
52
core/src/gui/menus/bandplan.cpp
Normal file
52
core/src/gui/menus/bandplan.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include <gui/menus/bandplan.h>
|
||||
#include <gui/bandplan.h>
|
||||
#include <gui/gui.h>
|
||||
#include <core.h>
|
||||
|
||||
namespace bandplanmenu {
|
||||
int bandplanId;
|
||||
bool bandPlanEnabled;
|
||||
|
||||
void init() {
|
||||
// todo: check if the bandplan wasn't removed
|
||||
if (bandplan::bandplanNames.size() == 0) {
|
||||
gui::waterfall.hideBandplan();
|
||||
return;
|
||||
}
|
||||
|
||||
if (bandplan::bandplans.find(core::configManager.conf["bandPlan"]) != bandplan::bandplans.end()) {
|
||||
std::string name = core::configManager.conf["bandPlan"];
|
||||
bandplanId = std::distance(bandplan::bandplanNames.begin(), std::find(bandplan::bandplanNames.begin(),
|
||||
bandplan::bandplanNames.end(), name));
|
||||
gui::waterfall.bandplan = &bandplan::bandplans[name];
|
||||
}
|
||||
else {
|
||||
gui::waterfall.bandplan = &bandplan::bandplans[bandplan::bandplanNames[0]];
|
||||
}
|
||||
|
||||
bandPlanEnabled = core::configManager.conf["bandPlanEnabled"];
|
||||
bandPlanEnabled ? gui::waterfall.showBandplan() : gui::waterfall.hideBandplan();
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvailWidth();
|
||||
ImGui::PushItemWidth(menuColumnWidth);
|
||||
if (ImGui::Combo("##_4_", &bandplanId, bandplan::bandplanNameTxt.c_str())) {
|
||||
gui::waterfall.bandplan = &bandplan::bandplans[bandplan::bandplanNames[bandplanId]];
|
||||
core::configManager.aquire();
|
||||
core::configManager.conf["bandPlan"] = bandplan::bandplanNames[bandplanId];
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
if (ImGui::Checkbox("Enabled", &bandPlanEnabled)) {
|
||||
bandPlanEnabled ? gui::waterfall.showBandplan() : gui::waterfall.hideBandplan();
|
||||
core::configManager.aquire();
|
||||
core::configManager.conf["bandPlanEnabled"] = bandPlanEnabled;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
bandplan::BandPlan_t plan = bandplan::bandplans[bandplan::bandplanNames[bandplanId]];
|
||||
ImGui::Text("Country: %s (%s)", plan.countryName.c_str(), plan.countryCode.c_str());
|
||||
ImGui::Text("Author: %s", plan.authorName.c_str());
|
||||
ImGui::Spacing();
|
||||
}
|
||||
};
|
6
core/src/gui/menus/bandplan.h
Normal file
6
core/src/gui/menus/bandplan.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace bandplanmenu {
|
||||
void init();
|
||||
void draw(void* ctx);
|
||||
};
|
23
core/src/gui/menus/display.cpp
Normal file
23
core/src/gui/menus/display.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <gui/menus/display.h>
|
||||
#include <imgui.h>
|
||||
#include <gui/gui.h>
|
||||
#include <core.h>
|
||||
|
||||
namespace displaymenu {
|
||||
bool showWaterfall;
|
||||
|
||||
void init() {
|
||||
showWaterfall = core::configManager.conf["showWaterfall"];
|
||||
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
if (ImGui::Checkbox("Show Waterfall", &showWaterfall)) {
|
||||
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
||||
core::configManager.aquire();
|
||||
core::configManager.conf["showWaterfall"] = showWaterfall;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::Spacing();
|
||||
}
|
||||
}
|
6
core/src/gui/menus/display.h
Normal file
6
core/src/gui/menus/display.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace displaymenu {
|
||||
void init();
|
||||
void draw(void* ctx);
|
||||
}
|
11
core/src/gui/menus/source.cpp
Normal file
11
core/src/gui/menus/source.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <gui/menus/source.h>
|
||||
|
||||
namespace sourecmenu {
|
||||
void init() {
|
||||
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
|
||||
}
|
||||
}
|
6
core/src/gui/menus/source.h
Normal file
6
core/src/gui/menus/source.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace sourecmenu {
|
||||
void init();
|
||||
void draw(void* ctx);
|
||||
}
|
@ -441,7 +441,7 @@ namespace ImGui {
|
||||
drawWaterfall();
|
||||
}
|
||||
drawVFOs();
|
||||
if (bandplan != NULL) {
|
||||
if (bandplan != NULL && bandplanVisible) {
|
||||
drawBandPlan();
|
||||
}
|
||||
|
||||
@ -780,5 +780,13 @@ namespace ImGui {
|
||||
int WaterFall::getFFTHeight() {
|
||||
return FFTAreaHeight;
|
||||
}
|
||||
|
||||
void WaterFall::showBandplan() {
|
||||
bandplanVisible = true;
|
||||
}
|
||||
|
||||
void WaterFall::hideBandplan() {
|
||||
bandplanVisible = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -91,6 +91,9 @@ namespace ImGui {
|
||||
void showWaterfall();
|
||||
void hideWaterfall();
|
||||
|
||||
void showBandplan();
|
||||
void hideBandplan();
|
||||
|
||||
void setFFTHeight(int height);
|
||||
int getFFTHeight();
|
||||
|
||||
@ -187,5 +190,6 @@ namespace ImGui {
|
||||
int newFFTAreaHeight;
|
||||
|
||||
bool waterfallVisible = true;
|
||||
bool bandplanVisible = false;
|
||||
};
|
||||
};
|
@ -8,7 +8,7 @@
|
||||
"Radio 1": {
|
||||
"device": "Speakers (Realtek High Definiti",
|
||||
"sampleRate": 48000.0,
|
||||
"volume": 0.6881720423698425
|
||||
"volume": 0.4185185134410858
|
||||
},
|
||||
"Radio 2": {
|
||||
"device": "Speakers (Realtek High Definiti",
|
||||
@ -25,7 +25,7 @@
|
||||
"menuWidth": 300,
|
||||
"min": -51.47058868408203,
|
||||
"showWaterfall": true,
|
||||
"source": "HackRF One #0 901868dc282c8f8b",
|
||||
"source": "Generic RTL2832U OEM :: 00000001",
|
||||
"sourceSettings": {
|
||||
"Generic RTL2832U OEM :: 00000001": {
|
||||
"gains": {
|
||||
|
Loading…
Reference in New Issue
Block a user