diff --git a/.gitignore b/.gitignore index 67e50798..12cbce30 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ build/ .vscode/ -*.old \ No newline at end of file +*.old +*.dll +*.exe \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 58be071e..9b95e1d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.9) project(sdrpp) +add_subdirectory("modules/radio") +add_subdirectory("modules/recorder") + if (MSVC) set(CMAKE_CXX_FLAGS "-O2 /std:c++17") link_directories(sdrpp "C:/Program Files/PothosSDR/lib/") @@ -38,7 +41,6 @@ if (MSVC) endif (MSVC) add_executable(sdrpp ${SRC} ${IMGUI}) -# add_library(sdrpp ${SRC} ${IMGUI}) if (MSVC) # Glew @@ -60,10 +62,4 @@ if (MSVC) target_link_libraries(sdrpp PRIVATE portaudio portaudio_static) endif (MSVC) -# # Copy resource directories -# if (!MSVC) -# add_custom_command(TARGET sdrpp POST_BUILD COMMAND cmake -E copy_directory ${CMAKE_SOURCE_DIR}/res ${CMAKE_BINARY_DIR}/res) -# add_custom_command(TARGET sdrpp POST_BUILD COMMAND cmake -E copy_directory ${CMAKE_SOURCE_DIR}/bandplans ${CMAKE_BINARY_DIR}/bandplans) -# endif (MSVC) - # cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/Users/Alex/vcpkg/scripts/buildsystems/vcpkg.cmake" -G "Visual Studio 15 2017 Win64" \ No newline at end of file diff --git a/module_list.json b/module_list.json deleted file mode 100644 index 96a6dd79..00000000 --- a/module_list.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Radio": "../modules/radio/build/Release/radio.dll" -} \ No newline at end of file diff --git a/modules/demo/CMakeLists.txt b/modules/demo/CMakeLists.txt index 1b8ac869..25e29d07 100644 --- a/modules/demo/CMakeLists.txt +++ b/modules/demo/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories(demo "../../src/imgui") file(GLOB SRC "src/*.cpp") file(GLOB IMGUI "../../src/imgui/*.cpp") add_library(demo SHARED ${SRC} ${IMGUI}) -set_target_properties(demo PROPERTIES OUTPUT_NAME demo) +set_target_properties(demo PROPERTIES PREFIX "") if (MSVC) # Glew diff --git a/modules/demo/src/main.cpp b/modules/demo/src/main.cpp index f6892fe0..d22f6377 100644 --- a/modules/demo/src/main.cpp +++ b/modules/demo/src/main.cpp @@ -1,26 +1,38 @@ #include #include +#include +#include +#include +#include +#include +#include mod::API_t* API; -struct DemoContext_t { +struct ExampleContext_t { std::string name; }; MOD_EXPORT void* _INIT_(mod::API_t* _API, ImGuiContext* imctx, std::string _name) { API = _API; - DemoContext_t* ctx = new DemoContext_t; + ExampleContext_t* ctx = new ExampleContext_t; ctx->name = _name; ImGui::SetCurrentContext(imctx); return ctx; } -MOD_EXPORT void _DRAW_MENU_(DemoContext_t* ctx) { - char buf[100]; - sprintf(buf, "I'm %s", ctx->name.c_str()); - ImGui::Button(buf); +MOD_EXPORT void _NEW_FRAME_(ExampleContext_t* ctx) { + } -MOD_EXPORT void _STOP_(DemoContext_t* ctx) { - delete ctx; +MOD_EXPORT void _DRAW_MENU_(ExampleContext_t* ctx) { + ImGui::Text("Demo!"); +} + +MOD_EXPORT void _HANDLE_EVENT_(ExampleContext_t* ctx, int eventId) { + +} + +MOD_EXPORT void _STOP_(ExampleContext_t* ctx) { + } \ No newline at end of file diff --git a/modules/radio/CMakeLists.txt b/modules/radio/CMakeLists.txt index 1543b210..fb00414f 100644 --- a/modules/radio/CMakeLists.txt +++ b/modules/radio/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories(radio "../../src/imgui") file(GLOB SRC "src/*.cpp") file(GLOB IMGUI "../../src/imgui/*.cpp") add_library(radio SHARED ${SRC} ${IMGUI}) -set_target_properties(radio PROPERTIES OUTPUT_NAME radio) +set_target_properties(radio PROPERTIES PREFIX "") if (MSVC) # Glew diff --git a/modules/recorder/CMakeLists.txt b/modules/recorder/CMakeLists.txt index e55e9f0d..32791d6e 100644 --- a/modules/recorder/CMakeLists.txt +++ b/modules/recorder/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories(recorder "../../src/imgui") file(GLOB SRC "src/*.cpp") file(GLOB IMGUI "../../src/imgui/*.cpp") add_library(recorder SHARED ${SRC} ${IMGUI}) -set_target_properties(recorder PROPERTIES OUTPUT_NAME recorder) +set_target_properties(recorder PROPERTIES PREFIX "") if (MSVC) # Glew diff --git a/prepare_root.bat b/prepare_root.bat new file mode 100644 index 00000000..b78a1ee3 --- /dev/null +++ b/prepare_root.bat @@ -0,0 +1,3 @@ +echo OFF +copy /b/v/y build\modules\radio\Release\radio.dll root\modules\radio.dll +copy /b/v/y build\modules\recorder\Release\recorder.dll root\modules\recorder.dll diff --git a/prepare_root.sh b/prepare_root.sh new file mode 100644 index 00000000..6f19402b --- /dev/null +++ b/prepare_root.sh @@ -0,0 +1,2 @@ +cp modules/radio/build/radio.so root/modules/radio.so +cp modules/recorder/build/recorder.so root/modules/recorder.so \ No newline at end of file diff --git a/res/icons/menu_raw.png b/res/icons/menu_raw.png deleted file mode 100644 index f1c132e0..00000000 Binary files a/res/icons/menu_raw.png and /dev/null differ diff --git a/res/icons/play_raw.png b/res/icons/play_raw.png deleted file mode 100644 index 61bfb8bc..00000000 Binary files a/res/icons/play_raw.png and /dev/null differ diff --git a/res/icons/stop.png b/res/icons/stop.png deleted file mode 100644 index 366651bf..00000000 Binary files a/res/icons/stop.png and /dev/null differ diff --git a/res/icons/stop_raw.png b/res/icons/stop_raw.png deleted file mode 100644 index 7d22d91e..00000000 Binary files a/res/icons/stop_raw.png and /dev/null differ diff --git a/band_colors.json b/root/band_colors.json similarity index 100% rename from band_colors.json rename to root/band_colors.json diff --git a/bandplans/general.json b/root/bandplans/general.json similarity index 100% rename from bandplans/general.json rename to root/bandplans/general.json diff --git a/bandplans/germany.json b/root/bandplans/germany.json similarity index 100% rename from bandplans/germany.json rename to root/bandplans/germany.json diff --git a/bandplans/russia.json b/root/bandplans/russia.json similarity index 100% rename from bandplans/russia.json rename to root/bandplans/russia.json diff --git a/config.json b/root/config.json similarity index 94% rename from config.json rename to root/config.json index e2017a54..38300a17 100644 --- a/config.json +++ b/root/config.json @@ -1,18 +1,18 @@ -{ - "audio": {}, - "bandPlan": "General", - "bandPlanEnabled": true, - "fftHeight": 300, - "frequency": 99000000, - "max": 0.0, - "maximized": false, - "menuWidth": 300, - "min": -70.0, - "showWaterfall": true, - "source": "", - "sourceSettings": {}, - "windowSize": { - "h": 720, - "w": 1280 - } +{ + "audio": {}, + "bandPlan": "General", + "bandPlanEnabled": true, + "fftHeight": 300, + "frequency": 99000000, + "max": 0.0, + "maximized": false, + "menuWidth": 300, + "min": -70.0, + "showWaterfall": true, + "source": "", + "sourceSettings": {}, + "windowSize": { + "h": 720, + "w": 1280 + } } \ No newline at end of file diff --git a/root/module_list.json b/root/module_list.json new file mode 100644 index 00000000..f7d192fd --- /dev/null +++ b/root/module_list.json @@ -0,0 +1,4 @@ +{ + "Radio": "./modules/radio.dll", + "Recorder": "./modules/recorder.dll" +} \ No newline at end of file diff --git a/root/modules/.gitkeep b/root/modules/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/root/recordings/.gitkeep b/root/recordings/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/res/fonts/Roboto-Medium.ttf b/root/res/fonts/Roboto-Medium.ttf similarity index 100% rename from res/fonts/Roboto-Medium.ttf rename to root/res/fonts/Roboto-Medium.ttf diff --git a/res/icons/menu.png b/root/res/icons/menu.png similarity index 100% rename from res/icons/menu.png rename to root/res/icons/menu.png diff --git a/res/icons/play.png b/root/res/icons/play.png similarity index 100% rename from res/icons/play.png rename to root/res/icons/play.png diff --git a/res/icons/sdrpp.ico b/root/res/icons/sdrpp.ico similarity index 100% rename from res/icons/sdrpp.ico rename to root/res/icons/sdrpp.ico diff --git a/res/icons/sdrpp.png b/root/res/icons/sdrpp.png similarity index 100% rename from res/icons/sdrpp.png rename to root/res/icons/sdrpp.png diff --git a/root/sdrpp.zip b/root/sdrpp.zip new file mode 100644 index 00000000..b3e65f4b Binary files /dev/null and b/root/sdrpp.zip differ diff --git a/src/config.cpp b/src/config.cpp index 1766fe38..6c46dde4 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -6,6 +6,7 @@ namespace config { bool autoSaveRunning = false; std::string _path; std::thread _workerThread; + std::string rootDir; void _autoSaveWorker() { while (autoSaveRunning) { @@ -50,4 +51,12 @@ namespace config { autoSaveRunning = false; _workerThread.join(); } + + void setRootDirectory(std::string dir) { + rootDir = dir; + } + + std::string getRootDirectory() { + return rootDir; + } }; \ No newline at end of file diff --git a/src/config.h b/src/config.h index 4dd3292b..da6b0ee0 100644 --- a/src/config.h +++ b/src/config.h @@ -14,6 +14,8 @@ namespace config { void load(std::string path); void startAutoSave(); void stopAutoSave(); + void setRootDirectory(std::string dir); + std::string getRootDirectory(); extern bool configModified; extern json config; diff --git a/src/icons.cpp b/src/icons.cpp index d1a93520..f80ff61b 100644 --- a/src/icons.cpp +++ b/src/icons.cpp @@ -9,9 +9,9 @@ namespace icons { ImTextureID STOP; ImTextureID MENU; - GLuint loadTexture(char* path) { + GLuint loadTexture(std::string path) { int w,h,n; - stbi_uc* data = stbi_load(path, &w, &h, &n, NULL); + stbi_uc* data = stbi_load(path.c_str(), &w, &h, &n, NULL); GLuint texId; glGenTextures(1, &texId); glBindTexture(GL_TEXTURE_2D, texId); @@ -24,9 +24,9 @@ namespace icons { } void load() { - LOGO = (ImTextureID)loadTexture("res/icons/sdrpp.png"); - PLAY = (ImTextureID)loadTexture("res/icons/play.png"); - STOP = (ImTextureID)loadTexture("res/icons/stop.png"); - MENU = (ImTextureID)loadTexture("res/icons/menu.png"); + LOGO = (ImTextureID)loadTexture(config::getRootDirectory() + "/res/icons/sdrpp.png"); + PLAY = (ImTextureID)loadTexture(config::getRootDirectory() + "/res/icons/play.png"); + STOP = (ImTextureID)loadTexture(config::getRootDirectory() + "/res/icons/stop.png"); + MENU = (ImTextureID)loadTexture(config::getRootDirectory() + "/res/icons/menu.png"); } } \ No newline at end of file diff --git a/src/icons.h b/src/icons.h index 2f886d23..7595682a 100644 --- a/src/icons.h +++ b/src/icons.h @@ -2,6 +2,7 @@ #include #include #include +#include namespace icons { extern ImTextureID LOGO; diff --git a/src/io/soapy.h b/src/io/soapy.h index 3be8f102..f72f5c9d 100644 --- a/src/io/soapy.h +++ b/src/io/soapy.h @@ -11,6 +11,8 @@ namespace io { public: SoapyWrapper() { SoapySDR::registerLogHandler(_logHandler); + SoapySDR::Device::make(""); + output.init(64000); currentGains = new float[1]; refresh(); diff --git a/src/main.cpp b/src/main.cpp index a77d9c1d..243bd839 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,9 +44,15 @@ int main() { spdlog::info("SDR++ v" VERSION_STR); +#ifdef _WIN32 + config::setRootDirectory("."); +#else + config::setRootDirectory("/etc/sdrpp"); +#endif + // Load config spdlog::info("Loading config"); - config::load("config.json"); + config::load(config::getRootDirectory() + "/config.json"); config::startAutoSave(); // Setup window @@ -80,7 +86,7 @@ int main() { // Load app icon GLFWimage icons[10]; - icons[0].pixels = stbi_load("res/icons/sdrpp.png", &icons[0].width, &icons[0].height, 0, 4); + icons[0].pixels = stbi_load((config::getRootDirectory() + "/res/icons/sdrpp.png").c_str(), &icons[0].width, &icons[0].height, 0, 4); icons[1].pixels = (unsigned char*)malloc(16 * 16 * 4); icons[1].width = icons[1].height = 16; icons[2].pixels = (unsigned char*)malloc(24 * 24 * 4); icons[2].width = icons[2].height = 24; icons[3].pixels = (unsigned char*)malloc(32 * 32 * 4); icons[3].width = icons[3].height = 32; @@ -127,10 +133,10 @@ int main() { icons::load(); spdlog::info("Loading band plans"); - bandplan::loadFromDir("bandplans"); + bandplan::loadFromDir(config::getRootDirectory() + "/bandplans"); spdlog::info("Loading band plans color table"); - bandplan::loadColorTable("band_colors.json"); + bandplan::loadColorTable(config::getRootDirectory() + "/band_colors.json"); windowInit(); diff --git a/src/main_window.cpp b/src/main_window.cpp index 90c42032..3360780e 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -170,9 +170,9 @@ void windowInit() { spdlog::info("Loading modules"); mod::initAPI(&wtf); - mod::loadFromList("module_list.json"); + mod::loadFromList(config::getRootDirectory() + "/module_list.json"); - bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF("res/fonts/Roboto-Medium.ttf", 128.0f); + bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF((config::getRootDirectory() + "/res/fonts/Roboto-Medium.ttf").c_str(), 128.0f); // Load last source configuration uint64_t frequency = config::config["frequency"]; @@ -214,13 +214,10 @@ void windowInit() { // Finish the recorder module // Add squelsh // Bandwidth ajustment - // DSB / CW and RAW modes; + // CW and RAW modes; // Bring VFO to a visible place when changing sample rate if it's smaller - // Have a proper root directory - // Fix issue of source name not set when source was not selected manually - // Generate entire source config before saving a source property - // ^ same for audio devices + // Have a proper root directory // And a module add/remove/change order menu // get rid of watchers and use if() instead diff --git a/win32/resources.rc b/win32/resources.rc index 6e89f0fc..c29a6c48 100644 --- a/win32/resources.rc +++ b/win32/resources.rc @@ -1 +1 @@ -IDR_MAINFRAME ICON "../res/icons/sdrpp.ico" \ No newline at end of file +IDR_MAINFRAME ICON "../root/res/icons/sdrpp.ico" \ No newline at end of file