Skip to content

Commit

Permalink
Merge pull request #594 from cjcliffe/audio_recording
Browse files Browse the repository at this point in the history
Audio recording
  • Loading branch information
cjcliffe authored Jan 15, 2018
2 parents 7b904bf + 7588e77 commit 7fb66b6
Show file tree
Hide file tree
Showing 29 changed files with 2,277 additions and 656 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")

SET(CUBICSDR_VERSION_MAJOR "0")
SET(CUBICSDR_VERSION_MINOR "2")
SET(CUBICSDR_VERSION_PATCH "2")
SET(CUBICSDR_VERSION_PATCH "3")
SET(CUBICSDR_VERSION_SUFFIX "")
SET(CUBICSDR_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}${CUBICSDR_VERSION_SUFFIX}")

Expand Down Expand Up @@ -347,6 +347,10 @@ SET (cubicsdr_sources
src/modules/modem/analog/ModemLSB.cpp
src/modules/modem/analog/ModemUSB.cpp
src/audio/AudioThread.cpp
src/audio/AudioSinkThread.cpp
src/audio/AudioSinkFileThread.cpp
src/audio/AudioFile.cpp
src/audio/AudioFileWAV.cpp
src/util/Gradient.cpp
src/util/Timer.cpp
src/util/MouseTracker.cpp
Expand Down Expand Up @@ -451,6 +455,10 @@ SET (cubicsdr_headers
src/modules/modem/analog/ModemLSB.h
src/modules/modem/analog/ModemUSB.h
src/audio/AudioThread.h
src/audio/AudioSinkThread.h
src/audio/AudioSinkFileThread.h
src/audio/AudioFile.h
src/audio/AudioFileWAV.h
src/util/Gradient.h
src/util/Timer.h
src/util/ThreadBlockingQueue.h
Expand Down Expand Up @@ -995,7 +1003,7 @@ IF (WIN32 AND BUILD_INSTALLER)

IF (MSVC)
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/external/msvc/${EX_PLATFORM_NAME}/vc_redist.${EX_PLATFORM_NAME}.exe DESTINATION vc_redist)
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '\\\"$INSTDIR\\\\vc_redist\\\\vc_redist.${EX_PLATFORM_NAME}.exe\\\" /q:a'")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '\\\"$INSTDIR\\\\vc_redist\\\\vc_redist.${EX_PLATFORM_NAME}.exe\\\" /passive /norestart'")
ENDIF (MSVC)


Expand Down
73 changes: 73 additions & 0 deletions src/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "AppConfig.h"
#include "CubicSDR.h"

#include <wx/msgdlg.h>

DeviceConfig::DeviceConfig() : deviceId("") {
ppm.store(0);
offset.store(0);
Expand Down Expand Up @@ -505,6 +507,51 @@ bool AppConfig::getBookmarksVisible() {
return bookmarksVisible.load();
}

void AppConfig::setRecordingPath(std::string recPath) {
recordingPath = recPath;
}

std::string AppConfig::getRecordingPath() {
return recordingPath;
}

bool AppConfig::verifyRecordingPath() {
string recPathStr = wxGetApp().getConfig()->getRecordingPath();

if (recPathStr.empty()) {
wxMessageBox( wxT("Recording path is not set. Please use 'Set Recording Path' from the 'File' Menu."), wxT("Recording Path Error"), wxICON_INFORMATION);

return false;
}

wxFileName recPath(recPathStr);

if (!recPath.Exists() || !recPath.IsDirWritable()) {
wxMessageBox( wxT("Recording path does not exist or is not writable. Please use 'Set Recording Path' from the 'File' Menu."), wxT("Recording Path Error"), wxICON_INFORMATION);

return false;
}

return true;
}


void AppConfig::setRecordingSquelchOption(int enumChoice) {
recordingSquelchOption = enumChoice;
}

int AppConfig::getRecordingSquelchOption() {
return recordingSquelchOption;
}

void AppConfig::setRecordingFileTimeLimit(int nbSeconds) {
recordingFileTimeLimitSeconds = nbSeconds;
}

int AppConfig::getRecordingFileTimeLimit() {
return recordingFileTimeLimitSeconds;
}


void AppConfig::setConfigName(std::string configName) {
this->configName = configName;
Expand Down Expand Up @@ -559,6 +606,12 @@ bool AppConfig::save() {
*window_node->newChild("bookmark_visible") = bookmarksVisible.load();
}

//Recording settings:
DataNode *rec_node = cfg.rootNode()->newChild("recording");
*rec_node->newChild("path") = recordingPath;
*rec_node->newChild("squelch") = recordingSquelchOption;
*rec_node->newChild("file_time_limit") = recordingFileTimeLimitSeconds;

DataNode *devices_node = cfg.rootNode()->newChild("devices");

std::map<std::string, DeviceConfig *>::iterator device_config_i;
Expand Down Expand Up @@ -741,6 +794,26 @@ bool AppConfig::load() {
}
}

//Recording settings:
if (cfg.rootNode()->hasAnother("recording")) {
DataNode *rec_node = cfg.rootNode()->getNext("recording");

if (rec_node->hasAnother("path")) {
DataNode *rec_path = rec_node->getNext("path");
recordingPath = rec_path->element()->toString();
}

if (rec_node->hasAnother("squelch")) {
DataNode *rec_squelch = rec_node->getNext("squelch");
rec_squelch->element()->get(recordingSquelchOption);
}

if (rec_node->hasAnother("file_time_limit")) {
DataNode *rec_file_time_limit = rec_node->getNext("file_time_limit");
rec_file_time_limit->element()->get(recordingFileTimeLimitSeconds);
}
}

if (cfg.rootNode()->hasAnother("devices")) {
DataNode *devices_node = cfg.rootNode()->getNext("devices");

Expand Down
14 changes: 14 additions & 0 deletions src/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ class AppConfig {
void setBookmarksVisible(bool state);
bool getBookmarksVisible();

//Recording settings:
void setRecordingPath(std::string recPath);
std::string getRecordingPath();
bool verifyRecordingPath();

void setRecordingSquelchOption(int enumChoice);
int getRecordingSquelchOption();

void setRecordingFileTimeLimit(int nbSeconds);
int getRecordingFileTimeLimit();

#if USE_HAMLIB
int getRigModel();
Expand Down Expand Up @@ -185,6 +195,10 @@ class AppConfig {
std::atomic_int dbOffset;
std::vector<SDRManualDef> manualDevices;
std::atomic_bool bookmarksVisible;

std::string recordingPath = "";
int recordingSquelchOption = 0;
int recordingFileTimeLimitSeconds = 0;
#if USE_HAMLIB
std::atomic_int rigModel, rigRate;
std::string rigPort;
Expand Down
Loading

0 comments on commit 7fb66b6

Please sign in to comment.