mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-28 21:37:50 +02:00
fix
This commit is contained in:
@ -18,7 +18,6 @@
|
||||
#include <watcher.h>
|
||||
#include <module.h>
|
||||
#include <signal_path/vfo_manager.h>
|
||||
#include <signal_path/audio.h>
|
||||
#include <gui/style.h>
|
||||
#include <config.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
@ -27,7 +26,6 @@
|
||||
#include <gui/menus/display.h>
|
||||
#include <gui/menus/bandplan.h>
|
||||
#include <gui/menus/sink.h>
|
||||
#include <gui/menus/audio.h>
|
||||
#include <gui/menus/scripting.h>
|
||||
#include <gui/dialogs/credits.h>
|
||||
#include <signal_path/source.h>
|
||||
@ -68,8 +66,6 @@ void fftHandler(dsp::complex_t* samples, int count, void* ctx) {
|
||||
|
||||
watcher<uint64_t> freq((uint64_t)90500000);
|
||||
watcher<double> vfoFreq(92000000.0);
|
||||
float dummyVolume = 1.0;
|
||||
float* volume = &dummyVolume;
|
||||
float fftMin = -70.0;
|
||||
float fftMax = 0.0;
|
||||
watcher<double> offset(0.0, true);
|
||||
@ -97,7 +93,6 @@ void windowInit() {
|
||||
|
||||
gui::menu.registerEntry("Source", sourecmenu::draw, NULL);
|
||||
gui::menu.registerEntry("Sinks", sinkmenu::draw, NULL);
|
||||
gui::menu.registerEntry("Audio", audiomenu::draw, NULL);
|
||||
gui::menu.registerEntry("Scripting", scriptingmenu::draw, NULL);
|
||||
gui::menu.registerEntry("Band Plan", bandplanmenu::draw, NULL);
|
||||
gui::menu.registerEntry("Display", displaymenu::draw, NULL);
|
||||
@ -120,7 +115,6 @@ void windowInit() {
|
||||
|
||||
sourecmenu::init();
|
||||
sinkmenu::init();
|
||||
audiomenu::init();
|
||||
scriptingmenu::init();
|
||||
bandplanmenu::init();
|
||||
displaymenu::init();
|
||||
@ -271,10 +265,6 @@ void drawWindow() {
|
||||
gui::waterfall.selectedVFOChanged = false;
|
||||
gui::freqSelect.setFrequency(vfo->generalOffset + gui::waterfall.getCenterFrequency());
|
||||
gui::freqSelect.frequencyChanged = false;
|
||||
audioStreamName = audio::getNameFromVFO(gui::waterfall.selectedVFO);
|
||||
if (audioStreamName != "") {
|
||||
volume = &audio::streams[audioStreamName]->volume;
|
||||
}
|
||||
core::configManager.aquire();
|
||||
core::configManager.conf["frequency"] = gui::freqSelect.frequency;
|
||||
core::configManager.release(true);
|
||||
@ -339,19 +329,7 @@ void drawWindow() {
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 8);
|
||||
ImGui::SetNextItemWidth(200);
|
||||
if (ImGui::SliderFloat("##_2_", volume, 0.0, 1.0, "")) {
|
||||
if (audioStreamName != "") {
|
||||
core::configManager.aquire();
|
||||
if (!core::configManager.conf["audio"].contains(audioStreamName)) {
|
||||
//saveAudioConfig(audioStreamName);
|
||||
// TODO: FIX THIS SHIT
|
||||
}
|
||||
audio::streams[audioStreamName]->audio->setVolume(*volume);
|
||||
core::configManager.conf["audio"][audioStreamName]["volume"] = *volume;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
}
|
||||
sigpath::sinkManager.showVolumeSlider(gui::waterfall.selectedVFO, "##_sdrpp_main_volume_", 200);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
|
@ -1,138 +0,0 @@
|
||||
#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("%s", 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();
|
||||
}
|
||||
}
|
||||
};
|
@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace audiomenu {
|
||||
void init();
|
||||
void draw(void* ctx);
|
||||
};
|
@ -1,9 +1,12 @@
|
||||
#include <gui/menus/sink.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
#include <core.h>
|
||||
|
||||
namespace sinkmenu {
|
||||
void init() {
|
||||
|
||||
core::configManager.aquire();
|
||||
sigpath::sinkManager.loadSinksFromConfig();
|
||||
core::configManager.release();
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
|
@ -9,12 +9,21 @@ namespace sourecmenu {
|
||||
double freqOffset = 0.0;
|
||||
|
||||
void init() {
|
||||
// Select default
|
||||
// TODO: Replace by setting
|
||||
if (sigpath::sourceManager.sourceNames.size() > 0) {
|
||||
core::configManager.aquire();
|
||||
std::string name = core::configManager.conf["source"];
|
||||
auto it = std::find(sigpath::sourceManager.sourceNames.begin(), sigpath::sourceManager.sourceNames.end(), name);
|
||||
if (it != sigpath::sourceManager.sourceNames.end()) {
|
||||
sigpath::sourceManager.selectSource(name);
|
||||
sourceId = std::distance(sigpath::sourceManager.sourceNames.begin(), it);
|
||||
}
|
||||
else if (sigpath::sourceManager.sourceNames.size() > 0) {
|
||||
sigpath::sourceManager.selectSource(sigpath::sourceManager.sourceNames[0]);
|
||||
}
|
||||
sigpath::sourceManager.setTuningOffset(0);
|
||||
else {
|
||||
spdlog::warn("No source available...");
|
||||
}
|
||||
sigpath::sourceManager.setTuningOffset(core::configManager.conf["offset"]);
|
||||
core::configManager.release();
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
@ -28,12 +37,18 @@ namespace sourecmenu {
|
||||
ImGui::SetNextItemWidth(itemWidth);
|
||||
if (ImGui::Combo("##source", &sourceId, items.c_str())) {
|
||||
sigpath::sourceManager.selectSource(sigpath::sourceManager.sourceNames[sourceId]);
|
||||
core::configManager.aquire();
|
||||
core::configManager.conf["source"] = sigpath::sourceManager.sourceNames[sourceId];
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
sigpath::sourceManager.showSelectedMenu();
|
||||
ImGui::SetNextItemWidth(itemWidth - ImGui::CalcTextSize("Offset (Hz)").x - 10);
|
||||
if (ImGui::InputDouble("Offset (Hz)##freq_offset", &freqOffset, 1.0, 100.0)) {
|
||||
sigpath::sourceManager.setTuningOffset(freqOffset);
|
||||
core::configManager.aquire();
|
||||
core::configManager.conf["offset"] = freqOffset;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user