Support the two 4.0 layouts and localize the preferences page
build / windows (push) Has been cancelled
build / release (push) Has been cancelled

This commit is contained in:
TheM14 committed 2026-10-27 23:51:57 +08:00
1 parent 0b9f3321fd
commit dc3372be27
21 files changed
+1149 -185

No files matched your search

+42 -22
View File
@@ -59,10 +59,10 @@ Matroska/WebM Reader** in that list. Bare `.eac3` / `.ec3` files do not depend o
Preferences → Tools → **JOC decoder**:
* **Output** — binaural, or a speaker layout from 2.0 to 9.1.6 (see
[Speaker layouts and channel order](#speaker-layouts-and-channel-order));
* **Output** — **Binaural (HRTF)**, or a **Speaker layout** from 2.0 to 9.1.6 (names and channel order
in the [table below](#speaker-layouts-and-channel-order));
* **Binaural mode** (near / mid / far) and the room **tail** in seconds;
* **HRTF source** — a **SOFA** file or a **Rosella** `.personalized_headphone` model. An empty
* **HRTF** — a **SOFA file** or a **Rosella personalized model**. An empty
path means the default location, `<component directory>\HRTF\binaural.sofa` or
`binaural.personalized_headphone`;
* **Gain** — a switch and a value in dB. Binaural rendering can exceed full scale on material
@@ -76,9 +76,17 @@ Preferences → Tools → **JOC decoder**:
from the Media Library and add it again): foobar2000 caches technical information per file, and
until it is reloaded Properties and the Converter still go by the old 32-bit floating-point
answer, warning that the encoder does not take floating-point input.
* the **ffmpeg** executable to use.
* the **ffmpeg.exe** executable to use.
* **Language** — **Follow system** / **简体中文** / **English**. Every string on the page, the status
lines and the errors a user can see use the selected language, and switching takes effect
immediately; the choice is stored in the component's own configuration. "Follow system" goes by
the Windows user-interface language: Chinese (including Traditional) reads the simplified Chinese
column, everything else reads English. The setting only affects interface text; decoding and
rendering never read it.
No control on the page is disabled, and the status line states what is in effect.
No control on the page is disabled, and the status line states what is in effect. The control names
above are the English ones; the Chinese page names the same controls 输出, 扬声器布局, 双耳模式,
HRTF 文件, 增益.
### Speaker layouts and channel order
@@ -86,6 +94,8 @@ No control on the page is disabled, and the status line states what is in effect
|---|---|---|---|
| 2.0 | 2 | `0x3` | FL FR |
| 3.1 | 4 | `0xF` | FL FR FC LFE |
| 4.0 Surround | 4 | `0x107` | FL FR FC BC |
| 4.0 Quad | 4 | `0x33` | FL FR BL BR |
| 5.1 | 6 | `0x3F` | FL FR FC LFE BL BR |
| 7.1 | 8 | `0x63F` | FL FR FC LFE BL BR SL SR |
| 5.1.2 | 8 | `0x560F` | FL FR FC LFE SL SR TFL TFR |
@@ -95,27 +105,36 @@ No control on the page is disabled, and the status line states what is in effect
| 9.1.4 | 14 | `0x2D6FF` | FL FR FC LFE BL BR FCL FCR SL SR TFL TFR TBL TBR |
| 9.1.6 | 16 | `0x3F6FF` | FL FR FC LFE BL BR FCL FCR SL SR TFL TFC TFR TBL TBC TBR |
**There are two 4.0 layouts, and they are different speaker sets, not two spellings of one layout.**
**4.0 Surround** is a front trio plus one back-centre speaker (`FL FR FC BC`; the renderer calls the
channels `L R C Cs`). **4.0 Quad** is a front and a back pair (`FL FR BL BR`; `L R Lrs Rrs`) with
neither a centre nor an LFE — an object straight ahead is a phantom image of the front pair, and the
LFE in the input has no output channel in this layout, so by the core's rule it is not mixed into
the others. Older builds had only the name `4.0`, which always meant the surround layout: the core
resolves `4.0` as an alias for `4.0 Surround` (the page shows `4.0 Surround`, and an applied page
stores the explicit name), and Quad has to be asked for as `4.0 Quad`.
The renderer emits the reference implementation's channel order (for 9.1.4: L R C LFE Lrs Rrs Ls Rs
Ltf Rtf Ltr Rtr Lw Rw), while foobar2000 defines the interleaved order as the ascending order of the
channel mask's speaker bits. The two agree for 2.0 through 7.1.4; 9.1.4 and 9.1.6 carry the wide
pair last, so the channels are permuted into mask order before delivery (the log says `channels
permuted into mask order`). The table above is that order; Properties shows the matching
`WAVEFORMATEXTENSIBLE_CHANNEL_MASK`, and the Converter writes files in the same order.
channel mask's speaker bits. The two agree for 2.0 through 7.1.4 (both 4.0 layouts included); 9.1.4
and 9.1.6 carry the wide pair last, so the channels are permuted into mask order before delivery
(the log says `channels permuted into mask order`). The table above is that order; Properties shows
the matching `WAVEFORMATEXTENSIBLE_CHANNEL_MASK`, and the Converter writes files in the same order.
The mask follows ffmpeg's definition of the same layout name (`5.1` is BL/BR, `5.1.2` and up are
SL/SR, the wide pair is FCL/FCR), so a layout name means the same thing in the component, in a
converted file and in other tools. **9.1.6's top-middle pair (Ltm/Rtm) has no WAVE position** — ffmpeg
places it at TSL/TSR, beyond a 32-bit mask — so it is delivered at the two centre positions the mask
has left, TFC and TBC: the mask still has exactly one bit per channel and the order is the one in the
table, at the cost of those two channels being labelled top front centre / top back centre in
foobar2000's channel lists.
SL/SR, the wide pair is FCL/FCR, `4.0` is FL FR FC BC), so a layout name means the same thing in the
component, in a converted file and in other tools. **9.1.6's top-middle pair (Ltm/Rtm) has no WAVE
position** — ffmpeg places it at TSL/TSR, beyond a 32-bit mask — so it is delivered at the two centre
positions the mask has left, TFC and TBC: the mask still has exactly one bit per channel and the
order is the one in the table, at the cost of those two channels being labelled top front centre /
top back centre in foobar2000's channel lists.
**Layouts other than 2.0 / 5.1 / 7.1 need ASIO (or an exclusive output that accepts the
layout).** foobar2000's shared and exclusive outputs follow the Windows speaker configuration, of
which those are the only multichannel ones; ASIO has no such limit and maps the channels in the
order the component delivers them (assign them by name in fb2k's ASIO channel mapping). With such a
layout on a system-configured output the core downmixes the extra channels — audible, but those
channels are not heard; the Converter is not bound by the output device and writes 14- or
**Windows itself has only the 2.0 / 5.1 / 7.1 speaker configurations, so every other layout (3.1,
both 4.0 layouts, anything with height or wide channels) needs ASIO (or an exclusive output that
accepts the layout) on shared and exclusive output.** ASIO has no such limit and maps the channels
in the order the component delivers them (assign them by name in fb2k's ASIO channel mapping). With
such a layout on a system-configured output the core downmixes the extra channels — audible, but
those channels are not heard; the Converter is not bound by the output device and writes 4-, 14- or
16-channel files as configured. The preferences status line says "needs ASIO output" when such a
layout is selected.
@@ -140,7 +159,8 @@ byte-for-byte acceptance rests on, so it must not be changed. `foo_input_joc.vcx
`kernel/` are compiled with `JOC_STATIC` / `EJOC_STATIC`, so their entry points are neither
imported nor exported. `tests\` holds the offline tools (bitstream self-test and cross-check,
render comparison, speaker-layout table and channel-order check, preferences-page layout check,
container-probe check) and `tools\` the build and test-bed scripts. Settings also read `JOC_*`
Chinese and English text-width check, container-probe check) and `tools\` the build and test-bed
scripts. Settings also read `JOC_*`
environment overrides for one run (development only); the list and what each one does is in
`src\settings.cpp`.
+35 -21
View File
@@ -50,22 +50,26 @@ Matroska/WebM Reader** 之前。裸流 `.eac3` / `.ec3` 不受这个顺序影响
## 设置
Preferences → Tools → **JOC decoder**:
Preferences → Tools → **JOC 解码器**:
* **Output** —— 双耳,或 2.0 到 9.1.6 的扬声器布局(见[扬声器布局与声道顺序](#扬声器布局与声道顺序));
* **Binaural mode**(near / mid / far)与房间 **tail** 秒数;
* **HRTF source** —— **SOFA** 文件或 **Rosella** `.personalized_headphone` 模型。路径留空表示
* **输出** —— **双耳(HRTF)**,或 **扬声器布局**:2.0 到 9.1.6,布局名与声道顺序见[下表](#扬声器布局与声道顺序);
* **双耳模式**(near / mid / far)与房间**尾音**秒数;
* **HRTF** —— **SOFA 文件**或 **Rosella 个性化模型**。路径留空表示
用默认位置 `<组件目录>\HRTF\` 下的 `binaural.sofa` 或 `binaural.personalized_headphone`;
* **Gain** —— 开关加 dB 值。双耳渲染在核心混音不削顶的素材上也可能超过满刻度,衰减放在这里;
* **增益** —— 开关加 dB 值。双耳渲染在核心混音不削顶的素材上也可能超过满刻度,衰减放在这里;
* **强制 24bit 输出(int24)** —— 默认关闭,交付 float32。打开后,交付前按内核写 WAV 的 int24
规则量化(截到 ±1 → ×8388607 → 截断),超范围的样本被截断到边缘、次数记进日志;组件同时把该
文件的技术信息报成 24bit 定点。渲染本身仍是 float32,这一项说的是交付给 foobar2000 的采样精度,
不是输出设备的位深(那个在 Preferences → Output 里设置)。**切换这个开关后要刷新文件信息**
(Properties → Reload info,或把文件从媒体库移除后重新加入):foobar2000 按文件缓存技术信息,
缓存没刷新时 Properties 与转换器仍按旧的 32bit 浮点判断,会提示"编码器不支持浮点输入"。
* **ffmpeg** 可执行文件路径。
* **ffmpeg.exe** 可执行文件路径。
* **界面语言** —— **跟随系统** / **简体中文** / **English**。设置页的全部文字、状态行和用户可见的
错误信息都用这一项选定的语言,切换后立刻生效;选择存在组件自己的配置里。"跟随系统"按 Windows 的
界面语言决定:中文(含繁体)用简体中文,其它语言用英文。这一项只影响界面文字,解码与渲染不读它。
页面上的控件都不禁用,状态行会说明当前生效的是什么。
页面上的控件都不禁用,状态行会说明当前生效的是什么。中文页面的控件名与上表一致,英文页面是同一些
控件的译文(例如 **Output**、**Speaker layout**、**Binaural mode**、**HRTF file**、**Apply gain**)。
### 扬声器布局与声道顺序
@@ -73,6 +77,8 @@ Preferences → Tools → **JOC decoder**:
|---|---|---|---|
| 2.0 | 2 | `0x3` | FL FR |
| 3.1 | 4 | `0xF` | FL FR FC LFE |
| 4.0 Surround | 4 | `0x107` | FL FR FC BC |
| 4.0 Quad | 4 | `0x33` | FL FR BL BR |
| 5.1 | 6 | `0x3F` | FL FR FC LFE BL BR |
| 7.1 | 8 | `0x63F` | FL FR FC LFE BL BR SL SR |
| 5.1.2 | 8 | `0x560F` | FL FR FC LFE SL SR TFL TFR |
@@ -82,23 +88,31 @@ Preferences → Tools → **JOC decoder**:
| 9.1.4 | 14 | `0x2D6FF` | FL FR FC LFE BL BR FCL FCR SL SR TFL TFR TBL TBR |
| 9.1.6 | 16 | `0x3F6FF` | FL FR FC LFE BL BR FCL FCR SL SR TFL TFC TFR TBL TBC TBR |
**4.0 有两个布局,它们是不同的扬声器集合,不是同一个布局的两种叫法。** **4.0 Surround** 是前置
三声道加一只后中(`FL FR FC BC`,渲染内核里的名字是 `L R C Cs`);**4.0 Quad** 是前后各一对
(`FL FR BL BR`,内核里是 `L R Lrs Rrs`),既没有中置也没有 LFE——对象在正前方时由左右两只音箱
合成幻像中置,输入里的 LFE 在这种布局下没有输出声道,按内核规则不混入其它声道。旧版本只有 `4.0`
一个名字,含义一直是 Surround,因此读到 `4.0` 时按 `4.0 Surround` 处理(设置页显示为
`4.0 Surround`,应用一次设置后存的就是显式名字);要 Quad 必须写 `4.0 Quad`。
渲染内核按参考实现的顺序产生声道(9.1.4 是 L R C LFE Lrs Rrs Ls Rs Ltf Rtf Ltr Rtr Lw Rw),
而 foobar2000 规定"帧内声道顺序 = 通道掩码中声道位的升序"。两者对 2.0 到 7.1.4 恰好一致;
9.1.4 与 9.1.6 的宽声道排在后面,所以交付前按掩码顺序重排(日志里写 `channels permuted into
而 foobar2000 规定"帧内声道顺序 = 通道掩码中声道位的升序"。两者对 2.0 到 7.1.4(含两种 4.0)恰好
一致;9.1.4 与 9.1.6 的宽声道排在后面,所以交付前按掩码顺序重排(日志里写 `channels permuted into
mask order`)。上表就是这个顺序;Properties 里能看到对应的 `WAVEFORMATEXTENSIBLE_CHANNEL_MASK`,
转换器写文件时也按同一个顺序落盘。
掩码取 ffmpeg 对同名布局的定义(`5.1` 是 BL/BR,`5.1.2` 起是 SL/SR,宽声道是 FCL/FCR),这样同一
个布局名在组件、转换产物与其它工具里含义一致。**9.1.6 的顶层中间声道对(Ltm/Rtm)在 WAVE 的 18
个声道位里没有对应位置**(ffmpeg 用 32 位掩码之外的 TSL/TSR),因此按 TFL/TFC/TFR/TBL/TBC/TBR 中
剩下的两个居中位置 TFC 与 TBC 交付:掩码仍然是一位声道一个位,顺序如上表,代价是这两路在
foobar2000 的声道列表里显示为顶前排中、顶后排中。
掩码取 ffmpeg 对同名布局的定义(`5.1` 是 BL/BR,`5.1.2` 起是 SL/SR,宽声道是 FCL/FCR,`4.0` 是
FL FR FC BC),这样同一个布局名在组件、转换产物与其它工具里含义一致。**9.1.6 的顶层中间声道对
(Ltm/Rtm)在 WAVE 的 18 个声道位里没有对应位置**(ffmpeg 用 32 位掩码之外的 TSL/TSR),因此按
TFL/TFC/TFR/TBL/TBC/TBR 中剩下的两个居中位置 TFC 与 TBC 交付:掩码仍然是一位声道一个位,顺序如
上表,代价是这两路在 foobar2000 的声道列表里显示为顶前排中、顶后排中。
**2.0 / 5.1 / 7.1 之外的布局需要 ASIO(或接受该布局的独占输出)。** foobar2000 的共享与独占输出
跟随 Windows 的扬声器配置,只有这几个配置;高度声道、宽声道与超过 8 声道的布局 ASIO 没有限制,声道
按组件交付的顺序对应到设备的输出通道(用 fb2k 的 ASIO 声道映射按名称分配)。用这样的布局而输出仍
走系统配置时,核心会把多出来的声道下混——能听到声音,但听不到那几路;转换器(Converter)不受输出
设备限制,可以按布局写出 14/16 声道的文件。设置页的状态行在选中这类布局时会写"需要 ASIO 输出"。
**Windows 自己只有 2.0 / 5.1 / 7.1 三种扬声器配置,其余布局(3.1、两种 4.0、所有带高度或宽声道的
布局)的共享与独占输出都需要 ASIO(或接受该布局的独占输出)。** 高度声道、宽声道、后中与超过 8
声道的布局 ASIO 没有限制,声道按组件交付的顺序对应到设备的输出通道(用 fb2k 的 ASIO 声道映射按名称
分配)。用这样的布局而输出仍走系统配置时,核心会把多出来的声道下混——能听到声音,但听不到那几路;
转换器(Converter)不受输出设备限制,可以按布局写出 4/14/16 声道的文件。设置页的状态行在选中这类
布局时会写"需要 ASIO 输出"。
### HRTF 数据
@@ -117,8 +131,8 @@ pwsh -File tools/package.ps1 # 两个架构,打包到 dist\*.fb2k-c
配置固定为 `Release-Static`(静态 CRT,`/MT`);`/fp:precise` 是逐字节验收的前提,不要改。
`foo_input_joc.vcxproj` 通过项目引用先构建 `kernel\joc_kernel.vcxproj`;`kernel/` 里的渲染内核
源码以 `JOC_STATIC` / `EJOC_STATIC` 编译,入口既不导入也不导出。`tests\` 是离线工具(码流
自检与交叉核对、渲染比对、布局表与频道顺序检查、设置页布局检查、容器探测检查),`tools\` 是构建
与测试床脚本。设置项另有 `JOC_*` 环境变量覆盖(仅用于开发运行),清单与含义在 `src\settings.cpp`。
自检与交叉核对、渲染比对、布局表与频道顺序检查、设置页布局检查、中英文文字宽度检查、容器探测
检查),`tools\` 是构建与测试床脚本。设置项另有 `JOC_*` 环境变量覆盖(仅用于开发运行),清单与含义在 `src\settings.cpp`。
排查问题看 DLL 旁边的 `joc_decoder.log`;组件启动时会把自己的版本、核心版本、日志路径写在
里面。日志按**字节**封顶:单个文件写满 16 MiB 就滚到同目录的 `joc_decoder.log.1`(覆盖上一次
+2
View File
@@ -99,6 +99,7 @@
<ClCompile Include="src\eac3_scan.cpp" />
<ClCompile Include="src\input_joc.cpp" />
<ClCompile Include="src\joc_decode.cpp" />
<ClCompile Include="src\lang.cpp" />
<ClCompile Include="src\log.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\prefs.cpp" />
@@ -110,6 +111,7 @@
<ClInclude Include="src\eac3_scan.h" />
<ClInclude Include="src\joc_decode.h" />
<ClInclude Include="src\joc_pch.h" />
<ClInclude Include="src\lang.h" />
<ClInclude Include="src\log.h" />
<ClInclude Include="src\prefs.h" />
<ClInclude Include="src\resource.h" />
+2 -2
View File
@@ -9,8 +9,8 @@
#define JOC_VERSION_H
#define JOC_VERSION_MAJOR 1
#define JOC_VERSION_MINOR 0
#define JOC_VERSION_MINOR 1
#define JOC_VERSION_PATCH 0
#define JOC_VERSION_STRING "1.0.0"
#define JOC_VERSION_STRING "1.1.0"
#endif /* JOC_VERSION_H */
+1 -1
View File
@@ -84,7 +84,7 @@ struct Options {
};
const char* kLayoutChoices =
"2.0 3.0 3.1 4.0 5.0 5.1 5.1.2 5.1.4 6.1 7.0 7.1 7.1.2 7.1.4 9.1.4 9.1.6 22.2";
"2.0 3.1 \"4.0 Surround\" \"4.0 Quad\" 5.1 7.1 5.1.2 5.1.4 7.1.2 7.1.4 9.1.4 9.1.6";
void print_usage() {
std::printf(
@@ -15,6 +15,8 @@ struct FrozenLayout {
constexpr FrozenLayout kLayouts[kLayoutCount] = {
{"2.0", 0, 1},
{"3.1", 3, 7},
{"4.0 Surround", 0xFF, 35},
{"4.0 Quad", 0xFF, 9},
{"5.1", 7, 15},
{"7.1", 11, 31},
{"5.1.2", 13, 1039},
@@ -25,6 +27,14 @@ constexpr FrozenLayout kLayouts[kLayoutCount] = {
{"9.1.6", 20, 3743},
};
// Spellings accepted in addition to the names above.
constexpr struct {
const char* alias;
const char* name;
} kAliases[] = {
{"4.0", "4.0 Surround"},
};
void fill(const FrozenLayout& source, LayoutInfo* out) {
out->name = source.name;
out->out_ch_config = source.out_ch_config;
@@ -52,6 +62,11 @@ bool layout_by_name(const char* name, LayoutInfo* out) {
return true;
}
}
for (const auto& alias : kAliases) {
if (std::strcmp(name, alias.alias) == 0) {
return layout_by_name(alias.name, out);
}
}
return false;
}
+6 -3
View File
@@ -8,7 +8,7 @@
namespace joc::speaker {
inline constexpr int kLayoutCount = 10;
inline constexpr int kLayoutCount = 12;
struct LayoutInfo {
const char* name = "";
@@ -17,10 +17,13 @@ struct LayoutInfo {
std::uint32_t channel_count = 0;
};
// All ten layouts in the reference's order (2.0, 3.1, 5.1, 7.1, 5.1.2, 5.1.4,
// All twelve layouts in the reference's order (2.0, 3.1, 4.0 Surround, 4.0 Quad,
// 5.1, 7.1, 5.1.2, 5.1.4, 7.1.2, 7.1.4, 9.1.4, 9.1.6).
bool layout_at(int index, LayoutInfo* out);
// False when the name is unknown (case-sensitive, exactly as the reference CLI).
// False when the name is unknown (case-sensitive, as the reference CLI). The
// legacy spelling "4.0" resolves to 4.0 Surround, which is what that name meant
// before the two 4.0 layouts were told apart.
bool layout_by_name(const char* name, LayoutInfo* out);
bool layout_by_bitfield(std::uint32_t bitfield, LayoutInfo* out);
+97 -1
View File
@@ -39,7 +39,7 @@ struct LayoutGeometry {
std::array<RegionGeometry, 7> regions{};
};
inline constexpr std::array<LayoutGeometry, 10> kLayouts{{
inline constexpr std::array<LayoutGeometry, 12> kLayouts{{
LayoutGeometry{
0x1u, 0, 2,
{{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
@@ -136,6 +136,102 @@ inline constexpr std::array<LayoutGeometry, 10> kLayouts{{
}
}}
},
LayoutGeometry{
0x23u, 0xFFu, 4,
{{0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{{
RegionGeometry{
4, 2, 2, 0,
{{SpeakerPoint{{0, 0, 0}, 0}, SpeakerPoint{{32767, 0, 0}, 1}, SpeakerPoint{{16384, 0, 0}, 2}, SpeakerPoint{{16384, 32767, 0}, 3}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{3, {0, 2, 1}}, AxisGroup{1, {3, 0, 0}}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
3, 1, 1, 0,
{{SpeakerPoint{{0, 0, 0}, 0}, SpeakerPoint{{32767, 0, 0}, 1}, SpeakerPoint{{16384, 0, 0}, 2}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{3, {0, 2, 1}}, AxisGroup{}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
4, 2, 2, 0,
{{SpeakerPoint{{0, 0, 0}, 0}, SpeakerPoint{{32767, 0, 0}, 1}, SpeakerPoint{{16384, 0, 0}, 2}, SpeakerPoint{{16384, 32767, 0}, 3}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{3, {0, 2, 1}}, AxisGroup{1, {3, 0, 0}}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
2, 2, 2, 0,
{{SpeakerPoint{{16384, 0, 0}, 2}, SpeakerPoint{{16384, 32767, 0}, 3}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{1, {0, 0, 0}}, AxisGroup{1, {1, 0, 0}}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
3, 1, 1, 0,
{{SpeakerPoint{{0, 0, 0}, 0}, SpeakerPoint{{32767, 0, 0}, 1}, SpeakerPoint{{16384, 0, 0}, 2}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{3, {0, 2, 1}}, AxisGroup{}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
1, 1, 1, 0,
{{SpeakerPoint{{16384, 32767, 0}, 3}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{1, {0, 0, 0}}, AxisGroup{}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
3, 1, 1, 0,
{{SpeakerPoint{{0, 0, 0}, 0}, SpeakerPoint{{32767, 0, 0}, 1}, SpeakerPoint{{16384, 0, 0}, 2}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{3, {0, 2, 1}}, AxisGroup{}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
}
}}
},
LayoutGeometry{
0x9u, 0xFFu, 4,
{{0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{{
RegionGeometry{
4, 2, 2, 0,
{{SpeakerPoint{{0, 0, 0}, 0}, SpeakerPoint{{32767, 0, 0}, 1}, SpeakerPoint{{0, 32767, 0}, 2}, SpeakerPoint{{32767, 32767, 0}, 3}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{2, {0, 1, 0}}, AxisGroup{2, {2, 3, 0}}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
4, 2, 2, 0,
{{SpeakerPoint{{0, 0, 0}, 0}, SpeakerPoint{{32767, 0, 0}, 1}, SpeakerPoint{{0, 32767, 0}, 2}, SpeakerPoint{{32767, 32767, 0}, 3}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{2, {0, 1, 0}}, AxisGroup{2, {2, 3, 0}}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
4, 2, 2, 0,
{{SpeakerPoint{{0, 0, 0}, 0}, SpeakerPoint{{32767, 0, 0}, 1}, SpeakerPoint{{0, 32767, 0}, 2}, SpeakerPoint{{32767, 32767, 0}, 3}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{2, {0, 1, 0}}, AxisGroup{2, {2, 3, 0}}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
2, 1, 1, 0,
{{SpeakerPoint{{0, 32767, 0}, 2}, SpeakerPoint{{32767, 32767, 0}, 3}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{2, {0, 1, 0}}, AxisGroup{}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
2, 1, 1, 0,
{{SpeakerPoint{{0, 0, 0}, 0}, SpeakerPoint{{32767, 0, 0}, 1}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{2, {0, 1, 0}}, AxisGroup{}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
2, 1, 1, 0,
{{SpeakerPoint{{0, 32767, 0}, 2}, SpeakerPoint{{32767, 32767, 0}, 3}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{2, {0, 1, 0}}, AxisGroup{}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
},
RegionGeometry{
2, 1, 1, 0,
{{SpeakerPoint{{0, 0, 0}, 0}, SpeakerPoint{{32767, 0, 0}, 1}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}, SpeakerPoint{}}},
{{AxisGroup{2, {0, 1, 0}}, AxisGroup{}, AxisGroup{}, AxisGroup{}}},
{{AxisGroup{}, AxisGroup{}, AxisGroup{}, AxisGroup{}}}
}
}}
},
LayoutGeometry{
0xFu, 7, 6,
{{0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
+23 -9
View File
@@ -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
View File
@@ -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;
}
+96
View File
@@ -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
View File
@@ -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
+11
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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;
}
+4
View File
@@ -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();
+6 -2
View File
@@ -62,6 +62,8 @@ struct Expected {
const Expected kExpected[] = {
{"2.0", "L R", "L R", 0x3},
{"3.1", "L R C LFE", "L R C LFE", 0xF},
{"4.0 Surround", "L R C Cs", "L R C Cs", 0x107},
{"4.0 Quad", "L R Lrs Rrs", "L R Lrs Rrs", 0x33},
{"5.1", "L R C LFE Ls Rs", "L R C LFE Ls Rs", 0x3F},
{"7.1", "L R C LFE Lrs Rrs Ls Rs", "L R C LFE Lrs Rrs Ls Rs", 0x63F},
{"5.1.2", "L R C LFE Ls Rs Ltm Rtm", "L R C LFE Ls Rs Ltm Rtm", 0x560F},
@@ -198,8 +200,10 @@ int main() {
for (const Expected& expected : kExpected) check_layout(expected);
// Names the table must not claim: the page used to offer these, and the kernel
// rejects every one of them.
for (const char* rejected : {"3.0", "4.0", "5.0", "6.1", "7.0", "22.2", ""}) {
// rejects every one of them. ("4.0" is not in this list: the kernel resolves it
// to 4.0 Surround for old configurations, and the settings migration rewrites it
// to the explicit name.)
for (const char* rejected : {"3.0", "5.0", "6.1", "7.0", "22.2", ""}) {
check(joc_decode::speaker_channels(rejected) == 0, "unsupported layout rejected",
rejected);
joc_decode::LayoutDelivery delivery;
+389
View File
@@ -0,0 +1,389 @@
// Measures every user-visible string of the preferences page against the control
// it is shown in, in both languages.
//
// ui_text_fit_test <path to foo_input_joc.dll>
//
// The page is bilingual, and the wider language is not always the translated one:
// "4.0 Surround" does not fit where "4.0" did. This check creates the dialog from
// the component's own resource (the same way the component does), then measures
// each string with the control's own font and compares it with the space that
// control has. Multi-line static controls are wrapped at word boundaries, so a
// hint that needs one line too many is reported as well.
//
// The text itself comes from src/lang.cpp, so the check covers both languages with
// the strings that ship; the mapping below mirrors what the page applies.
//
// The component imports the SDK helpers from the host's shared.dll, so that file
// has to sit beside this executable (and beside the component).
#include <windows.h>
#include <cstdio>
#include <string>
#include <vector>
#include "../src/lang.h"
#include "../src/joc_decode.h"
#include "../src/resource.h"
namespace {
int g_failures = 0;
std::string narrow(const wchar_t* text) {
if (text == nullptr || *text == L'\0') return {};
const int needed = WideCharToMultiByte(CP_UTF8, 0, text, -1, nullptr, 0, nullptr, nullptr);
std::string out(static_cast<std::size_t>(needed), '\0');
WideCharToMultiByte(CP_UTF8, 0, text, -1, out.data(), needed, nullptr, nullptr);
if (!out.empty() && out.back() == '\0') out.pop_back();
return out;
}
std::wstring widen(const char* text) {
if (text == nullptr || *text == '\0') return {};
const int needed = MultiByteToWideChar(CP_UTF8, 0, text, -1, nullptr, 0);
std::wstring out(static_cast<std::size_t>(needed), L'\0');
MultiByteToWideChar(CP_UTF8, 0, text, -1, out.data(), needed);
if (!out.empty() && out.back() == L'\0') out.pop_back();
return out;
}
class Measurer {
public:
Measurer() {
dc_ = CreateCompatibleDC(nullptr);
SetMapMode(dc_, MM_TEXT);
}
~Measurer() {
if (dc_ != nullptr) DeleteDC(dc_);
}
int width(const std::wstring& text, HFONT font) {
HGDIOBJ previous = nullptr;
if (font != nullptr) previous = SelectObject(dc_, font);
SIZE size{};
GetTextExtentPoint32W(dc_, text.c_str(), static_cast<int>(text.size()), &size);
if (previous != nullptr) SelectObject(dc_, previous);
return size.cx;
}
int line_height(HFONT font) {
HGDIOBJ previous = nullptr;
if (font != nullptr) previous = SelectObject(dc_, font);
TEXTMETRICW metrics{};
GetTextMetricsW(dc_, &metrics);
if (previous != nullptr) SelectObject(dc_, previous);
return metrics.tmHeight + metrics.tmExternalLeading;
}
// Greedy word wrap: how many lines the text needs at this width.
int lines(const std::wstring& text, HFONT font, int available) {
int count = 1;
int used = 0;
std::wstring word;
for (std::size_t i = 0; i <= text.size(); ++i) {
const wchar_t ch = i < text.size() ? text[i] : L' ';
if (ch == L' ' || ch == L'\n' || i == text.size()) {
if (!word.empty()) {
const int word_width = width(word, font);
if (used != 0 && used + width(L" ", font) + word_width > available) {
++count;
used = word_width;
} else {
used += (used != 0 ? width(L" ", font) : 0) + word_width;
}
word.clear();
}
if (ch == L'\n') {
++count;
used = 0;
}
} else {
word.push_back(ch);
}
}
return count;
}
private:
HDC dc_ = nullptr;
};
struct Binding {
int control;
joc_lang::Text text;
};
const Binding kBindings[] = {
{IDC_GROUP_OUTPUT, joc_lang::Text::kGroupOutput},
{IDC_RADIO_BINAURAL, joc_lang::Text::kRadioBinaural},
{IDC_RADIO_SPEAKER, joc_lang::Text::kRadioSpeaker},
{IDC_LABEL_MODE, joc_lang::Text::kLabelMode},
{IDC_LABEL_TAIL, joc_lang::Text::kLabelTail},
{IDC_CHECK_INT24, joc_lang::Text::kCheckInt24},
{IDC_LABEL_INT24_HINT, joc_lang::Text::kInt24Hint},
{IDC_GROUP_HRTF, joc_lang::Text::kGroupHrtf},
{IDC_RADIO_HRTF_SOFA, joc_lang::Text::kRadioSofa},
{IDC_RADIO_HRTF_ROSELLA, joc_lang::Text::kRadioRosella},
{IDC_LABEL_HRTF, joc_lang::Text::kLabelHrtfFile},
{IDC_BROWSE_HRTF, joc_lang::Text::kButtonBrowse},
{IDC_LABEL_HRTF_HINT, joc_lang::Text::kHrtfHint},
{IDC_GROUP_GAIN, joc_lang::Text::kGroupGain},
{IDC_CHECK_GAIN, joc_lang::Text::kCheckGain},
{IDC_LABEL_GAIN, joc_lang::Text::kLabelGainUnit},
{IDC_LABEL_GAIN_HINT, joc_lang::Text::kGainHint},
{IDC_GROUP_MISC, joc_lang::Text::kGroupOther},
{IDC_LABEL_LANGUAGE, joc_lang::Text::kLabelLanguage},
{IDC_LABEL_FFMPEG, joc_lang::Text::kLabelFfmpeg},
{IDC_BROWSE_FFMPEG, joc_lang::Text::kButtonBrowse},
};
// The host sizes the page window to its own area and clips whatever is below it,
// without a scrollbar, so an oversized page silently loses its lower groups. The
// area measured inside a 125 percent foobar2000 window is 456 px tall, i.e. about
// 273 dialog units; 268 leaves room for the window chrome at both 96 and 125.
void check_page_size(HWND dialog) {
RECT client{};
GetClientRect(dialog, &client);
RECT budget{0, 0, 330, 268};
MapDialogRect(dialog, &budget);
if (client.right > budget.right || client.bottom > budget.bottom) {
++g_failures;
std::printf("PAGE TOO LARGE: %ldx%ld px, budget %ldx%ld px\n", client.right,
client.bottom, budget.right, budget.bottom);
} else {
std::printf("page size %ldx%ld px, budget %ldx%ld px\n", client.right, client.bottom,
budget.right, budget.bottom);
}
}
void report(const std::string& language, const char* what, const std::string& text, int needed,
int available) {
if (needed <= available) return;
++g_failures;
std::printf("OVERFLOW [%s] %s: %d px needed, %d available: %s\n", language.c_str(), what,
needed, available, text.c_str());
}
std::size_t index_of(joc_lang::Text text) {
std::size_t index = 0;
for (const Binding& binding : kBindings) {
if (binding.text == text) return index;
++index;
}
return static_cast<std::size_t>(-1);
}
bool windows_speaker_config(unsigned mask) {
return mask == 0x3u || mask == 0x3Fu || mask == 0x63Fu;
}
void check_control(Measurer& measurer, HWND dialog, const Binding& binding,
const std::string& language) {
HWND control = GetDlgItem(dialog, binding.control);
if (control == nullptr) {
++g_failures;
std::printf("MISSING [%s] control %d\n", language.c_str(), binding.control);
return;
}
RECT rect{};
GetClientRect(control, &rect);
const int rect_width = rect.right - rect.left;
const int rect_height = rect.bottom - rect.top;
const auto font = reinterpret_cast<HFONT>(SendMessageW(control, WM_GETFONT, 0, 0));
const std::wstring text = widen(joc_lang::get(
language == "en" ? joc_lang::Language::kEnglish : joc_lang::Language::kChineseSimplified,
binding.text));
wchar_t class_name[64] = {};
GetClassNameW(control, class_name, 64);
const std::string window_class = narrow(class_name);
int available = rect_width;
if (window_class == "Button") {
const LONG_PTR style = GetWindowLongPtrW(control, GWL_STYLE);
const LONG_PTR type = style & BS_TYPEMASK;
// A check box or radio button draws its box inside the control rectangle,
// and a push button its frame: the text has to fit in what is left.
available -= (type == BS_AUTOCHECKBOX || type == BS_AUTORADIOBUTTON) ? 17 : 8;
}
const int line_height = measurer.line_height(font);
if (rect_height >= 2 * line_height) {
const int lines = measurer.lines(text, font, available);
report(language, "wrapped text", narrow(text.c_str()), lines * line_height,
rect_height);
} else {
report(language, "text width", narrow(text.c_str()), measurer.width(text, font),
available);
}
}
void check_line(Measurer& measurer, HWND control, const std::string& language,
const std::string& text) {
if (control == nullptr) {
++g_failures;
std::printf("MISSING [%s] status control\n", language.c_str());
return;
}
RECT rect{};
GetClientRect(control, &rect);
const int rect_height = rect.bottom - rect.top;
const auto font = reinterpret_cast<HFONT>(SendMessageW(control, WM_GETFONT, 0, 0));
const std::wstring wide_text = widen(text.c_str());
const int line_height = measurer.line_height(font);
if (rect_height >= 2 * line_height) {
const int lines = measurer.lines(wide_text, font, rect.right - rect.left);
report(language, "status lines", text, lines * line_height, rect_height);
} else {
report(language, "status width", text, measurer.width(wide_text, font), rect.right);
}
}
void check_combo(Measurer& measurer, HWND control, const std::string& language,
const std::vector<std::string>& items) {
if (control == nullptr) {
++g_failures;
std::printf("MISSING [%s] combo\n", language.c_str());
return;
}
RECT rect{};
GetClientRect(control, &rect);
// Drop-down list: the closed control shows the selected item next to the arrow.
const int available = rect.right - 17;
const auto font = reinterpret_cast<HFONT>(SendMessageW(control, WM_GETFONT, 0, 0));
for (const std::string& item : items) {
report(language, "combo item", item, measurer.width(widen(item.c_str()), font),
available);
}
}
std::string format(const char* pattern, const char* layout, unsigned channels,
const char* suffix) {
char buffer[256] = {};
std::snprintf(buffer, sizeof(buffer), pattern, layout, channels, suffix);
return buffer;
}
INT_PTR CALLBACK stub_proc(HWND, UINT, WPARAM, LPARAM) { return FALSE; }
// The page is an embedded WS_CHILD dialog, so it needs a parent window even when
// it is only measured.
HWND create_host() {
static const wchar_t* kClass = L"joc_text_fit_host";
WNDCLASSEXW window_class{};
window_class.cbSize = sizeof(window_class);
window_class.lpfnWndProc = DefWindowProcW;
window_class.hInstance = GetModuleHandleW(nullptr);
window_class.lpszClassName = kClass;
RegisterClassExW(&window_class);
return CreateWindowExW(0, kClass, L"host", WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, nullptr,
nullptr, window_class.hInstance, nullptr);
}
} // namespace
int main(int argc, char** argv) {
if (argc < 2) {
std::fprintf(stderr, "usage: ui_text_fit_test <foo_input_joc.dll>\n");
return 2;
}
const std::wstring dll_path = [&] {
const int needed = MultiByteToWideChar(CP_UTF8, 0, argv[1], -1, nullptr, 0);
std::wstring out(static_cast<std::size_t>(needed), L'\0');
MultiByteToWideChar(CP_UTF8, 0, argv[1], -1, out.data(), needed);
if (!out.empty() && out.back() == L'\0') out.pop_back();
return out;
}();
HMODULE module = LoadLibraryExW(dll_path.c_str(), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
if (module == nullptr) {
std::fprintf(stderr, "cannot load %s (error %lu)\n", argv[1], GetLastError());
return 1;
}
HWND host = create_host();
if (host == nullptr) {
std::fprintf(stderr, "cannot create the host window (error %lu)\n", GetLastError());
return 1;
}
HWND dialog = CreateDialogParamW(module, MAKEINTRESOURCEW(IDD_JOC_PREFS), host,
stub_proc, 0);
if (dialog == nullptr) {
std::fprintf(stderr, "CreateDialogParamW failed (error %lu)\n", GetLastError());
return 1;
}
check_page_size(dialog);
Measurer measurer;
for (const std::string language : {"zh", "en"}) {
for (const Binding& binding : kBindings) {
check_control(measurer, dialog, binding, language);
}
const joc_lang::Language resolved = language == "en"
? joc_lang::Language::kEnglish
: joc_lang::Language::kChineseSimplified;
// Combo boxes.
std::vector<std::string> modes;
for (unsigned i = 0; i < 3; ++i) {
const joc_lang::Text id = i == 0 ? joc_lang::Text::kComboModeNear
: i == 1 ? joc_lang::Text::kComboModeFar
: joc_lang::Text::kComboModeMid;
modes.emplace_back(joc_lang::get(resolved, id));
}
check_combo(measurer, GetDlgItem(dialog, IDC_COMBO_MODE), language, modes);
check_combo(measurer, GetDlgItem(dialog, IDC_COMBO_LANGUAGE), language,
{joc_lang::get(resolved, joc_lang::Text::kLanguageSystem),
joc_lang::get(resolved, joc_lang::Text::kLanguageChinese),
joc_lang::get(resolved, joc_lang::Text::kLanguageEnglish)});
std::size_t layout_count = 0;
const joc_decode::LayoutSpec* layouts = joc_decode::layout_table(&layout_count);
std::vector<std::string> names;
for (std::size_t i = 0; i < layout_count; ++i) names.emplace_back(layouts[i].name);
check_combo(measurer, GetDlgItem(dialog, IDC_COMBO_LAYOUT), language, names);
// Status lines the page writes at run time.
const HWND output_status = GetDlgItem(dialog, IDC_LABEL_OUTPUT_STATUS);
for (std::size_t i = 0; i < layout_count; ++i) {
joc_decode::LayoutDelivery delivery;
const bool plain =
joc_decode::layout_delivery(layouts[i].name, &delivery) &&
windows_speaker_config(delivery.mask);
check_line(measurer, output_status, language,
format(joc_lang::get(resolved, joc_lang::Text::kSpeakerStatus),
layouts[i].name, layouts[i].channels,
plain ? ""
: joc_lang::get(resolved,
joc_lang::Text::kSpeakerStatusAsio)));
}
// The page shortens the path line before it is shown, so only the two-line
// envelope of the status field is measured: the label, and the longest text
// the elision can leave behind (the file name on its own).
check_line(measurer, GetDlgItem(dialog, IDC_LABEL_STATUS), language,
std::string(joc_lang::get(resolved, joc_lang::Text::kHrtfSourceSofa)) +
joc_lang::get(resolved, joc_lang::Text::kSeparator) +
joc_lang::get(resolved, joc_lang::Text::kHrtfDefault) + "\n" +
"binaural.personalized_headphone");
check_line(measurer, GetDlgItem(dialog, IDC_LABEL_STATUS), language,
std::string(
joc_lang::get(resolved, joc_lang::Text::kHrtfSourceRosella)) +
joc_lang::get(resolved, joc_lang::Text::kSeparator) + "\n" +
joc_lang::get(resolved, joc_lang::Text::kHrtfDefaultUnknown));
char gain[128] = {};
std::snprintf(gain, sizeof(gain),
joc_lang::get(resolved, joc_lang::Text::kGainStatusOn), -12.00);
check_line(measurer, GetDlgItem(dialog, IDC_LABEL_GAIN_STATUS), language, gain);
check_line(measurer, GetDlgItem(dialog, IDC_LABEL_GAIN_STATUS), language,
joc_lang::get(resolved, joc_lang::Text::kGainStatusOff));
}
DestroyWindow(dialog);
if (g_failures == 0) {
std::printf("ui_text_fit_test: both languages fit their controls\n");
return 0;
}
std::printf("ui_text_fit_test: %d string(s) do not fit\n", g_failures);
return 1;
}
+1
View File
@@ -47,6 +47,7 @@ $lines = @(
"cl $common /Fe:`"$outDir\scan_crosscheck.exe`" /Fo:`"$outDir\\`" tests\scan_crosscheck.cpp src\eac3_scan.cpp `"$coreLib`" shell32.lib",
"cl $common /Fe:`"$outDir\render_harness.exe`" /Fo:`"$outDir\\`" tests\render_harness.cpp src\joc_decode.cpp src\eac3_scan.cpp src\container_scan.cpp src\log.cpp `"$coreLib`" shell32.lib",
"cl $common /Fe:`"$outDir\layout_table_test.exe`" /Fo:`"$outDir\\`" tests\layout_table_test.cpp src\joc_decode.cpp src\eac3_scan.cpp src\container_scan.cpp src\log.cpp `"$coreLib`" shell32.lib",
"cl $common /Fe:`"$outDir\ui_text_fit_test.exe`" /Fo:`"$outDir\\`" tests\ui_text_fit_test.cpp src\lang.cpp src\joc_decode.cpp src\eac3_scan.cpp src\container_scan.cpp src\log.cpp `"$coreLib`" shell32.lib user32.lib gdi32.lib",
'if errorlevel 1 exit /b 1',
'exit /b 0'
)