Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI String lookup class #110

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if(UNIX)
endif()
include(check_nng)
find_package(nng REQUIRED QUIET)
find_package(fmt REQUIRED QUIET)
add_subdirectory(submodules)

set(EPS_SHARED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/shared)
Expand Down
7 changes: 4 additions & 3 deletions ear-production-suite-plugins/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,14 @@ target_link_libraries(ear-plugin-base PUBLIC
Boost::boost
protobuf::libprotobuf
nng::nng
fmt::fmt
spdlog::spdlog
bw64
adm
Eigen3::Eigen)
if(SPDLOG_FMT_EXTERNAL)
target_link_libraries(ear-plugin-base PUBLIC fmt::fmt)
endif()

target_compile_definitions(ear-plugin-base PUBLIC
SPDLOG_FMT_EXTERNAL)

target_include_directories(ear-plugin-base PUBLIC
# Headers used from source/build location:
Expand Down
3 changes: 3 additions & 0 deletions reaper-adm-extension/src/reaper_adm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ set(EXTENSION_SOURCES
reaperguid.cpp
reaperhost.cpp
track.cpp
ui_text.cpp
coordinate_conversion/coord_conv.cpp
progress/importdialog.cpp
progress/importlistener.cpp
Expand Down Expand Up @@ -142,6 +143,7 @@ set(EXTENSION_HEADERS
reaper_plugin_functions.h
resource.h
track.h
ui_text.h
win_mem_debug.h
win_nonblock_msg.h
coordinate_conversion/coord_conv.cpp
Expand Down Expand Up @@ -198,6 +200,7 @@ target_include_directories(reaper_adm_object
target_link_libraries(reaper_adm_dependencies
INTERFACE
$<TARGET_OBJECTS:reaper_adm_object>
fmt::fmt
IRT::bw64
adm
WDL::swell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "exportaction_admsource-admvst.h"
#include "exportaction_admsource-earvst.h"
#include "ui_text.h"

void AdmExportHandler::repopulate(ReaperAPI const & api)
{
Expand Down Expand Up @@ -47,12 +48,12 @@ std::vector<std::string> AdmExportHandler::generateExportErrorStrings()
std::vector<std::string> msgs;

if(!admExportSources) {
msgs.push_back(std::string("No Valid Export Sources!"));
msgs.push_back(eps::uiText(eps::TextID::EXPORT_HANDLER_ERROR_NO_VALID_SOURCES));
}

if(admExportSources) {
if (admExportSources->getTotalExportChannels() == 0) {
msgs.push_back("Current configuration of export sources provides 0 channels of audio.");
msgs.push_back(eps::uiText(eps::TextID::EXPORT_HANDLER_ERROR_NO_CHANNELS));
}
auto sourcesMsgs = admExportSources->generateExportErrorStrings();
msgs.insert(msgs.end(), sourcesMsgs.begin(), sourcesMsgs.end());
Expand All @@ -68,7 +69,7 @@ std::vector<std::string> AdmExportHandler::generateExportWarningStrings()
std::vector<std::string> msgs;

if(earSceneMasterVstSources && earSceneMasterVstSources->validForExport() && admExportVstSources && admExportVstSources->validForExport()) {
msgs.push_back(std::string("Multiple Types of Export Source!"));
msgs.push_back(eps::uiText(eps::TextID::EXPORT_HANDLER_WARNING_MULTIPLE_SOURCE_TYPES));
}

if(admExportSources) {
Expand Down
31 changes: 18 additions & 13 deletions reaper-adm-extension/src/reaper_adm/exportaction_dialogcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "resource.h"
#include "exportaction_issues.h"
#include "exportaction.h"
#include "ui_text.h"

// Lots of assumptions made here! May need more re-jigging if future versions differ
#define EXPECTED_RENDER_DIALOG_WINDOW_TITLE "Render to File"
Expand All @@ -14,9 +15,6 @@
#define REQUIRED_SOURCE_COMBO_OPTION "Master mix"
#define REQUIRED_BOUNDS_COMBO_OPTION "Entire project"

#define TAKEOVER_TEXT_FOR_CHANNEL_COUNT "Auto" // What we will display for "Channels" when our PCM Sink is selected
#define FALLBACK_VALUE_FOR_CHANNEL_COUNT "Stereo" // Value once we restore state, if we didn't know what it was before

#define TIMER_ID 1

int MakeWParam(int loWord, int hiWord)
Expand Down Expand Up @@ -153,7 +151,7 @@ void RenderDialogControl::RenderDialogState::startPreparingRenderControls(HWND h
{
startedPrepareDialogControls = true; // Prevents paint message relauching this
EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_REFRESH), false);
SetWindowText(GetDlgItem(hwndDlg, IDC_INFOPANE), LPCSTR("\r\nValidating Project Structure...\r\n\r\nPlease Wait..."));
SetWindowText(GetDlgItem(hwndDlg, IDC_INFOPANE), eps::uiText(eps::TextID::RENDERER_VALIDATING_DIALOG).c_str());
SetTimer(hwndDlg,
TIMER_ID, // timer identifier
100, // interval(ms)
Expand Down Expand Up @@ -221,7 +219,7 @@ BOOL CALLBACK RenderDialogControl::RenderDialogState::prepareRenderControl_pass2
if(channelsLastOption.length() == 0 && currentOption.length() > 0){
channelsLastOption = currentOption;
}
channelsControlSetError |= (SetWindowText(editControl, TAKEOVER_TEXT_FOR_CHANNEL_COUNT) == 0);
channelsControlSetError |= (SetWindowText(editControl, eps::uiText(eps::TextID::EXPORT_DIALOG_TAKEOVER_TEXT_FOR_CHANNEL_COUNT).c_str()) == 0);
EnableWindow(editControl, false);
UpdateWindow(editControl);
}
Expand All @@ -246,27 +244,27 @@ std::string RenderDialogControl::RenderDialogState::getAdmExportVstsInfoString()

auto exportSources = admExportHandler->getAdmExportSources();
if(exportSources) {
op += "Using export source: \"";
op += eps::uiText(eps::TextID::RENDERER_EXPORT_SOURCE_PREFIX);
op += admExportHandler->getAdmExportSources()->getExportSourcesName();
op += "\"";
} else {
op += "No suitable export sources!";
op += eps::uiText(eps::TextID::RENDERER_ERROR_NO_EXPORT_SOURCES);
}

auto errors = admExportHandler->generateExportErrorStrings();
auto warnings = admExportHandler->generateExportWarningStrings();
auto infos = admExportHandler->generateExportInfoStrings();

if (errors.size() > 0) {
op.append("\r\n\r\nERRORS:");
op.append(eps::uiText(eps::TextID::RENDER_LOG_ERROR_HEADER));
for(auto &msg : errors) {
op.append(itemStarter);
op.append(msg);
}
}

if (warnings.size() > 0) {
op.append("\r\n\r\nWARNINGS:");
op.append(eps::uiText(eps::TextID::RENDER_LOG_WARNING_HEADER));
for(auto &msg : warnings) {
op.append(itemStarter);
op.append(msg);
Expand All @@ -276,7 +274,7 @@ std::string RenderDialogControl::RenderDialogState::getAdmExportVstsInfoString()
if (infos.size() > 0) {
op.append("\r\n");
if(warnings.size() > 0 || errors.size() > 0) {
op.append("\r\nINFO:");
op.append(eps::uiText(eps::TextID::RENDER_LOG_INFO_HEADER));
}
for(auto &msg : infos) {
op.append(itemStarter);
Expand Down Expand Up @@ -360,7 +358,7 @@ WDL_DLGRET RenderDialogControl::RenderDialogState::wavecfgDlgProc(HWND hwndDlg,
channelsControlHwnd.has_value() &&
!sampleRateControlSetError && !channelsControlSetError;
if(!allControlsSuccessful) {
infoPaneText = "WARNING: Unable to takeover all render controls. REAPER version may be unsupported and render may fail.\r\n\r\n" + infoPaneText;
infoPaneText = eps::uiText(eps::TextID::RENDERER_ERROR_FAILED_CONTROL_OVERRIDE) + infoPaneText;
}

SetWindowText(GetDlgItem(hwndDlg, IDC_INFOPANE), LPCSTR(infoPaneText.c_str()));
Expand Down Expand Up @@ -423,8 +421,15 @@ WDL_DLGRET RenderDialogControl::RenderDialogState::wavecfgDlgProc(HWND hwndDlg,
if(channelsControlHwnd) {
auto editControl = getComboBoxEdit(*channelsControlHwnd);
if(channelsLastOption.length() > 0){
std::string opt = channelsLastOption == TAKEOVER_TEXT_FOR_CHANNEL_COUNT ? FALLBACK_VALUE_FOR_CHANNEL_COUNT : channelsLastOption;
selectInComboBox(*channelsControlHwnd, opt);
std::string opt =
channelsLastOption ==
eps::uiText(
eps::TextID::
EXPORT_DIALOG_TAKEOVER_TEXT_FOR_CHANNEL_COUNT)
? uiText(eps::TextID::
EXPORT_DIALOG_FALLBACK_VALUE_FOR_CHANNEL_COUNT)
: channelsLastOption;
selectInComboBox(*channelsControlHwnd, opt);
SetWindowText(editControl, opt.c_str());
}
EnableWindow(editControl, true);
Expand Down
92 changes: 51 additions & 41 deletions reaper-adm-extension/src/reaper_adm/exportaction_pcmsink.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "exportaction_pcmsink.h"

#include "adm/adm.hpp"
#include "adm/utilities/id_assignment.hpp"
#include "adm/write.hpp"
#include "ui_text.h"
#include <fmt/core.h>

#ifdef _WIN32
#include <Windows.h>
Expand Down Expand Up @@ -39,51 +39,62 @@ PCM_sink_adm::PCM_sink_adm(std::shared_ptr<ReaperAPI> api, const char *fn, void
auto admExportSources = admExportHandler->getAdmExportSources();

if(!admExportSources) {
api->ShowMessageBox("No suitable export sources within the current project.\r\nCan not continue with render.", "No Export Sources", 0);
abortRender();
api->ShowMessageBox(
eps::uiText(eps::TextID::EXPORT_SINK_ERROR_NO_SOURCES).c_str(),
eps::uiText(eps::TextID::EXPORT_SINK_ERROR_NO_SOURCES_TITLE).c_str(),
0);
abortRender();
return;
}

// Check things that directly cause issues for the sink
totalChannels = admExportSources->getTotalExportChannels();

if (totalChannels == 0) {
api->ShowMessageBox("The current configuration of export sources will export 0 channels of audio.\r\nCan not continue with render.", "No Audio To Export", 0);
abortRender();
api->ShowMessageBox(
eps::uiText(eps::TextID::EXPORT_SINK_ERROR_NO_SOURCES).c_str(),
eps::uiText(eps::TextID::EXPORT_SINK_ERROR_NO_CHANNELS_TITLE).c_str(),
0);
abortRender();
return;
}

if(sRate != admExportSources->getSampleRate())
{
std::string msg("Error: Sink sample rate (");
msg.append(std::to_string(sRate));
msg.append(") does not match VST sample rate (");
msg.append(std::to_string(admExportSources->getSampleRate()));
msg.append(")!\r\nThis is likely an internal issue.\r\nCan not continue with render.");
api->ShowMessageBox(msg.c_str(), "Sample Rate Mismatch", 0);
abortRender();
return;
auto msg =
fmt::format(eps::uiText(eps::TextID::EXPORT_SINK_ERROR_SAMPLE_RATE),
sRate, admExportSources->getSampleRate());
api->ShowMessageBox(
msg.c_str(),
eps::uiText(eps::TextID::EXPORT_SINK_ERROR_SAMPLE_RATE_TITLE).c_str(),
0);
abortRender();
return;
}

// Check other errors (warnings/infos are fine... we can continue with those)
auto errors = admExportHandler->generateExportErrorStrings();
if(errors.size() > 0) {
auto op = std::string("Can not render due to the following issues:\r\n");
if(!errors.empty()) {
auto op = eps::uiText(eps::TextID::EXPORT_HANDLER_ERROR_NO_VALID_SOURCES);
for(auto& error : errors) {
op.append("\r\n");
op.append(error);
}
api->ShowMessageBox(op.c_str() , "Render Issues", 0);
api->ShowMessageBox(
op.c_str(),
eps::uiText(eps::TextID::EXPORT_SINK_ISSUES_TITLE).c_str(), 0);
abortRender();
return;
}

// Check ADM
auto doc = admExportSources->getAdmDocument();
if(!doc) {
api->ShowMessageBox("Error: No ADM metadata available for export.\r\nThis is likely an internal issue.\r\nCan not continue with render.", "No ADM Metadata", 0);
abortRender();
return;
api->ShowMessageBox(
eps::uiText(eps::TextID::EXPORT_SINK_ERROR_NO_ADM).c_str(),
eps::uiText(eps::TextID::EXPORT_SINK_ERROR_NO_ADM_TITLE).c_str(), 0);
abortRender();
return;
}

// Configure ADM document
Expand Down Expand Up @@ -130,19 +141,18 @@ PCM_sink_adm::~PCM_sink_adm()
}

if (actualFramesWritten < expectedFramesWritten) {
// Warn user - didn't receive all the frames we expected
auto msg = std::string("Warning:\r\n");
msg += "Received ";
msg += std::to_string(actualFramesWritten);
msg += " frames from export source \"";
msg += admExportHandler->getAdmExportSources()->getExportSourcesName();
msg += "\".\r\n";
msg += "Expected ";
msg += std::to_string(expectedFramesWritten);
msg += " frames.";
api->ShowMessageBox(msg.c_str(), "Render", 0);
// Warn user - didn't receive all the frames we expected
auto msg = fmt::format(
eps::uiText(eps::TextID::EXPORT_SINK_WARNING_FRAMES),
actualFramesWritten,
admExportHandler->getAdmExportSources()->getExportSourcesName(),
expectedFramesWritten);
api->ShowMessageBox(
msg.c_str(),
eps::uiText(eps::TextID::EXPORT_SINK_WARNING_FRAMES_TITLE)
.c_str(),
0);
}

writer.reset();
}

Expand All @@ -169,17 +179,17 @@ INT64 PCM_sink_adm::GetFileSize()
return 0;
}

void PCM_sink_adm::GetOutputInfoString(char *buf, int buflen)
{
if (writer) {
strncpy(buf, "Rendering ADM tracks...", buflen);
}
else {
strncpy(buf, "WARNING: Unable to render - invalid project structure!", buflen);
}
void PCM_sink_adm::GetOutputInfoString(char *buf, int buflen) {
if (writer) {
strncpy(buf, eps::uiText(eps::TextID::EXPORT_SINK_INFO_RENDERING).c_str(),
buflen);
} else {
strncpy(buf,
eps::uiText(eps::TextID::EXPORT_SINK_WARNING_BAD_STRUCTURE).c_str(),
buflen);
}
}


void PCM_sink_adm::WriteDoubles(double **samples, int len, int nch, int offset, int spacing)
{
if (!writer) return;
Expand Down
Loading