Support the two 4.0 layouts and localize the preferences page
This commit is contained in:
1 parent
0b9f3321fd
commit
dc3372be27
21 files changed
+1149
-185
No files matched your search
+23
-9
@@ -507,14 +507,23 @@ public:
|
||||
std::string error;
|
||||
if (!m_engine.start(m_native_path.get_ptr(), m_settings, &error)) {
|
||||
joc_log::line("decoder: engine start failed: %s", error.c_str());
|
||||
// The most common cause by far, and the one a user can act on.
|
||||
if (m_settings.output == joc_decode::Output::kBinaural &&
|
||||
m_settings.hrtf_file.empty()) {
|
||||
throw exception_io_data(
|
||||
"JOC:双耳渲染需要先指定 HRTF 文件(Preferences -> Tools -> JOC 解码器),"
|
||||
"或把输出改为扬声器布局。");
|
||||
}
|
||||
throw exception_io_data(error.c_str());
|
||||
// The message the user sees is in the page's language; the engine's own
|
||||
// line stays English and follows it, because it names the file or the
|
||||
// stream the failure came from.
|
||||
const joc_lang::Language language =
|
||||
joc_lang::resolve(joc_settings::read().language);
|
||||
std::string message = joc_lang::get(
|
||||
language, m_settings.output == joc_decode::Output::kBinaural
|
||||
? joc_lang::Text::kErrorHrtfNeeded
|
||||
: joc_lang::Text::kErrorRenderStream);
|
||||
message += "\n";
|
||||
message += error;
|
||||
// Logged as well: the dialog the host shows is not part of a support log,
|
||||
// and which language was in effect is part of the report.
|
||||
joc_log::line("decoder: reporting to the user (%s):\n%s",
|
||||
language == joc_lang::Language::kEnglish ? "english" : "chinese",
|
||||
message.c_str());
|
||||
throw exception_io_data(message.c_str());
|
||||
}
|
||||
m_channels = m_engine.channels();
|
||||
if (m_channels == 0) m_channels = 2;
|
||||
@@ -644,7 +653,12 @@ public:
|
||||
// An aborted seek reports itself as an abort, not as a decode failure.
|
||||
abort.check();
|
||||
joc_log::line("decoder: seek to %.6f s failed: %s", seconds, error.c_str());
|
||||
throw exception_io_data(error.c_str());
|
||||
const joc_lang::Language language =
|
||||
joc_lang::resolve(joc_settings::read().language);
|
||||
std::string message = joc_lang::get(language, joc_lang::Text::kErrorSeek);
|
||||
message += "\n";
|
||||
message += error;
|
||||
throw exception_io_data(message.c_str());
|
||||
}
|
||||
// The position reporting and the first-read statistics belong to the run
|
||||
// that starts here, not to the one that was interrupted.
|
||||
|
||||
+21
-4
@@ -312,6 +312,12 @@ private:
|
||||
// "5.1" means to ffmpeg), while 5.1.2 and up use the side pair (SL/SR). The wide
|
||||
// pair of 9.1.x has one home only: FCL/FCR (ffmpeg spells the same two FLC/FRC).
|
||||
//
|
||||
// The two 4.0 layouts are different speaker sets, not two spellings of one layout:
|
||||
// 4.0 Surround is a front trio plus one back-centre speaker (0x107), 4.0 Quad is a
|
||||
// front pair and a back pair with neither centre nor LFE (0x33). The bare name
|
||||
// "4.0" has always meant the former, so the kernel resolves it as an alias for it
|
||||
// and a stored value is migrated to the explicit name.
|
||||
//
|
||||
// 9.1.6 is the one layout WAVE cannot describe completely: it has three height
|
||||
// pairs, and the mask has positions for two (TFL/TFR, TBL/TBR) plus single centre
|
||||
// positions. The top-middle pair -- ffmpeg's TSL/TSR, above a 32-bit mask -- is
|
||||
@@ -325,6 +331,14 @@ const LayoutSpec kLayouts[] = {
|
||||
4,
|
||||
{"L", "R", "C", "LFE"},
|
||||
{kSpeakerFrontLeft, kSpeakerFrontRight, kSpeakerFrontCenter, kSpeakerLfe}},
|
||||
{"4.0 Surround",
|
||||
4,
|
||||
{"L", "R", "C", "Cs"},
|
||||
{kSpeakerFrontLeft, kSpeakerFrontRight, kSpeakerFrontCenter, kSpeakerBackCenter}},
|
||||
{"4.0 Quad",
|
||||
4,
|
||||
{"L", "R", "Lrs", "Rrs"},
|
||||
{kSpeakerFrontLeft, kSpeakerFrontRight, kSpeakerBackLeft, kSpeakerBackRight}},
|
||||
{"5.1",
|
||||
6,
|
||||
{"L", "R", "C", "LFE", "Ls", "Rs"},
|
||||
@@ -1084,15 +1098,18 @@ bool Engine::start(const std::string& input_path, const Settings& settings, std:
|
||||
const std::string& hrtf_file = hrtf_in_use;
|
||||
if (hrtf_file.empty()) {
|
||||
if (error != nullptr) {
|
||||
*error = "双耳渲染需要 HRTF 文件,但组件目录无法确定;请在设置页里显式指定路径";
|
||||
*error = "the component directory is unknown, so the default HRTF location "
|
||||
"cannot be resolved; name an HRTF file in the preferences page";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!file_exists(hrtf_file)) {
|
||||
if (error != nullptr) {
|
||||
*error = std::string("找不到 HRTF 文件:") + hrtf_file +
|
||||
(settings.hrtf_file.empty() ? "(默认位置,可在设置页里指定其它路径)"
|
||||
: "");
|
||||
*error = "HRTF file not found: " + hrtf_file +
|
||||
(settings.hrtf_file.empty()
|
||||
? " (the default location; another file can be named in the "
|
||||
"preferences page)"
|
||||
: "");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
// See lang.h: one row per string, Chinese first because it is the source text.
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
#include "lang.h"
|
||||
|
||||
namespace joc_lang {
|
||||
|
||||
namespace {
|
||||
|
||||
struct Entry {
|
||||
Text id;
|
||||
const char* zh;
|
||||
const char* en;
|
||||
};
|
||||
|
||||
constexpr Entry kTexts[] = {
|
||||
{Text::kPageName, "JOC 解码器", "JOC decoder"},
|
||||
{Text::kGroupOutput, "输出", "Output"},
|
||||
{Text::kRadioBinaural, "双耳(HRTF)", "Binaural (HRTF)"},
|
||||
{Text::kRadioSpeaker, "扬声器布局", "Speaker layout"},
|
||||
{Text::kLabelMode, "双耳模式", "Binaural mode"},
|
||||
{Text::kComboModeNear, "near(近场)", "near"},
|
||||
{Text::kComboModeMid, "mid(默认)", "mid (default)"},
|
||||
{Text::kComboModeFar, "far(远场)", "far"},
|
||||
{Text::kLabelTail, "房间尾音(秒)", "Room tail (s)"},
|
||||
{Text::kCheckInt24, "强制 24bit 输出(int24)", "Force 24-bit output (int24)"},
|
||||
{Text::kInt24Hint, "切换后需刷新文件信息", "reload file info after switching"},
|
||||
{Text::kSpeakerStatus, "扬声器布局 %s(%u 声道%s)", "Speaker layout %s (%u ch%s)"},
|
||||
{Text::kSpeakerStatusAsio, ",需要 ASIO 输出", ", needs ASIO"},
|
||||
{Text::kGroupHrtf, "HRTF", "HRTF"},
|
||||
{Text::kRadioSofa, "SOFA 文件", "SOFA file"},
|
||||
{Text::kRadioRosella, "Rosella 个性化模型", "Rosella personalized model"},
|
||||
{Text::kLabelHrtfFile, "HRTF 文件", "HRTF file"},
|
||||
{Text::kButtonBrowse, "浏览…", "Browse…"},
|
||||
{Text::kHrtfHint,
|
||||
"留空时读组件目录下 HRTF\\binaural.sofa 或 HRTF\\binaural.personalized_headphone。",
|
||||
"Empty means HRTF\\binaural.sofa or binaural.personalized_headphone next to "
|
||||
"the component."},
|
||||
{Text::kHrtfSourceSofa, "SOFA", "SOFA"},
|
||||
{Text::kHrtfSourceRosella, "Rosella 个性化模型", "Rosella personalized model"},
|
||||
{Text::kHrtfDefault, "默认", "default"},
|
||||
{Text::kHrtfDefaultUnknown, "无法确定默认路径",
|
||||
"cannot resolve the default location"},
|
||||
{Text::kGroupGain, "增益", "Gain"},
|
||||
{Text::kCheckGain, "应用增益", "Apply gain"},
|
||||
{Text::kLabelGainUnit, "dB", "dB"},
|
||||
{Text::kGainStatusOn, "增益开 %.2f dB", "gain on, %.2f dB"},
|
||||
{Text::kGainStatusOff, "增益关(输出不衰减)", "gain off (no attenuation)"},
|
||||
{Text::kGainHint, "双耳渲染后可能超过 0 dBFS,可用负值衰减。",
|
||||
"Binaural rendering can exceed 0 dBFS; attenuate with a negative value."},
|
||||
{Text::kGroupOther, "其它", "Other"},
|
||||
{Text::kLabelLanguage, "界面语言", "Language"},
|
||||
{Text::kLabelFfmpeg, "ffmpeg.exe", "ffmpeg.exe"},
|
||||
{Text::kLanguageSystem, "跟随系统", "Follow system"},
|
||||
{Text::kLanguageChinese, "简体中文", "简体中文"},
|
||||
{Text::kLanguageEnglish, "English", "English"},
|
||||
{Text::kSeparator, ":", ": "},
|
||||
{Text::kErrorHrtfNeeded,
|
||||
"JOC:双耳渲染需要 HRTF 数据文件,请在 Preferences → Tools → JOC 解码器 里指定,"
|
||||
"或把输出改为扬声器布局。",
|
||||
"JOC: binaural rendering needs an HRTF data file. Set one in Preferences → "
|
||||
"Tools → JOC decoder, or switch the output to a speaker layout."},
|
||||
{Text::kErrorRenderStream, "JOC:无法创建渲染流。",
|
||||
"JOC: cannot create the render stream."},
|
||||
{Text::kErrorSeek, "JOC:无法跳转到目标位置。",
|
||||
"JOC: cannot seek to the target position."},
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Language resolve(Language language) {
|
||||
if (language == Language::kChineseSimplified || language == Language::kEnglish) {
|
||||
return language;
|
||||
}
|
||||
// PRIMARYLANGID stays the same across the Chinese variants, so a Traditional
|
||||
// Chinese Windows reads the simplified column rather than English.
|
||||
return PRIMARYLANGID(GetUserDefaultUILanguage()) == LANG_CHINESE
|
||||
? Language::kChineseSimplified
|
||||
: Language::kEnglish;
|
||||
}
|
||||
|
||||
const char* get(Language language, Text id) {
|
||||
const bool english = resolve(language) == Language::kEnglish;
|
||||
for (const Entry& entry : kTexts) {
|
||||
if (entry.id == id) return english ? entry.en : entry.zh;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
} // namespace joc_lang
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
// User-interface text for the component, in the languages the page offers.
|
||||
//
|
||||
// Only strings a user can see belong here: labels, buttons, the status lines under
|
||||
// the controls, and the messages an error is reported with. Log lines and engine
|
||||
// diagnostics stay English, so a support log reads the same whatever the page is
|
||||
// set to.
|
||||
//
|
||||
// The Chinese column is the source: the English column translates it rather than
|
||||
// wording the feature independently, and the two must mean the same thing.
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace joc_lang {
|
||||
|
||||
enum class Language {
|
||||
kSystem = 0, // follow the Windows user-interface language
|
||||
kChineseSimplified = 1,
|
||||
kEnglish = 2,
|
||||
};
|
||||
|
||||
enum class Text {
|
||||
// preferences page
|
||||
kPageName,
|
||||
kGroupOutput,
|
||||
kRadioBinaural,
|
||||
kRadioSpeaker,
|
||||
kLabelMode,
|
||||
kComboModeNear,
|
||||
kComboModeMid,
|
||||
kComboModeFar,
|
||||
kLabelTail,
|
||||
kCheckInt24,
|
||||
kInt24Hint,
|
||||
kSpeakerStatus,
|
||||
kSpeakerStatusAsio,
|
||||
kGroupHrtf,
|
||||
kRadioSofa,
|
||||
kRadioRosella,
|
||||
kLabelHrtfFile,
|
||||
kButtonBrowse,
|
||||
kHrtfHint,
|
||||
kHrtfSourceSofa,
|
||||
kHrtfSourceRosella,
|
||||
kHrtfDefault,
|
||||
kHrtfDefaultUnknown,
|
||||
kGroupGain,
|
||||
kCheckGain,
|
||||
kLabelGainUnit,
|
||||
kGainStatusOn,
|
||||
kGainStatusOff,
|
||||
kGainHint,
|
||||
kGroupOther,
|
||||
kLabelLanguage,
|
||||
kLabelFfmpeg,
|
||||
kLanguageSystem,
|
||||
kLanguageChinese,
|
||||
kLanguageEnglish,
|
||||
// "SOFA": the separator between a label and the value after it
|
||||
kSeparator,
|
||||
// messages shown when decoding fails
|
||||
kErrorHrtfNeeded,
|
||||
kErrorRenderStream,
|
||||
kErrorSeek,
|
||||
};
|
||||
|
||||
// The language actually used: kSystem resolves to the Windows user-interface
|
||||
// language (Chinese if that language is Chinese, English otherwise).
|
||||
Language resolve(Language language);
|
||||
|
||||
// Text for an already resolved language (pass resolve()'s result).
|
||||
const char* get(Language language, Text id);
|
||||
|
||||
} // namespace joc_lang
|
||||
@@ -8,7 +8,9 @@
|
||||
#include <SDK/componentversion.h>
|
||||
#include <SDK/coreversion.h>
|
||||
#include <SDK/initquit.h>
|
||||
#include "lang.h"
|
||||
#include "log.h"
|
||||
#include "settings.h"
|
||||
|
||||
// Kept in one place: the string reported to foobar2000 and written to the log
|
||||
// must not drift apart.
|
||||
@@ -42,6 +44,15 @@ public:
|
||||
joc_log::line("log file : %s", joc_log::path());
|
||||
joc_log::line("log limit : %llu byte(s) per file, then rolled to the .1 suffix",
|
||||
joc_log::budget_bytes());
|
||||
const joc_settings::Values stored = joc_settings::read();
|
||||
joc_log::line("interface language: %s (stored: %s)",
|
||||
joc_lang::resolve(stored.language) == joc_lang::Language::kEnglish
|
||||
? "english"
|
||||
: "chinese",
|
||||
stored.language == joc_lang::Language::kSystem
|
||||
? "system default"
|
||||
: (stored.language == joc_lang::Language::kEnglish ? "english"
|
||||
: "chinese"));
|
||||
joc_log::line("compiled as : %s",
|
||||
#if defined(_M_IX86)
|
||||
"x86 (32-bit)"
|
||||
|
||||
+243
-85
@@ -4,6 +4,11 @@
|
||||
// plain Win32 modeless dialog. The SDK's preferences_page_impl<> helper would
|
||||
// pull in the ATL/WTL dialog framework, which the SDK does not ship; nothing in
|
||||
// this page needs it.
|
||||
//
|
||||
// Every visible string comes from src/lang.cpp: the dialog resource carries the
|
||||
// Chinese text as the design-time default, and the page replaces all of it once it
|
||||
// knows which language is selected, so changing the language combo takes effect
|
||||
// without reopening the page.
|
||||
|
||||
#include <SDK/foobar2000-lite.h>
|
||||
|
||||
@@ -16,8 +21,10 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "joc_decode.h"
|
||||
#include "lang.h"
|
||||
#include "prefs.h"
|
||||
#include "log.h"
|
||||
#include "resource.h"
|
||||
@@ -60,41 +67,87 @@ void set_text(HWND control, const std::string& text) {
|
||||
SetWindowTextW(control, wide(text).c_str());
|
||||
}
|
||||
|
||||
// The layouts the page offers come from the core-facing table (layout_table()), so
|
||||
// it cannot offer one the decoder rejects. Offering them is not a promise that
|
||||
// every output can play them: foobar2000's shared and exclusive outputs follow the
|
||||
// Windows speaker configuration, while an ASIO output passes any channel count and
|
||||
// any layout through.
|
||||
//
|
||||
// The speaker configurations Windows itself has are 2.0, 5.1 and 7.1. Anything
|
||||
// else -- a height channel, the wide pair, more than eight channels -- is not
|
||||
// else -- a height channel, either 4.0 layout, more than eight channels -- is not
|
||||
// carried by a shared or exclusive output, so the status line points at ASIO.
|
||||
bool windows_speaker_config(unsigned mask) {
|
||||
return mask == 0x3u || mask == 0x3Fu || mask == 0x63Fu;
|
||||
}
|
||||
|
||||
const char* const kModeNames[] = {"near", "far", "mid"};
|
||||
const char* const kModeLabels[] = {"near(近场)", "far(远场)", "mid(默认)"};
|
||||
// A drop-down list's items are rebuilt whenever the language changes, and the
|
||||
// selection has to survive that.
|
||||
void fill_combo(HWND combo, const std::vector<std::string>& items, int selected) {
|
||||
const int current =
|
||||
selected >= 0 ? selected
|
||||
: static_cast<int>(SendMessageW(combo, CB_GETCURSEL, 0, 0));
|
||||
SendMessageW(combo, CB_RESETCONTENT, 0, 0);
|
||||
for (const std::string& item : items) {
|
||||
SendMessageW(combo, CB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(wide(item).c_str()));
|
||||
}
|
||||
if (current >= 0 && current < static_cast<int>(items.size())) {
|
||||
SendMessageW(combo, CB_SETCURSEL, static_cast<WPARAM>(current), 0);
|
||||
}
|
||||
}
|
||||
|
||||
// The binaural mode combo lists the three modes in the order they widen, with the
|
||||
// default (mid) in the middle.
|
||||
joc_lang::Text mode_text(unsigned index) {
|
||||
switch (index) {
|
||||
case 0: return joc_lang::Text::kComboModeNear;
|
||||
case 2: return joc_lang::Text::kComboModeFar;
|
||||
default: return joc_lang::Text::kComboModeMid;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned mode_index(unsigned mode) {
|
||||
switch (mode) {
|
||||
case 1: return 0;
|
||||
case 2: return 1;
|
||||
default: return 2;
|
||||
case 2: return 2;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned mode_value(unsigned index) {
|
||||
switch (index) {
|
||||
case 0: return 1;
|
||||
case 1: return 2;
|
||||
case 2: return 2;
|
||||
default: return 3;
|
||||
}
|
||||
}
|
||||
|
||||
int language_index(joc_lang::Language language) {
|
||||
switch (language) {
|
||||
case joc_lang::Language::kChineseSimplified: return 1;
|
||||
case joc_lang::Language::kEnglish: return 2;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
joc_lang::Language language_value(int index) {
|
||||
switch (index) {
|
||||
case 1: return joc_lang::Language::kChineseSimplified;
|
||||
case 2: return joc_lang::Language::kEnglish;
|
||||
default: return joc_lang::Language::kSystem;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> mode_items(joc_lang::Language language) {
|
||||
std::vector<std::string> items;
|
||||
for (unsigned i = 0; i < 3; ++i) {
|
||||
items.emplace_back(joc_lang::get(language, mode_text(i)));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
std::vector<std::string> language_items(joc_lang::Language language) {
|
||||
return {joc_lang::get(language, joc_lang::Text::kLanguageSystem),
|
||||
joc_lang::get(language, joc_lang::Text::kLanguageChinese),
|
||||
joc_lang::get(language, joc_lang::Text::kLanguageEnglish)};
|
||||
}
|
||||
|
||||
bool pick_file(HWND owner, std::string& path, const wchar_t* title,
|
||||
const wchar_t* filter) {
|
||||
wchar_t buffer[4096] = {};
|
||||
const wchar_t* filter) { wchar_t buffer[4096] = {};
|
||||
const std::wstring current = wide(path);
|
||||
if (!current.empty() && current.size() < 4090) {
|
||||
std::wcsncpy(buffer, current.c_str(), 4090);
|
||||
@@ -112,6 +165,42 @@ bool pick_file(HWND owner, std::string& path, const wchar_t* title,
|
||||
return true;
|
||||
}
|
||||
|
||||
// Shortens a path to the width a control has, keeping its start and the file name
|
||||
// and cutting out the middle. The status line under the group is two lines tall,
|
||||
// and a long user-components path would otherwise push the file name out of view.
|
||||
std::string elide_path(HWND control, const std::string& path, int max_width) {
|
||||
HDC dc = GetDC(control);
|
||||
if (dc == nullptr) return path;
|
||||
const auto font = reinterpret_cast<HFONT>(SendMessageW(control, WM_GETFONT, 0, 0));
|
||||
HGDIOBJ previous = font != nullptr ? SelectObject(dc, font) : nullptr;
|
||||
auto fits = [&](const std::wstring& text) {
|
||||
SIZE size{};
|
||||
GetTextExtentPoint32W(dc, text.c_str(), static_cast<int>(text.size()), &size);
|
||||
return size.cx <= max_width;
|
||||
};
|
||||
|
||||
const std::wstring wide_path = wide(path);
|
||||
std::string result = path;
|
||||
if (!fits(wide_path)) {
|
||||
const std::size_t slash = wide_path.find_last_of(L"\\/");
|
||||
const std::wstring tail = slash == std::wstring::npos ? wide_path
|
||||
: wide_path.substr(slash);
|
||||
const std::wstring head = slash == std::wstring::npos ? std::wstring()
|
||||
: wide_path.substr(0, slash);
|
||||
result = narrow(tail);
|
||||
for (std::size_t keep = head.size(); keep > 0; --keep) {
|
||||
const std::wstring candidate = head.substr(0, keep) + L"…" + tail;
|
||||
if (fits(candidate)) {
|
||||
result = narrow(candidate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (previous != nullptr) SelectObject(dc, previous);
|
||||
ReleaseDC(control, dc);
|
||||
return result;
|
||||
}
|
||||
|
||||
class prefs_instance : public preferences_page_instance {
|
||||
public:
|
||||
prefs_instance(HWND parent, preferences_page_callback::ptr callback)
|
||||
@@ -143,12 +232,12 @@ public:
|
||||
joc_settings::write(values);
|
||||
m_initial = values;
|
||||
joc_log::line("prefs: applied %s", joc_settings::describe(values).c_str());
|
||||
update_status();
|
||||
apply_texts();
|
||||
notify();
|
||||
}
|
||||
|
||||
void reset() override {
|
||||
load_controls(joc_settings::defaults());
|
||||
load_values(joc_settings::defaults());
|
||||
joc_log::line("prefs: reset to defaults");
|
||||
notify();
|
||||
}
|
||||
@@ -170,9 +259,8 @@ private:
|
||||
INT_PTR handle(UINT message, WPARAM wparam, LPARAM lparam) {
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
load_controls(joc_settings::read());
|
||||
load_values(joc_settings::read());
|
||||
apply_dark_mode();
|
||||
update_status();
|
||||
return TRUE;
|
||||
case WM_COMMAND: {
|
||||
const int id = LOWORD(wparam);
|
||||
@@ -196,7 +284,6 @@ private:
|
||||
return TRUE;
|
||||
}
|
||||
if (id == IDC_RADIO_HRTF_SOFA || id == IDC_RADIO_HRTF_ROSELLA) {
|
||||
update_enabled_state();
|
||||
update_status();
|
||||
notify();
|
||||
return TRUE;
|
||||
@@ -211,18 +298,29 @@ private:
|
||||
return TRUE;
|
||||
}
|
||||
if (id == IDC_RADIO_BINAURAL || id == IDC_RADIO_SPEAKER) {
|
||||
update_enabled_state();
|
||||
update_status();
|
||||
notify();
|
||||
return TRUE;
|
||||
}
|
||||
if (id == IDC_CHECK_GAIN || id == IDC_CHECK_INT24) {
|
||||
update_enabled_state();
|
||||
update_status();
|
||||
notify();
|
||||
return TRUE;
|
||||
}
|
||||
if (code == EN_CHANGE || code == CBN_SELCHANGE) {
|
||||
if (id == IDC_EDIT_HRTF || id == IDC_COMBO_LAYOUT ||
|
||||
id == IDC_EDIT_GAIN) {
|
||||
if (code == CBN_SELCHANGE) {
|
||||
if (id == IDC_COMBO_LANGUAGE) {
|
||||
// The language applies to the page itself, so every text is
|
||||
// replaced at once. The value is stored when the page is
|
||||
// applied, like the other controls.
|
||||
apply_texts();
|
||||
} else if (id == IDC_COMBO_LAYOUT || id == IDC_COMBO_MODE) {
|
||||
update_status();
|
||||
}
|
||||
notify();
|
||||
return TRUE;
|
||||
}
|
||||
if (code == EN_CHANGE) {
|
||||
if (id == IDC_EDIT_HRTF || id == IDC_EDIT_GAIN) {
|
||||
update_status();
|
||||
}
|
||||
notify();
|
||||
@@ -265,34 +363,59 @@ private:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void load_controls(const joc_settings::Values& values) {
|
||||
// ---- language ---------------------------------------------------------
|
||||
|
||||
joc_lang::Language selected_language() const {
|
||||
const int index = static_cast<int>(
|
||||
SendDlgItemMessageW(m_hwnd, IDC_COMBO_LANGUAGE, CB_GETCURSEL, 0, 0));
|
||||
return language_value(index);
|
||||
}
|
||||
|
||||
// Replaces every visible string with the one for the language the combo has
|
||||
// selected. Safe to call before the combos have items: their lists are
|
||||
// (re)built here from the same language, keeping the current selection.
|
||||
void apply_texts() {
|
||||
const joc_lang::Language language = joc_lang::resolve(selected_language());
|
||||
auto label = [&](int control, joc_lang::Text text) {
|
||||
set_text(GetDlgItem(m_hwnd, control), joc_lang::get(language, text));
|
||||
};
|
||||
label(IDC_GROUP_OUTPUT, joc_lang::Text::kGroupOutput);
|
||||
label(IDC_RADIO_BINAURAL, joc_lang::Text::kRadioBinaural);
|
||||
label(IDC_RADIO_SPEAKER, joc_lang::Text::kRadioSpeaker);
|
||||
label(IDC_LABEL_MODE, joc_lang::Text::kLabelMode);
|
||||
label(IDC_LABEL_TAIL, joc_lang::Text::kLabelTail);
|
||||
label(IDC_CHECK_INT24, joc_lang::Text::kCheckInt24);
|
||||
label(IDC_LABEL_INT24_HINT, joc_lang::Text::kInt24Hint);
|
||||
label(IDC_GROUP_HRTF, joc_lang::Text::kGroupHrtf);
|
||||
label(IDC_RADIO_HRTF_SOFA, joc_lang::Text::kRadioSofa);
|
||||
label(IDC_RADIO_HRTF_ROSELLA, joc_lang::Text::kRadioRosella);
|
||||
label(IDC_LABEL_HRTF, joc_lang::Text::kLabelHrtfFile);
|
||||
label(IDC_BROWSE_HRTF, joc_lang::Text::kButtonBrowse);
|
||||
label(IDC_LABEL_HRTF_HINT, joc_lang::Text::kHrtfHint);
|
||||
label(IDC_GROUP_GAIN, joc_lang::Text::kGroupGain);
|
||||
label(IDC_CHECK_GAIN, joc_lang::Text::kCheckGain);
|
||||
label(IDC_LABEL_GAIN, joc_lang::Text::kLabelGainUnit);
|
||||
label(IDC_LABEL_GAIN_HINT, joc_lang::Text::kGainHint);
|
||||
label(IDC_GROUP_MISC, joc_lang::Text::kGroupOther);
|
||||
label(IDC_LABEL_LANGUAGE, joc_lang::Text::kLabelLanguage);
|
||||
label(IDC_LABEL_FFMPEG, joc_lang::Text::kLabelFfmpeg);
|
||||
label(IDC_BROWSE_FFMPEG, joc_lang::Text::kButtonBrowse);
|
||||
|
||||
fill_combo(GetDlgItem(m_hwnd, IDC_COMBO_MODE), mode_items(language), -1);
|
||||
fill_combo(GetDlgItem(m_hwnd, IDC_COMBO_LANGUAGE), language_items(language), -1);
|
||||
update_status();
|
||||
}
|
||||
|
||||
// ---- control values ---------------------------------------------------
|
||||
|
||||
void load_values(const joc_settings::Values& values) {
|
||||
CheckRadioButton(m_hwnd, IDC_RADIO_BINAURAL, IDC_RADIO_SPEAKER,
|
||||
values.output == 0 ? IDC_RADIO_BINAURAL : IDC_RADIO_SPEAKER);
|
||||
|
||||
HWND layout = GetDlgItem(m_hwnd, IDC_COMBO_LAYOUT);
|
||||
SendMessageW(layout, CB_RESETCONTENT, 0, 0);
|
||||
std::size_t layout_count = 0;
|
||||
const joc_decode::LayoutSpec* layouts = joc_decode::layout_table(&layout_count);
|
||||
int selected = 0;
|
||||
for (std::size_t i = 0; i < layout_count; ++i) {
|
||||
SendMessageW(layout, CB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(wide(layouts[i].name).c_str()));
|
||||
if (values.speaker_layout == layouts[i].name) selected = static_cast<int>(i);
|
||||
}
|
||||
SendMessageW(layout, CB_SETCURSEL, selected, 0);
|
||||
|
||||
HWND mode = GetDlgItem(m_hwnd, IDC_COMBO_MODE);
|
||||
SendMessageW(mode, CB_RESETCONTENT, 0, 0);
|
||||
for (unsigned i = 0; i < 3; ++i) {
|
||||
SendMessageW(mode, CB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(wide(kModeLabels[i]).c_str()));
|
||||
}
|
||||
SendMessageW(mode, CB_SETCURSEL, mode_index(values.binaural_mode), 0);
|
||||
|
||||
CheckRadioButton(m_hwnd, IDC_RADIO_HRTF_SOFA, IDC_RADIO_HRTF_ROSELLA,
|
||||
values.hrtf_source == joc_settings::HrtfSource::kRosella
|
||||
? IDC_RADIO_HRTF_ROSELLA
|
||||
: IDC_RADIO_HRTF_SOFA);
|
||||
|
||||
set_text(GetDlgItem(m_hwnd, IDC_EDIT_HRTF), values.hrtf_file);
|
||||
set_text(GetDlgItem(m_hwnd, IDC_EDIT_FFMPEG), values.ffmpeg_path);
|
||||
|
||||
@@ -306,7 +429,33 @@ private:
|
||||
values.gain_enabled ? BST_CHECKED : BST_UNCHECKED, 0);
|
||||
SendMessageW(GetDlgItem(m_hwnd, IDC_CHECK_INT24), BM_SETCHECK,
|
||||
values.force_int24 ? BST_CHECKED : BST_UNCHECKED, 0);
|
||||
update_enabled_state();
|
||||
|
||||
// The item lists are language-dependent, so they are built (in the stored
|
||||
// language) before the selections are restored, and the texts are applied
|
||||
// last: apply_texts() reads the language from the combo, so a selection set
|
||||
// afterwards would leave the page in the other language.
|
||||
const joc_lang::Language language = joc_lang::resolve(values.language);
|
||||
fill_combo(GetDlgItem(m_hwnd, IDC_COMBO_LANGUAGE),
|
||||
language_items(language), language_index(values.language));
|
||||
fill_combo(GetDlgItem(m_hwnd, IDC_COMBO_MODE), mode_items(language),
|
||||
static_cast<int>(mode_index(values.binaural_mode)));
|
||||
|
||||
std::size_t layout_count = 0;
|
||||
const joc_decode::LayoutSpec* layouts = joc_decode::layout_table(&layout_count);
|
||||
std::vector<std::string> names;
|
||||
int layout_index = 0;
|
||||
for (std::size_t i = 0; i < layout_count; ++i) {
|
||||
names.emplace_back(layouts[i].name);
|
||||
if (values.speaker_layout == layouts[i].name) {
|
||||
layout_index = static_cast<int>(i);
|
||||
}
|
||||
}
|
||||
// The list comes from the core-facing table, so the page cannot offer a
|
||||
// layout the decoder rejects. Offering one is not a promise that an output
|
||||
// can play it: shared and exclusive outputs follow the Windows speaker
|
||||
// configuration, ASIO passes any channel count through.
|
||||
fill_combo(GetDlgItem(m_hwnd, IDC_COMBO_LAYOUT), names, layout_index);
|
||||
apply_texts();
|
||||
}
|
||||
|
||||
joc_settings::Values read_controls() const {
|
||||
@@ -322,7 +471,7 @@ private:
|
||||
}
|
||||
const int mode_sel =
|
||||
static_cast<int>(SendDlgItemMessageW(m_hwnd, IDC_COMBO_MODE, CB_GETCURSEL, 0, 0));
|
||||
values.binaural_mode = mode_value(mode_sel < 0 ? 2u : static_cast<unsigned>(mode_sel));
|
||||
values.binaural_mode = mode_value(mode_sel < 0 ? 1u : static_cast<unsigned>(mode_sel));
|
||||
|
||||
values.hrtf_source = IsDlgButtonChecked(m_hwnd, IDC_RADIO_HRTF_ROSELLA) == BST_CHECKED
|
||||
? joc_settings::HrtfSource::kRosella
|
||||
@@ -336,6 +485,7 @@ private:
|
||||
IsDlgButtonChecked(m_hwnd, IDC_CHECK_GAIN) == BST_CHECKED;
|
||||
values.force_int24 =
|
||||
IsDlgButtonChecked(m_hwnd, IDC_CHECK_INT24) == BST_CHECKED;
|
||||
values.language = selected_language();
|
||||
// Advanced values are not on this page; keep whatever is stored.
|
||||
const joc_settings::Values stored = joc_settings::read();
|
||||
values.object_delay_samples = stored.object_delay_samples;
|
||||
@@ -343,60 +493,60 @@ private:
|
||||
return values;
|
||||
}
|
||||
|
||||
// Nothing on this page is ever disabled: a greyed control reads as an option
|
||||
// that cannot be used, and none of these settings is invalid in the other
|
||||
// mode. A speaker layout chosen while binaural output is active simply has no
|
||||
// effect until the output is switched back, and the gain field describes what
|
||||
// the switch would apply. What is in effect is stated in the status line.
|
||||
void update_enabled_state() { update_status(); }
|
||||
|
||||
// Updates the lines that describe what is in effect. Nothing on this page is
|
||||
// disabled: a speaker layout chosen while binaural output is active simply has
|
||||
// no effect until the output is switched back, and the status line says which
|
||||
// layout and how many channels that would be.
|
||||
void update_status() {
|
||||
const joc_lang::Language language = joc_lang::resolve(selected_language());
|
||||
const joc_settings::Values values = read_controls();
|
||||
|
||||
std::string output_status;
|
||||
if (values.output != 0) {
|
||||
char text[160] = {};
|
||||
char text[192] = {};
|
||||
const unsigned channels = joc_decode::speaker_channels(values.speaker_layout);
|
||||
joc_decode::LayoutDelivery delivery;
|
||||
const bool plain =
|
||||
joc_decode::layout_delivery(values.speaker_layout, &delivery) &&
|
||||
windows_speaker_config(delivery.mask);
|
||||
std::snprintf(text, sizeof(text), "扬声器布局 %s(%u 声道%s)",
|
||||
values.speaker_layout.c_str(), channels,
|
||||
plain ? "" : ",需要 ASIO 输出");
|
||||
std::snprintf(
|
||||
text, sizeof(text),
|
||||
joc_lang::get(language, joc_lang::Text::kSpeakerStatus),
|
||||
values.speaker_layout.c_str(), channels,
|
||||
plain ? "" : joc_lang::get(language, joc_lang::Text::kSpeakerStatusAsio));
|
||||
output_status = text;
|
||||
}
|
||||
set_text(GetDlgItem(m_hwnd, IDC_LABEL_OUTPUT_STATUS), output_status);
|
||||
|
||||
// The hint says what the switch does and what the other state means: the
|
||||
// renderer is float32 either way, so "24bit" is about the delivery, and
|
||||
// that is not something a checkbox label can carry on its own. The second
|
||||
// half matters because this switch changes what the component *reports*
|
||||
// about a file, and foobar2000 caches that per file: an item whose
|
||||
// information was read before the switch was flipped keeps the old format
|
||||
// until it is reloaded.
|
||||
set_text(GetDlgItem(m_hwnd, IDC_LABEL_INT24_HINT),
|
||||
values.force_int24
|
||||
? "开启:量化到 int24,超出 ±1 截断;切换后需刷新文件信息"
|
||||
: "关闭:按 32 位浮点交付(默认)");
|
||||
|
||||
joc_decode::Settings effective = joc_settings::current();
|
||||
effective.hrtf_source =
|
||||
static_cast<joc_decode::HrtfSource>(values.hrtf_source);
|
||||
effective.hrtf_source = static_cast<joc_decode::HrtfSource>(values.hrtf_source);
|
||||
effective.hrtf_file = values.hrtf_file;
|
||||
const std::string file = joc_decode::resolve_hrtf_file(effective);
|
||||
std::string hrtf_status =
|
||||
std::string(joc_settings::hrtf_source_name(values.hrtf_source)) + ":";
|
||||
if (values.hrtf_file.empty()) hrtf_status += "默认";
|
||||
hrtf_status += "\n" +
|
||||
(file.empty() ? std::string("无法确定默认路径") : file);
|
||||
const joc_lang::Text source = values.hrtf_source == joc_settings::HrtfSource::kRosella
|
||||
? joc_lang::Text::kHrtfSourceRosella
|
||||
: joc_lang::Text::kHrtfSourceSofa;
|
||||
std::string hrtf_status = joc_lang::get(language, source);
|
||||
hrtf_status += joc_lang::get(language, joc_lang::Text::kSeparator);
|
||||
if (values.hrtf_file.empty()) {
|
||||
hrtf_status += joc_lang::get(language, joc_lang::Text::kHrtfDefault);
|
||||
}
|
||||
hrtf_status += "\n";
|
||||
if (file.empty()) {
|
||||
hrtf_status += joc_lang::get(language, joc_lang::Text::kHrtfDefaultUnknown);
|
||||
} else {
|
||||
RECT status_rect{};
|
||||
GetClientRect(GetDlgItem(m_hwnd, IDC_LABEL_STATUS), &status_rect);
|
||||
hrtf_status += elide_path(GetDlgItem(m_hwnd, IDC_LABEL_STATUS), file,
|
||||
status_rect.right - 4);
|
||||
}
|
||||
set_text(GetDlgItem(m_hwnd, IDC_LABEL_STATUS), hrtf_status);
|
||||
|
||||
char gain[96] = {};
|
||||
if (values.gain_enabled) {
|
||||
std::snprintf(gain, sizeof(gain), "增益开 %.2f dB", values.gain_db);
|
||||
} else {
|
||||
std::snprintf(gain, sizeof(gain), "增益关(输出不衰减)");
|
||||
}
|
||||
std::snprintf(
|
||||
gain, sizeof(gain),
|
||||
joc_lang::get(language, values.gain_enabled ? joc_lang::Text::kGainStatusOn
|
||||
: joc_lang::Text::kGainStatusOff),
|
||||
values.gain_db);
|
||||
set_text(GetDlgItem(m_hwnd, IDC_LABEL_GAIN_STATUS), gain);
|
||||
}
|
||||
|
||||
@@ -412,6 +562,7 @@ private:
|
||||
if (now.gain_db != m_initial.gain_db) return true;
|
||||
if (now.tail_seconds != m_initial.tail_seconds) return true;
|
||||
if (now.ffmpeg_path != m_initial.ffmpeg_path) return true;
|
||||
if (now.language != m_initial.language) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -459,12 +610,19 @@ private:
|
||||
|
||||
class prefs_page : public preferences_page_v3 {
|
||||
public:
|
||||
const char* get_name() override { return "JOC 解码器"; }
|
||||
// The page name follows the language setting; foobar2000 asks for it when it
|
||||
// builds the tree, so a change shows up the next time the page is opened.
|
||||
const char* get_name() override {
|
||||
static std::string name;
|
||||
name = joc_lang::get(joc_lang::resolve(joc_settings::read().language),
|
||||
joc_lang::Text::kPageName);
|
||||
return name.c_str();
|
||||
}
|
||||
GUID get_guid() override { return kPrefsGuid; }
|
||||
GUID get_parent_guid() override { return preferences_page::guid_tools; }
|
||||
|
||||
preferences_page_instance::ptr instantiate(HWND parent,
|
||||
preferences_page_callback::ptr callback) override {
|
||||
preferences_page_callback::ptr callback) override {
|
||||
return fb2k::service_new<prefs_instance>(parent, callback);
|
||||
}
|
||||
};
|
||||
|
||||
+44
-32
@@ -7,51 +7,63 @@
|
||||
// sample page uses (SDK\foobar2000\foo_sample\foo_sample.rc). A CAPTION statement
|
||||
// implies WS_CAPTION, which would draw a second frame inside the host's and shift
|
||||
// every control down by the caption height -- visible but not clickable.
|
||||
IDD_JOC_PREFS DIALOGEX 0, 0, 330, 299
|
||||
//
|
||||
// The height is capped by what the host gives the page: it sizes the page window to
|
||||
// its own area and clips anything below it, without a scrollbar, so a page that is
|
||||
// too tall silently loses its lower groups. 268 dialog units keeps every group
|
||||
// inside the area at 96 and 125 percent scaling; tests/ui_text_fit_test.cpp fails
|
||||
// if the dialog grows past that.
|
||||
//
|
||||
// The texts below are the Chinese ones; the page replaces every one of them at
|
||||
// start-up with the string for the selected language (src/lang.cpp). Each control
|
||||
// is therefore as wide as the wider of its two texts.
|
||||
IDD_JOC_PREFS DIALOGEX 0, 0, 330, 268
|
||||
STYLE DS_SETFONT | WS_CHILD
|
||||
FONT 8, "Microsoft Sans Serif", 400, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "输出", IDC_GROUP_OUTPUT, 7, 5, 316, 86
|
||||
GROUPBOX "输出", IDC_GROUP_OUTPUT, 7, 4, 316, 72
|
||||
CONTROL "双耳(HRTF)", IDC_RADIO_BINAURAL, "Button",
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP, 16, 20, 72, 10
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP, 16, 15, 92, 10
|
||||
CONTROL "扬声器布局", IDC_RADIO_SPEAKER, "Button",
|
||||
BS_AUTORADIOBUTTON | WS_TABSTOP, 16, 38, 60, 10
|
||||
LTEXT "布局", IDC_LABEL_LAYOUT, 80, 39, 22, 10
|
||||
COMBOBOX IDC_COMBO_LAYOUT, 104, 36, 60, 120,
|
||||
BS_AUTORADIOBUTTON | WS_TABSTOP, 16, 28, 84, 10
|
||||
COMBOBOX IDC_COMBO_LAYOUT, 104, 25, 110, 160,
|
||||
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "双耳模式", IDC_LABEL_MODE, 172, 22, 42, 10
|
||||
COMBOBOX IDC_COMBO_MODE, 216, 19, 96, 90,
|
||||
LTEXT "双耳模式", IDC_LABEL_MODE, 16, 41, 66, 10
|
||||
COMBOBOX IDC_COMBO_MODE, 86, 38, 92, 90,
|
||||
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "房间尾音(秒)", IDC_LABEL_TAIL, 172, 41, 62, 10
|
||||
EDITTEXT IDC_EDIT_TAIL, 238, 38, 40, 13, ES_AUTOHSCROLL
|
||||
LTEXT "", IDC_LABEL_OUTPUT_STATUS, 16, 52, 300, 10
|
||||
LTEXT "房间尾音(秒)", IDC_LABEL_TAIL, 184, 41, 58, 10
|
||||
EDITTEXT IDC_EDIT_TAIL, 246, 38, 40, 13, ES_AUTOHSCROLL
|
||||
LTEXT "", IDC_LABEL_OUTPUT_STATUS, 16, 53, 300, 10
|
||||
CONTROL "强制 24bit 输出(int24)", IDC_CHECK_INT24, "Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP, 16, 64, 116, 10
|
||||
LTEXT "", IDC_LABEL_INT24_HINT, 16, 76, 300, 10
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP, 16, 65, 156, 10
|
||||
LTEXT "切换后需刷新文件信息", IDC_LABEL_INT24_HINT, 176, 65, 136, 10
|
||||
|
||||
GROUPBOX "HRTF", IDC_GROUP_HRTF, 7, 97, 316, 100
|
||||
GROUPBOX "HRTF", IDC_GROUP_HRTF, 7, 79, 316, 92
|
||||
CONTROL "SOFA 文件", IDC_RADIO_HRTF_SOFA, "Button",
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP, 16, 112, 56, 10
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP, 16, 91, 50, 10
|
||||
CONTROL "Rosella 个性化模型", IDC_RADIO_HRTF_ROSELLA, "Button",
|
||||
BS_AUTORADIOBUTTON | WS_TABSTOP, 78, 112, 78, 10
|
||||
LTEXT "HRTF 文件(留空=默认位置)", IDC_LABEL_HRTF, 16, 131, 106, 10
|
||||
EDITTEXT IDC_EDIT_HRTF, 126, 128, 148, 13, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "浏览…", IDC_BROWSE_HRTF, 279, 128, 38, 13
|
||||
LTEXT "留空时读组件目录下 HRTF\\binaural.sofa 或 binaural.personalized_headphone;SOFA 由渲染器内部编译,滤波组表已编入库中。",
|
||||
IDC_LABEL_HRTF_HINT, 16, 147, 300, 20
|
||||
LTEXT "", IDC_LABEL_STATUS, 16, 171, 300, 20
|
||||
BS_AUTORADIOBUTTON | WS_TABSTOP, 70, 91, 146, 10
|
||||
LTEXT "HRTF 文件", IDC_LABEL_HRTF, 16, 106, 40, 10
|
||||
EDITTEXT IDC_EDIT_HRTF, 58, 103, 186, 13, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "浏览…", IDC_BROWSE_HRTF, 248, 103, 52, 13
|
||||
LTEXT "留空时读组件目录下 HRTF\\binaural.sofa 或 HRTF\\binaural.personalized_headphone。",
|
||||
IDC_LABEL_HRTF_HINT, 16, 121, 300, 20
|
||||
LTEXT "", IDC_LABEL_STATUS, 16, 143, 300, 20
|
||||
|
||||
GROUPBOX "增益", IDC_GROUP_GAIN, 7, 202, 316, 48
|
||||
GROUPBOX "增益", IDC_GROUP_GAIN, 7, 174, 316, 42
|
||||
CONTROL "应用增益", IDC_CHECK_GAIN, "Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP, 16, 218, 58, 10
|
||||
LTEXT "dB", IDC_LABEL_GAIN, 80, 218, 12, 10
|
||||
EDITTEXT IDC_EDIT_GAIN, 96, 215, 40, 13, ES_AUTOHSCROLL
|
||||
LTEXT "", IDC_LABEL_GAIN_STATUS, 145, 218, 171, 10
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP, 16, 187, 48, 10
|
||||
LTEXT "dB", IDC_LABEL_GAIN, 68, 187, 12, 10
|
||||
EDITTEXT IDC_EDIT_GAIN, 84, 184, 44, 13, ES_AUTOHSCROLL
|
||||
LTEXT "", IDC_LABEL_GAIN_STATUS, 134, 187, 182, 10
|
||||
LTEXT "双耳渲染后可能超过 0 dBFS,可用负值衰减。",
|
||||
IDC_LABEL_GAIN_HINT, 16, 234, 300, 10
|
||||
IDC_LABEL_GAIN_HINT, 16, 202, 300, 10
|
||||
|
||||
GROUPBOX "其它", IDC_GROUP_MISC, 7, 255, 316, 38
|
||||
LTEXT "ffmpeg.exe", IDC_LABEL_FFMPEG, 16, 271, 44, 10
|
||||
EDITTEXT IDC_EDIT_FFMPEG, 64, 268, 210, 13, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "浏览…", IDC_BROWSE_FFMPEG, 279, 268, 38, 13
|
||||
GROUPBOX "其它", IDC_GROUP_MISC, 7, 219, 316, 48
|
||||
LTEXT "界面语言", IDC_LABEL_LANGUAGE, 16, 232, 34, 10
|
||||
COMBOBOX IDC_COMBO_LANGUAGE, 52, 229, 110, 90,
|
||||
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "ffmpeg.exe", IDC_LABEL_FFMPEG, 16, 252, 50, 10
|
||||
EDITTEXT IDC_EDIT_FFMPEG, 70, 249, 176, 13, ES_AUTOHSCROLL
|
||||
PUSHBUTTON "浏览…", IDC_BROWSE_FFMPEG, 250, 249, 50, 13
|
||||
END
|
||||
+2
-1
@@ -7,7 +7,6 @@
|
||||
#define IDC_RADIO_BINAURAL 2011
|
||||
#define IDC_RADIO_SPEAKER 2012
|
||||
#define IDC_COMBO_LAYOUT 2013
|
||||
#define IDC_LABEL_LAYOUT 2014
|
||||
#define IDC_LABEL_MODE 2015
|
||||
#define IDC_COMBO_MODE 2016
|
||||
#define IDC_LABEL_TAIL 2017
|
||||
@@ -37,3 +36,5 @@
|
||||
#define IDC_EDIT_FFMPEG 2042
|
||||
#define IDC_BROWSE_FFMPEG 2043
|
||||
#define IDC_LABEL_STATUS 2044
|
||||
#define IDC_LABEL_LANGUAGE 2045
|
||||
#define IDC_COMBO_LANGUAGE 2046
|
||||
+35
-2
@@ -33,6 +33,7 @@ constexpr GUID kGuidForceInt24 = {0xd2c67f41, 0x8b53, 0x4a2e, {0x97, 0x61, 0x0f,
|
||||
constexpr GUID kGuidObjectDelay = {0x5b2e9c18, 0xa640, 0x4d7b, {0x92, 0x0e, 0x37, 0xc5, 0x81, 0x6b, 0x2a, 0x54}};
|
||||
constexpr GUID kGuidThreads = {0xcb7a4015, 0x3f98, 0x4c62, {0xa0, 0x8d, 0x1b, 0x74, 0x29, 0xe6, 0x53, 0x0f}};
|
||||
constexpr GUID kGuidFfmpeg = {0x0e9d37c2, 0x5a18, 0x4b40, {0xb6, 0x3f, 0x88, 0x2d, 0x9a, 0x70, 0x1c, 0x65}};
|
||||
constexpr GUID kGuidLanguage = {0x58e17a04, 0x3d92, 0x4f6b, {0xa1, 0x27, 0x94, 0xc8, 0x0b, 0x6d, 0x53, 0xe1}};
|
||||
|
||||
cfg_uint g_output(kGuidOutput, 0);
|
||||
cfg_string g_layout(kGuidLayout, "7.1");
|
||||
@@ -50,6 +51,8 @@ cfg_bool g_force_int24(kGuidForceInt24, false);
|
||||
cfg_uint g_object_delay(kGuidObjectDelay, 1473);
|
||||
cfg_uint g_threads(kGuidThreads, 0);
|
||||
cfg_string g_ffmpeg(kGuidFfmpeg, "ffmpeg");
|
||||
// 0 = follow the Windows user-interface language, 1 = Chinese, 2 = English.
|
||||
cfg_uint g_language(kGuidLanguage, 0);
|
||||
|
||||
// Appends an optional trailing field to one of the fixed describe() buffers, so a
|
||||
// setting that is off leaves the line exactly as it was.
|
||||
@@ -112,10 +115,21 @@ const char* hrtf_default_file_name(HrtfSource source) {
|
||||
|
||||
Values defaults() { return Values(); }
|
||||
|
||||
namespace {
|
||||
|
||||
// The layout name the decoder should use for a stored or overridden value: "4.0"
|
||||
// is the spelling older configurations use for the layout the table calls 4.0
|
||||
// Surround, so every caller sees one of the names in the layout table.
|
||||
std::string canonical_layout(const std::string& layout) {
|
||||
return (layout == "4.0") ? std::string("4.0 Surround") : layout;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Values read() {
|
||||
Values values;
|
||||
values.output = static_cast<int>(static_cast<unsigned>(g_output));
|
||||
values.speaker_layout = g_layout.get_ptr();
|
||||
values.speaker_layout = canonical_layout(g_layout.get_ptr());
|
||||
// A layout the core does not accept (an old build offered several it never
|
||||
// accepted) would fail when the renderer is created, and the page cannot show it
|
||||
// either, because its list is the core's own table. Falling back here makes the
|
||||
@@ -141,6 +155,19 @@ Values read() {
|
||||
values.native_threads = static_cast<unsigned>(g_threads);
|
||||
values.ffmpeg_path = g_ffmpeg.get_ptr();
|
||||
if (values.ffmpeg_path.empty()) values.ffmpeg_path = "ffmpeg";
|
||||
const unsigned language = static_cast<unsigned>(g_language);
|
||||
values.language = language <= 2u ? static_cast<joc_lang::Language>(language)
|
||||
: joc_lang::Language::kSystem;
|
||||
// The page and the messages both read this far, so the development override
|
||||
// lives here rather than in current(), where only the decoder would see it.
|
||||
std::string text;
|
||||
if (env_string("JOC_LANGUAGE", &text)) {
|
||||
values.language = (text == "en" || text == "english")
|
||||
? joc_lang::Language::kEnglish
|
||||
: (text == "zh" || text == "chinese")
|
||||
? joc_lang::Language::kChineseSimplified
|
||||
: joc_lang::Language::kSystem;
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
@@ -157,6 +184,7 @@ void write(const Values& values) {
|
||||
g_object_delay = values.object_delay_samples;
|
||||
g_threads = values.native_threads;
|
||||
g_ffmpeg = values.ffmpeg_path.c_str();
|
||||
g_language = static_cast<unsigned>(values.language);
|
||||
}
|
||||
|
||||
joc_decode::Settings current() {
|
||||
@@ -164,7 +192,7 @@ joc_decode::Settings current() {
|
||||
|
||||
std::string text;
|
||||
if (env_string("JOC_OUTPUT", &text)) values.output = (text == "speaker") ? 1 : 0;
|
||||
(void)env_string("JOC_LAYOUT", &values.speaker_layout);
|
||||
if (env_string("JOC_LAYOUT", &text)) values.speaker_layout = canonical_layout(text);
|
||||
(void)env_string("JOC_HRTF", &values.hrtf_file);
|
||||
if (env_string("JOC_HRTF_SOURCE", &text)) {
|
||||
values.hrtf_source = (text == "rosella") ? HrtfSource::kRosella : HrtfSource::kSofa;
|
||||
@@ -236,6 +264,11 @@ std::string describe(const Values& values) {
|
||||
values.tail_seconds, values.object_delay_samples, values.native_threads,
|
||||
values.ffmpeg_path.c_str());
|
||||
append_to(text, values.force_int24 ? " int24=forced" : "");
|
||||
append_to(text, values.language == joc_lang::Language::kSystem
|
||||
? " language=system"
|
||||
: (values.language == joc_lang::Language::kEnglish
|
||||
? " language=english"
|
||||
: " language=chinese"));
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "joc_decode.h"
|
||||
#include "lang.h"
|
||||
|
||||
namespace joc_settings {
|
||||
|
||||
@@ -45,6 +46,9 @@ struct Values {
|
||||
unsigned object_delay_samples = 1473;
|
||||
unsigned native_threads = 0;
|
||||
std::string ffmpeg_path = "ffmpeg";
|
||||
// Language of the page, the status lines and the messages; kSystem follows
|
||||
// the Windows user-interface language. Decoding and rendering never read it.
|
||||
joc_lang::Language language = joc_lang::Language::kSystem;
|
||||
};
|
||||
|
||||
Values defaults();
|
||||
|
||||
Reference in new issue
Block a user