@potatosalad775/eqcaps-device-bridge 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -4
- package/dist/device.d.ts +14 -6
- package/dist/device.d.ts.map +1 -1
- package/dist/device.js +40 -18
- package/dist/device.js.map +1 -1
- package/dist/handler.d.ts +25 -1
- package/dist/handler.d.ts.map +1 -1
- package/dist/handler.js.map +1 -1
- package/dist/handlers/index.d.ts +3 -1
- package/dist/handlers/index.d.ts.map +1 -1
- package/dist/handlers/index.js +4 -0
- package/dist/handlers/index.js.map +1 -1
- package/dist/handlers/ktmicro-usb-hid.d.ts +16 -2
- package/dist/handlers/ktmicro-usb-hid.d.ts.map +1 -1
- package/dist/handlers/ktmicro-usb-hid.js +41 -14
- package/dist/handlers/ktmicro-usb-hid.js.map +1 -1
- package/dist/handlers/qudelix-usb-hid.d.ts +20 -13
- package/dist/handlers/qudelix-usb-hid.d.ts.map +1 -1
- package/dist/handlers/qudelix-usb-hid.js +219 -87
- package/dist/handlers/qudelix-usb-hid.js.map +1 -1
- package/dist/handlers/qudelix-v2-usb-hid.d.ts +31 -0
- package/dist/handlers/qudelix-v2-usb-hid.d.ts.map +1 -0
- package/dist/handlers/qudelix-v2-usb-hid.js +266 -0
- package/dist/handlers/qudelix-v2-usb-hid.js.map +1 -0
- package/dist/handlers/qudelix.d.ts +185 -0
- package/dist/handlers/qudelix.d.ts.map +1 -0
- package/dist/handlers/qudelix.js +585 -0
- package/dist/handlers/qudelix.js.map +1 -0
- package/dist/handlers/topping-usb-hid.d.ts +51 -0
- package/dist/handlers/topping-usb-hid.d.ts.map +1 -0
- package/dist/handlers/topping-usb-hid.js +658 -0
- package/dist/handlers/topping-usb-hid.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/protocols.d.ts +9 -0
- package/dist/protocols.d.ts.map +1 -1
- package/dist/protocols.js +85 -34
- package/dist/protocols.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @potatosalad775/eqcaps-device-bridge
|
|
2
2
|
|
|
3
3
|
Reads and writes parametric EQ on audio hardware: FiiO, Walkplay-chipset dongles, Moondrop,
|
|
4
|
-
KT Micro, Fosi Audio, Qudelix, JDS Labs, Nothing, Tanchjim, Edifier, Audeze and others, every
|
|
4
|
+
KT Micro, Fosi Audio, Qudelix, Topping, JDS Labs, Nothing, Tanchjim, Edifier, Audeze and others, every
|
|
5
5
|
hardware device in the [eqcaps](https://github.com/potatosalad775/eqcaps) database. Protocols
|
|
6
6
|
ported from [devicePEQ](https://github.com/jeromeof/devicePEQ), and changed to do what each
|
|
7
7
|
vendor's own app does where one is known.
|
|
@@ -105,9 +105,12 @@ why a block can't be driven: an unknown handler (data newer than this bridge) or
|
|
|
105
105
|
| `moondrop-usb-hid` | HID | `bandFrame` (`"biquad"`, the default: 36 bytes with Q2.30 coefficients and the slot; `"compact"`: 14 bytes of freq, q, gain and type; `"wide"`: 34 bytes with the coefficients zero), `commit` (what follows the bands: `"apply"`, the default, one `[1,0x0A,4,0,0,FF,FF]`; `"commit"`, `[1,0x60,0]`; `"none"`, nothing, with the 50 ms wait kept), `customSlot` (the slot a push selects and a `biquad` frame names, default 7), `selectSlot` (default true; false skips the `[1,0x0F,1,slot]` that starts a push), `duckPreamp` (default false; true writes -128 dB as the pre-gain before the bands, and the real one after the commit), `saveOffsets` (default false; true ends a push with `[1,4,0]`), `linkCheck` (default false; true asks `[0x80,0x31,0]` before each part of a push and before a pull or control access, for a dongle with a headset, and refuses with `rejected` when byte 3 is 0), `ledCommand` (the command of the `led` control, default `0x28`; BLUE ROSE uses `0x18`). Every frame sent, read requests included, is zero-padded to the size the HID descriptor declares for report `0x4B` (63 bytes where it declares none), and never truncated, as the app does. |
|
|
106
106
|
| `moondrop-old-fashioned-hid` | HID | – (a packet, read requests included, is zero-padded to the descriptor's size for report 75 when that is larger than its 10 bytes) |
|
|
107
107
|
| `conexant-usb-hid` | HID | – |
|
|
108
|
-
| `ktmicro-usb-hid` | HID | `baseRegister` (default `0x26`), `bandRegisters` (`[{ "freq", "q" }]` per band, for models that skip or reorder registers), `customSlot` (default 3), `freqUnit` (Hz per unit of the frequency field, default 1; 2 where the firmware stores half the frequency), `slotRegister` and `preampRegister` (default true; false leaves the slot register 0x24, which also switches the EQ, or the preamp register 0x66 alone), `frameDelay` (ms between the frames of a push, default 0), `enableRegister` (the register of an EQ switch, 1 on and 0 off, on firmware without slots: a push turns it on first, and the slot register is left alone), `writeAck` (byte 6 of the answer to a good write; each write then waits for its answer, and another flag is `rejected`), `bandDelay` (ms after each band's two frames, default 0) |
|
|
108
|
+
| `ktmicro-usb-hid` | HID | `baseRegister` (default `0x26`), `bandRegisters` (`[{ "freq", "q" }]` per band, for models that skip or reorder registers), `customSlot` (default 3), `freqUnit` (Hz per unit of the frequency field, default 1; 2 where the firmware stores half the frequency), `slotRegister` and `preampRegister` (default true; false leaves the slot register 0x24, which also switches the EQ, or the preamp register 0x66 alone), `frameDelay` (ms between the frames of a push, default 0), `enableRegister` (the register of an EQ switch, 1 on and 0 off, on firmware without slots: a push turns it on first, and the slot register is left alone), `enableLast` (with `enableRegister`, a push writes the 1 after the bands and preamp, just before the commit; Walkplay's app), `writeAck` (byte 6 of the answer to a good write; each write then waits for its answer, and another flag is `rejected`), `writeWait` (ms each write waits for the device's answer to its register, going on whether or not one comes and without reading it; only a timeout is let go, and `writeAck` takes over when set; default none), `bandDelay` (ms after each band's two frames, default 0), `typeFlag` (bits OR-ed into every band's type byte on write and cleared from it on read, default 0; Walkplay's app sets bit 3, so 8), `gainRegister` (the register `globalGain` and `globalGainDb` use, default `0x3b`) |
|
|
109
|
+
| `topping-usb-hid` | `volume` and `balance` (dB; the device holds the volume as attenuation in 0.5 dB steps, or 1 dB in its 1 dB step mode, and the balance as signed tenths); `mute`, `input`, `output`, `gain`, `lineMode`, `dacFilter`, `polarity`, `crossfeed`, `brightness` (the device's own numbers). DX5 II only; the other families' settings are not driven. A volume write is refused (`rejected`) while a line output is in DAC mode, as the app sends nothing then. From Topping's web app; tried on a DX5 II |
|
|
109
110
|
| `fosi-audio-usb-hid` | HID | `reportId` (default 1), `bandwidth` (default 0), `defaultSlot` (default 7) |
|
|
110
|
-
| `qudelix-usb-hid` | HID |
|
|
111
|
+
| `qudelix-usb-hid` | HID | –. EQs: the user EQ by default, and `spk`, the speaker (headphone) EQ. For the 5K (firmware 3.0.0 and later; older is `unsupported`) and the T71, as Qudelix's app for Chrome drives them, reading and writing. The framing comes from the vendor id (`0x0a12` or `0x1fc9`) and the descriptor, the model from the device's answer to the opening request (sent once the device has been quiet for 20 ms, answered within 5 s), and the EQ mode from the device: in the 5K's single-EQ mode the default EQ is its 20-band EQ and `spk` is `unsupported`. The speaker EQ is written left and right alike, in the one frame the app sends for both channels, and read from the left channel (`log` says when the right differs); a speaker EQ of 4 or 8 channels (the T71's crossover drivers) is `unsupported`. The T71's 5-channel user EQ is written on every channel. A push waits for the device's echo of each band before the next (a 5K can stop answering after 20 back to back); a device that sends none gets them at once. Slots are the app's preset indexes (0–21 built in, then the EQ's custom presets from 22); a push to a slot saves it with an empty name, the app's default. `bandCount()`, `eqEnabled()`, `currentSlot()` and `firmware()` ask the device. |
|
|
112
|
+
| `qudelix-v2-usb-hid` | HID | –. EQs as for `qudelix-usb-hid`. For the 5K Plus, as Qudelix's app for Chrome drives it: messages of elements in fragments, each but the last acknowledged within 1 s; a missing or bad acknowledgement fails the operation and closes the session, which the next operation opens again. In single-EQ mode the default EQ is the 30-band EQ. As in the app, a push requests the stored preset and sets the whole configuration (to switch the EQ on), the attributes (to make it parametric) and, for a pre-gain, the whole preset with only the pre-gain and type changed. |
|
|
113
|
+
| `topping-usb-hid` | HID | `family` (`dx1`, the default, `dx5`, `e50`, `dx9d` or `d900`: the DX1 II, DX5 II, E50 II, DX9 Discrete and D900, which share USB id `0x152a:0x8750` and differ in how a session starts, how the config list is asked for and where the firmware, the active config and the EQ switch are read). As Topping's web app drives them, reading and writing. A slot is one of the device's stored configs (3 on the DX1 II and E50 II, 10 on the others), which a push needs to exist already. The pre-gain is computed for every family. The DX5 II and E50 II refuse firmware older than the app's minimum (2.37 and 1.52) as `unsupported`; the D900 does when its capabilities answer is not the one the app requires. Tried on a DX5 II; the other four are unchecked. |
|
|
111
114
|
| `jds-labs-usb-serial` | serial | – |
|
|
112
115
|
| `nothing-usb-serial` | serial | `customSlot` (default 5) |
|
|
113
116
|
| `fiio-usb-serial` | serial | `saveCommand` (default `0x19`) |
|
|
@@ -126,6 +129,31 @@ and `ktmicro-usb-hid` turn the EQ off with a preset (KT Micro's default is slot
|
|
|
126
129
|
write may target; once any preset is marked, the unmarked ones are built-in curves (SPEC §9). The
|
|
127
130
|
bridge passes the mark on in `capabilities.slots` and doesn't enforce it. A new option goes in `src/protocols.ts` (`OPTIONS`) and this table.
|
|
128
131
|
|
|
132
|
+
## Other EQs
|
|
133
|
+
|
|
134
|
+
A profile's `protocol.eqs` (format 1.3, SPEC §9.2) lists the device's EQs besides the one the
|
|
135
|
+
profile describes: Qudelix's speaker EQ under its user EQ. One connection drives them all, and
|
|
136
|
+
each operation says which EQ it is for.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { eqProfile } from '@potatosalad775/eqcaps-core';
|
|
140
|
+
|
|
141
|
+
for (const eq of device.capabilities.eqs) console.log(eq.id, eq.name, eq.bandCount, eq.slots);
|
|
142
|
+
const held = await device.pull({ eq: 'spk' });
|
|
143
|
+
const spk = eqProfile(profile, 'spk')!; // the profile of that EQ: its band count and presets
|
|
144
|
+
const result = fit(spk, wantedFilters, wantedPreamp);
|
|
145
|
+
const filters = complete(spk, result.slots, { hints: held.filters }).filters;
|
|
146
|
+
await device.push({ filters, eq: 'spk' });
|
|
147
|
+
await device.eqEnabled('spk'); // also currentSlot(eq), bandCount(eq), setEnabled(on, slot, eq)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Without `eq`, every operation is about the profile's own EQ, as on a device with one.
|
|
151
|
+
`capabilities.eqs` holds the listed EQs this bridge's handler drives, each with its own preset
|
|
152
|
+
`slots`; one the handler doesn't know is left out, and naming an EQ that isn't there is an
|
|
153
|
+
`invalid-request`. The EQs are independent: a push to one leaves the others as they are. A
|
|
154
|
+
handler names its EQs in `eqs` and reads the operation's from `ctx.eq`; a new one goes there and
|
|
155
|
+
in the table above.
|
|
156
|
+
|
|
129
157
|
## Device controls
|
|
130
158
|
|
|
131
159
|
A profile's `protocol.controls` (format 1.2, SPEC §9.1) lists the device's settings besides the EQ:
|
|
@@ -159,7 +187,7 @@ its role), so data newer than the bridge still drives the rest.
|
|
|
159
187
|
| `fosi-audio-usb-hid` | `volume`, `gainMode`, `filterMode`, `gameMode`, `upsample`, `uacMode`, `led` (one byte each, the device's own values) |
|
|
160
188
|
| `walkplay-hid` | `dacFilter`, `gainLevel`, `workMode`, `volume` (one byte each); `dre` (toggle, held as 0 on, 1 off; Tanchjim's app); `micGain`, `leftGain`, `rightGain` (dB, on a 1/256 grid). From NICEHCK's and Walkplay's web apps; `firmware()` too |
|
|
161
189
|
| `moondrop-usb-hid` | `globalGain` (dB on a 1/256 grid: read with `[0x80,3,0]`, written with `[1,3,2,s16 LE]` and the offset save `[1,4,0]`); then features that are read with `[0x80,cmd,0]` (the value at byte 3) and written with `[1,cmd,1,value]`, 50 ms, and no save: `dacFilter` (`0x11`), `dacMode` (`0x1D`), `led` (`0x28`, or `ledCommand`; 0 or 1), `gainLevel` (`0x26`), `ancMode` (`0x25`), `dualMicEnc` (`0x34`; 0 or 1); `promptTone` (on or off, 0 or 1) and `promptToneVolume`, which are bytes 0 and 1 of the three-byte `0x2B` (on, volume, tone): a write reads the three, changes its own and writes all three back, so the tone is never changed. A value that is not a whole number from 0 to 255 (0 or 1 for the toggles) is `unrepresentable`; the ones a device takes are the profile's. With `linkCheck`, the link is asked about before each read and write. From Moondrop's web app; `firmware()` too |
|
|
162
|
-
| `ktmicro-usb-hid` | `globalGain` (the KT0211L's DAC gain register 0x3b as a step), `globalGainDb` (the same register in dB on models that hold it so, minus ten times the dB). From Kiwi Ears' web app |
|
|
190
|
+
| `ktmicro-usb-hid` | `globalGain` (the KT0211L's DAC gain register 0x3b as a step), `globalGainDb` (the same register in dB on models that hold it so, minus ten times the dB); both use `gainRegister` in place of 0x3b when it is set (Walkplay's SchemeNo19 holds the dB in 0x57). From Kiwi Ears' web app and Walkplay's Android app |
|
|
163
191
|
|
|
164
192
|
Errors are `BridgeError`s with a `code`: `unsupported-type`, `unrepresentable`, `unsupported`,
|
|
165
193
|
`timeout`, `bad-response`, `rejected`, `transport` or `invalid-request`.
|
package/dist/device.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Control, type FilterType } from '@potatosalad775/eqcaps-core';
|
|
2
|
-
import type { AnyHandler, HandlerCapabilities, PullRequest, PullResult, PushRequest, PushResult, Slot, WireGrid } from './handler.ts';
|
|
2
|
+
import type { AnyHandler, EqInfo, HandlerCapabilities, PullRequest, PullResult, PushRequest, PushResult, Slot, WireGrid } from './handler.ts';
|
|
3
3
|
import { type DeviceIdentity } from './identity.ts';
|
|
4
4
|
import type { Protocol } from './protocols.ts';
|
|
5
5
|
import type { Transport } from './transport.ts';
|
|
@@ -21,8 +21,13 @@ export interface DeviceCapabilities extends HandlerCapabilities {
|
|
|
21
21
|
types: readonly FilterType[];
|
|
22
22
|
/** What the write frames can carry. A profile domain outside it can't be written. */
|
|
23
23
|
wire: WireGrid;
|
|
24
|
-
/** The
|
|
24
|
+
/** The preset slots of the EQ the profile describes. */
|
|
25
25
|
slots: readonly Slot[];
|
|
26
|
+
/**
|
|
27
|
+
* The device's other EQs (SPEC §9.2), each with its own slots: `pull`, `push` and the EQ's
|
|
28
|
+
* switch and preset take one's id as `eq`. Empty for a device with one EQ.
|
|
29
|
+
*/
|
|
30
|
+
eqs: readonly EqInfo[];
|
|
26
31
|
/** The device drops the connection after a push that saves; reconnect afterwards. */
|
|
27
32
|
disconnectOnSave: boolean;
|
|
28
33
|
/** The protocol for this device is unconfirmed. */
|
|
@@ -49,21 +54,24 @@ export interface BridgeDevice {
|
|
|
49
54
|
pull(request?: PullRequest): Promise<PullResult>;
|
|
50
55
|
push(request: PushRequest): Promise<PushResult>;
|
|
51
56
|
/**
|
|
57
|
+
* Each of the next four takes the id of one of `capabilities.eqs` as `eq`, and is about the
|
|
58
|
+
* profile's own EQ without it.
|
|
59
|
+
*
|
|
52
60
|
* The active preset slot; null when the protocol can't say, or (on some bypass-preset
|
|
53
61
|
* protocols) when the EQ is off. Where the EQ switch is separate state (`readsEnabled`), this is
|
|
54
62
|
* the preset the device plays when its EQ is on, whether it is on or not.
|
|
55
63
|
*/
|
|
56
|
-
currentSlot(): Promise<number | null>;
|
|
64
|
+
currentSlot(eq?: string): Promise<number | null>;
|
|
57
65
|
/** Whether the EQ is on (`readsEnabled`); null when the protocol or device doesn't say. */
|
|
58
|
-
eqEnabled(): Promise<boolean | null>;
|
|
59
|
-
setEnabled(enabled: boolean, slot?: number): Promise<void>;
|
|
66
|
+
eqEnabled(eq?: string): Promise<boolean | null>;
|
|
67
|
+
setEnabled(enabled: boolean, slot?: number, eq?: string): Promise<void>;
|
|
60
68
|
/** The device's firmware version, read once; null when the protocol or device doesn't say. */
|
|
61
69
|
firmware(): Promise<string | null>;
|
|
62
70
|
/**
|
|
63
71
|
* The band count the device reports, asked each time; null when the protocol or device doesn't
|
|
64
72
|
* say. It can differ from the profile's `bandCount`: the bridge doesn't reconcile them.
|
|
65
73
|
*/
|
|
66
|
-
bandCount(): Promise<number | null>;
|
|
74
|
+
bandCount(eq?: string): Promise<number | null>;
|
|
67
75
|
/**
|
|
68
76
|
* The current value of every control in `capabilities.controls`; null for one the device
|
|
69
77
|
* doesn't have now (SPEC §9.1: its firmware range or `when` doesn't hold). Opt-in: pull and
|
package/dist/device.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,OAAO,EAEZ,KAAK,UAAU,EACf,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EACX,UAAU,EACV,mBAAmB,EAEnB,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,WAAW;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACxC,+EAA+E;IAC/E,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,oCAAoC;IACpC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC9D,oDAAoD;IACpD,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IAC7B,qFAAqF;IACrF,IAAI,EAAE,QAAQ,CAAC;IACf,
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,OAAO,EAEZ,KAAK,UAAU,EACf,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EACX,UAAU,EACV,MAAM,EACN,mBAAmB,EAEnB,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,MAAM,cAAc,CAAC;AAEtB,OAA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CAAC,EACc,CAAC;AAExF;;;GAGG;AACH,wBAAgB,UAAU,CACzB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,WAAgB,GACvB,YAAY,CA2Nd"}
|
package/dist/device.js
CHANGED
|
@@ -19,13 +19,30 @@ export function openDevice(transport, protocol, options = {}) {
|
|
|
19
19
|
throw new BridgeError('invalid-request', `${handler.id} doesn't run over a ${transport.kind} transport`);
|
|
20
20
|
}
|
|
21
21
|
const handlerOptions = protocol.options ?? {};
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const context = (presets, eq) => {
|
|
23
|
+
const bypass = presets?.find((p) => p.bypass)?.id;
|
|
24
|
+
return {
|
|
25
|
+
transport,
|
|
26
|
+
options: handlerOptions,
|
|
27
|
+
...(eq !== undefined ? { eq } : {}),
|
|
28
|
+
...(bypass !== undefined ? { bypass } : {}),
|
|
29
|
+
sleep: options.sleep ?? realSleep,
|
|
30
|
+
log: options.log ?? (() => { })
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** The profile's own EQ, and everything that isn't about one EQ. */
|
|
34
|
+
const ctx = context(protocol.presets);
|
|
35
|
+
// The data's other EQs that this handler drives: one it doesn't know is left out (SPEC §9.2).
|
|
36
|
+
const eqs = (protocol.eqs ?? []).filter((e) => (handler.eqs ?? []).includes(e.id));
|
|
37
|
+
const contexts = new Map(eqs.map((e) => [e.id, context(e.presets, e.id)]));
|
|
38
|
+
/** The context of an operation on `eq`; an EQ the profile doesn't list is refused. */
|
|
39
|
+
const on = (eq) => {
|
|
40
|
+
if (eq === undefined)
|
|
41
|
+
return ctx;
|
|
42
|
+
const found = contexts.get(eq);
|
|
43
|
+
if (!found)
|
|
44
|
+
throw new BridgeError('invalid-request', `${handler.id}: no EQ "${eq}" here`);
|
|
45
|
+
return found;
|
|
29
46
|
};
|
|
30
47
|
const own = handler.capabilities(transport, handlerOptions);
|
|
31
48
|
const capabilities = {
|
|
@@ -33,6 +50,7 @@ export function openDevice(transport, protocol, options = {}) {
|
|
|
33
50
|
types: handler.codec.types,
|
|
34
51
|
wire: handler.codec.wire(handlerOptions),
|
|
35
52
|
slots: protocol.presets ?? [],
|
|
53
|
+
eqs: eqs.map(({ presets, ...e }) => ({ ...e, slots: presets ?? [] })),
|
|
36
54
|
disconnectOnSave: protocol.disconnectOnSave ?? false,
|
|
37
55
|
experimental: protocol.experimental ?? false,
|
|
38
56
|
readsFirmware: handler.firmware !== undefined,
|
|
@@ -86,14 +104,16 @@ export function openDevice(transport, protocol, options = {}) {
|
|
|
86
104
|
}
|
|
87
105
|
r.slot = request.slot;
|
|
88
106
|
}
|
|
107
|
+
const target = on(request.eq);
|
|
89
108
|
if (capabilities.needsBandCount) {
|
|
90
|
-
const
|
|
109
|
+
const listed = eqs.find((e) => e.id === request.eq)?.bandCount;
|
|
110
|
+
const bands = request.bands ?? listed ?? options.profile?.bandCount ?? undefined;
|
|
91
111
|
if (typeof bands !== 'number' || !Number.isInteger(bands) || bands < 0) {
|
|
92
112
|
throw new BridgeError('invalid-request', `${handler.id} needs a band count: pass \`bands\`, or open the device with its profile`);
|
|
93
113
|
}
|
|
94
114
|
r.bands = bands;
|
|
95
115
|
}
|
|
96
|
-
return handler.pull(
|
|
116
|
+
return handler.pull(target, r);
|
|
97
117
|
});
|
|
98
118
|
},
|
|
99
119
|
push(request) {
|
|
@@ -101,31 +121,33 @@ export function openDevice(transport, protocol, options = {}) {
|
|
|
101
121
|
if (!capabilities.canWrite) {
|
|
102
122
|
throw new BridgeError('unsupported', `${handler.id} can't write to this device`);
|
|
103
123
|
}
|
|
104
|
-
const
|
|
124
|
+
const { eq, ...rest } = request;
|
|
125
|
+
const result = await handler.push(on(eq), rest);
|
|
105
126
|
return { reconnect: result.reconnect || capabilities.disconnectOnSave };
|
|
106
127
|
});
|
|
107
128
|
},
|
|
108
|
-
currentSlot() {
|
|
109
|
-
return serial(async () => (handler.currentSlot ? handler.currentSlot(
|
|
129
|
+
currentSlot(eq) {
|
|
130
|
+
return serial(async () => (handler.currentSlot ? handler.currentSlot(on(eq)) : null));
|
|
110
131
|
},
|
|
111
|
-
eqEnabled() {
|
|
112
|
-
return serial(async () => (handler.eqEnabled ? handler.eqEnabled(
|
|
132
|
+
eqEnabled(eq) {
|
|
133
|
+
return serial(async () => (handler.eqEnabled ? handler.eqEnabled(on(eq)) : null));
|
|
113
134
|
},
|
|
114
|
-
setEnabled(enabled, slot) {
|
|
135
|
+
setEnabled(enabled, slot, eq) {
|
|
115
136
|
return serial(async () => {
|
|
116
137
|
if (!handler.setEnabled) {
|
|
117
138
|
throw new BridgeError('unsupported', `${handler.id} has no EQ switch`);
|
|
118
139
|
}
|
|
119
|
-
await handler.setEnabled(
|
|
140
|
+
await handler.setEnabled(on(eq), enabled, slot);
|
|
120
141
|
});
|
|
121
142
|
},
|
|
122
143
|
firmware() {
|
|
123
144
|
return serial(readFirmware);
|
|
124
145
|
},
|
|
125
|
-
bandCount() {
|
|
146
|
+
bandCount(eq) {
|
|
126
147
|
return serial(async () => {
|
|
148
|
+
const target = on(eq);
|
|
127
149
|
try {
|
|
128
|
-
return (await handler.bandCount?.(
|
|
150
|
+
return (await handler.bandCount?.(target)) ?? null;
|
|
129
151
|
}
|
|
130
152
|
catch (e) {
|
|
131
153
|
ctx.log(`${handler.id}: no band count (${e.message})`);
|
package/dist/device.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd,YAAY,EACZ,IAAI,EAIJ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"device.js","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd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,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/handler.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface PullRequest {
|
|
|
20
20
|
slot?: number;
|
|
21
21
|
/** Bands to read, where the protocol can't tell. Default: the profile's `bandCount`. */
|
|
22
22
|
bands?: number;
|
|
23
|
+
/** Which of the device's EQs to read (SPEC §9.2): an id of `capabilities.eqs`. Default: the profile's own. */
|
|
24
|
+
eq?: string;
|
|
23
25
|
}
|
|
24
26
|
/** What the device holds, in canonical units: written values (D39). */
|
|
25
27
|
export interface PullResult {
|
|
@@ -45,6 +47,18 @@ export interface PushRequest {
|
|
|
45
47
|
preamp?: number;
|
|
46
48
|
/** Preset slot to write to. Refused, like `preamp`, where the write names none (`writesSlot`). */
|
|
47
49
|
slot?: number;
|
|
50
|
+
/** Which of the device's EQs to write (SPEC §9.2): an id of `capabilities.eqs`. Default: the profile's own. */
|
|
51
|
+
eq?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Another EQ of the device, as its profile lists it (SPEC §9.2). */
|
|
54
|
+
export interface EqInfo {
|
|
55
|
+
/** The handler's id of the EQ: what `eq` takes. */
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
/** Its band count, where the profile gives one that differs from its own. */
|
|
59
|
+
bandCount?: number;
|
|
60
|
+
/** Its own preset slots. */
|
|
61
|
+
slots: readonly Slot[];
|
|
48
62
|
}
|
|
49
63
|
export interface PushResult {
|
|
50
64
|
/** The device drops the connection after saving; reconnect before the next operation. */
|
|
@@ -126,7 +140,12 @@ export interface HandlerCapabilities {
|
|
|
126
140
|
export interface HandlerContext<T extends Transport, O> {
|
|
127
141
|
transport: T;
|
|
128
142
|
options: O;
|
|
129
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* The EQ the operation is for (SPEC §9.2), one of the handler's `eqs`; undefined for the EQ the
|
|
145
|
+
* handler drives by default.
|
|
146
|
+
*/
|
|
147
|
+
eq?: string;
|
|
148
|
+
/** The preset that EQ's list marks `bypass`: selecting it turns the EQ off (SPEC §9). */
|
|
130
149
|
bypass?: number;
|
|
131
150
|
/** Waits between writes. Tests replace it to run without real delays. */
|
|
132
151
|
sleep(ms: number): Promise<void>;
|
|
@@ -157,6 +176,11 @@ export interface Handler<T extends Transport, O, F> {
|
|
|
157
176
|
readonly sppServiceClass?: string;
|
|
158
177
|
/** The protocol turns the EQ off by selecting a preset, which the profile marks `bypass`. */
|
|
159
178
|
readonly bypassPreset?: boolean;
|
|
179
|
+
/**
|
|
180
|
+
* The device's other EQs this handler drives, by id: the vocabulary of a profile's
|
|
181
|
+
* `protocol.eqs` (SPEC §9.2). An operation names one in `ctx.eq`.
|
|
182
|
+
*/
|
|
183
|
+
readonly eqs?: readonly string[];
|
|
160
184
|
capabilities(transport: T, options: O): HandlerCapabilities;
|
|
161
185
|
/** `bands` is always set when `needsBandCount` is. */
|
|
162
186
|
pull(ctx: HandlerContext<T, O>, request: {
|
package/dist/handler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE/E,yFAAyF;AACzF,MAAM,WAAW,IAAI;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC3B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["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G,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC/D,UAAU,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvF,yFAAyF;IACzF,QAAQ,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7D,2EAA2E;IAC3E,SAAS,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC9D;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;KAAE,CAAC;CACpE;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;AACxE,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,MAAM,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;AAEhF,+EAA+E;AAE/E,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEhD,gEAAgE;AAChE,eAAO,MAAM,GAAG,yCAAyC,CAAC"}
|
package/dist/handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AA6NA,gEAAgE;AAChE,MAAM,CAAC,MAAM,GAAG,GAAG,sCAAsC,CAAC"}
|
package/dist/handlers/index.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ export declare const HANDLERS: {
|
|
|
7
7
|
readonly 'conexant-usb-hid': import("../handler.ts").HidHandler;
|
|
8
8
|
readonly 'ktmicro-usb-hid': import("../handler.ts").HidHandler<import("./ktmicro-usb-hid.ts").KtmicroHidOptions>;
|
|
9
9
|
readonly 'fosi-audio-usb-hid': import("../handler.ts").HidHandler<import("./fosi-audio-usb-hid.ts").FosiAudioHidOptions>;
|
|
10
|
-
readonly '
|
|
10
|
+
readonly 'topping-usb-hid': import("../handler.ts").HidHandler<import("./topping-usb-hid.ts").ToppingHidOptions>;
|
|
11
|
+
readonly 'qudelix-usb-hid': import("../handler.ts").HidHandler<import("./qudelix-usb-hid.ts").QudelixUsbHidOptions>;
|
|
12
|
+
readonly 'qudelix-v2-usb-hid': import("../handler.ts").HidHandler<import("./qudelix-v2-usb-hid.ts").QudelixV2UsbHidOptions>;
|
|
11
13
|
readonly 'jds-labs-usb-serial': import("../handler.ts").StreamHandler;
|
|
12
14
|
readonly 'nothing-usb-serial': import("../handler.ts").StreamHandler<import("./nothing-usb-serial.ts").NothingOptions>;
|
|
13
15
|
readonly 'fiio-usb-serial': import("../handler.ts").StreamHandler<import("./fiio-usb-serial.ts").FiioUsbSerialOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAmBA,4BAA4B;AAC5B,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;CAmBX,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC;AACvC,MAAM,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC;AACvC,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,SAAS;IACrE,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC;CAC1D,GACE,CAAC,GACD,KAAK,CAAC"}
|
package/dist/handlers/index.js
CHANGED
|
@@ -12,7 +12,9 @@ import { moondropOldFashionedHid } from "./moondrop-old-fashioned-hid.js";
|
|
|
12
12
|
import { moondropUsbHid } from "./moondrop-usb-hid.js";
|
|
13
13
|
import { nothingUsbSerial } from "./nothing-usb-serial.js";
|
|
14
14
|
import { qudelixUsbHid } from "./qudelix-usb-hid.js";
|
|
15
|
+
import { qudelixV2UsbHid } from "./qudelix-v2-usb-hid.js";
|
|
15
16
|
import { tanchjimRitaSerial } from "./tanchjim-rita-serial.js";
|
|
17
|
+
import { toppingUsbHid } from "./topping-usb-hid.js";
|
|
16
18
|
import { walkplayHid } from "./walkplay-hid.js";
|
|
17
19
|
/** Every handler, by id. */
|
|
18
20
|
export const HANDLERS = {
|
|
@@ -23,7 +25,9 @@ export const HANDLERS = {
|
|
|
23
25
|
'conexant-usb-hid': conexantUsbHid,
|
|
24
26
|
'ktmicro-usb-hid': ktmicroUsbHid,
|
|
25
27
|
'fosi-audio-usb-hid': fosiAudioUsbHid,
|
|
28
|
+
'topping-usb-hid': toppingUsbHid,
|
|
26
29
|
'qudelix-usb-hid': qudelixUsbHid,
|
|
30
|
+
'qudelix-v2-usb-hid': qudelixV2UsbHid,
|
|
27
31
|
'jds-labs-usb-serial': jdsLabsUsbSerial,
|
|
28
32
|
'nothing-usb-serial': nothingUsbSerial,
|
|
29
33
|
'fiio-usb-serial': fiioUsbSerial,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;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ClC,iBAAiB,EAAE,aAAa;IAChC,oBAAoB,EAAE,eAAe;IACrC,iBAAiB,EAAE,aAAa;IAChC,iBAAiB,EAAE,aAAa;IAChC,oBAAoB,EAAE,eAAe;IACrC,qBAAqB,EAAE,gBAAgB;IACvC,oBAAoB,EAAE,gBAAgB;IACtC,iBAAiB,EAAE,aAAa;IAChC,WAAW,EAAE,QAAQ;IACrB,sBAAsB,EAAE,kBAAkB;IAC1C,sBAAsB,EAAE,kBAAkB;IAC1C,gBAAgB,EAAE,aAAa;IAC/B,MAAM;CACG,CAAC"}
|
|
@@ -18,14 +18,28 @@ export interface KtmicroHidOptions {
|
|
|
18
18
|
/** Milliseconds between the frames of a push. Default 0. */
|
|
19
19
|
frameDelay?: number;
|
|
20
20
|
/**
|
|
21
|
-
* Register of an EQ switch (1 on, 0 off), on firmware without slots. A push turns it on first
|
|
22
|
-
* and the slot register is left alone.
|
|
21
|
+
* Register of an EQ switch (1 on, 0 off), on firmware without slots. A push turns it on first
|
|
22
|
+
* (or after the bands, with `enableLast`), and the slot register is left alone.
|
|
23
23
|
*/
|
|
24
24
|
enableRegister?: number;
|
|
25
|
+
/** With `enableRegister`, a push writes the 1 after the bands and preamp, before the commit. */
|
|
26
|
+
enableLast?: boolean;
|
|
25
27
|
/** Byte 6 of the answer to a good write: each write then waits for its answer. Default: none. */
|
|
26
28
|
writeAck?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Milliseconds each write waits for the device's answer to its register, going on whether or not
|
|
31
|
+
* one comes and without looking at it. `writeAck`, when set, takes over. Default: no wait.
|
|
32
|
+
*/
|
|
33
|
+
writeWait?: number;
|
|
27
34
|
/** Milliseconds after each band's two frames. Default 0. */
|
|
28
35
|
bandDelay?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Bits OR-ed into every band's type byte on write and cleared from it on read (Walkplay's app
|
|
38
|
+
* sets bit 3: 8). Default 0.
|
|
39
|
+
*/
|
|
40
|
+
typeFlag?: number;
|
|
41
|
+
/** Register of the DAC gain the `globalGain` controls drive. Default 0x3b. */
|
|
42
|
+
gainRegister?: number;
|
|
29
43
|
}
|
|
30
44
|
export declare const KTMICRO_TYPES: import("../io.ts").TypeCodes;
|
|
31
45
|
export declare function ktmicroRegisters(o: KtmicroHidOptions, band: number): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ktmicro-usb-hid.d.ts","sourceRoot":"","sources":["../../src/handlers/ktmicro-usb-hid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ktmicro-usb-hid.d.ts","sourceRoot":"","sources":["../../src/handlers/ktmicro-usb-hid.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,KAAK,EAAkB,QAAQ,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAI7F,MAAM,WAAW,iBAAiB;IACjC,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6FAA6F;IAC7F,aAAa,CAAC,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvD,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mGAAmG;IACnG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kEAAkE;IAClE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gGAAgG;IAChG,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAYD,eAAO,MAAM,aAAa,8BAAkE,CAAC;AAE7F,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM;UAhDjC,MAAM;OAAK,MAAM;EA6DlD;AAsBD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,iBAAiB,EAAE,QAAQ,CA4C3D,CAAC;AAgDF,eAAO,MAAM,aAAa,EAAE,UAAU,CAAC,iBAAiB,CA2FvD,CAAC"}
|
|
@@ -11,8 +11,15 @@
|
|
|
11
11
|
// Kiwi Ears' web app (equalizer.kiwiears.com) has no slots: its register 0x24 (0x34 on KT1132L and
|
|
12
12
|
// KT3016L, where 0x24 answers with a date) switches the EQ, 1 on and 0 off. Every write answers with
|
|
13
13
|
// a success flag in byte 6, which it waits for. Register 0x3b is the KT0211L's DAC gain.
|
|
14
|
+
//
|
|
15
|
+
// Walkplay's Android app drives its SchemeNo17 (5 bands, register 0x24 the switch, half the
|
|
16
|
+
// frequency) and SchemeNo19 (6 bands from register 0x35, 0x34 the switch, whole Hz) devices this
|
|
17
|
+
// way too, with differences: every type byte has bit 3 set on write and is masked with 7 on read,
|
|
18
|
+
// the switch is written after the bands, each write waits up to a second for an answer it never
|
|
19
|
+
// checks, and the DAC offset sits in register 0x3b (as a step) or 0x57 (in dB). The app also
|
|
20
|
+
// writes its own preset index (0x02, 0x16), which the bridge leaves alone.
|
|
14
21
|
import { field, grid, I16, I8, le16, le32, readI16le, readI32le, readI8, readU16le, U16, U8 } from "../bytes.js";
|
|
15
|
-
import { BridgeError } from "../errors.js";
|
|
22
|
+
import { BridgeError, isBridgeError } from "../errors.js";
|
|
16
23
|
import { hidFrame, hidRequest, refuseUncarried, sendFrame, typeCodes } from "../io.js";
|
|
17
24
|
const REPORT_ID = 0x4b;
|
|
18
25
|
const READ = 0x52;
|
|
@@ -22,6 +29,7 @@ const SLOT = 0x24;
|
|
|
22
29
|
const PREAMP = 0x66;
|
|
23
30
|
const DAC_GAIN = 0x3b;
|
|
24
31
|
const WRITE_TIMEOUT = 5000;
|
|
32
|
+
const gainRegister = (o) => o.gainRegister ?? DAC_GAIN;
|
|
25
33
|
export const KTMICRO_TYPES = typeCodes('ktmicro', { PK: 0, LPQ: 1, HPQ: 2, LSC: 3, HSC: 4 });
|
|
26
34
|
export function ktmicroRegisters(o, band) {
|
|
27
35
|
if (o.bandRegisters) {
|
|
@@ -42,9 +50,10 @@ const packet = (register, cmd, data = []) => {
|
|
|
42
50
|
const hasPreamp = (o) => o.preampRegister !== false;
|
|
43
51
|
const hasSlots = (o) => o.slotRegister !== false && o.enableRegister === undefined;
|
|
44
52
|
const freqUnit = (o) => o.freqUnit ?? 1;
|
|
53
|
+
const typeFlag = (o) => o.typeFlag ?? 0;
|
|
45
54
|
/** One band from its two register answers or writes. */
|
|
46
55
|
const band = (a, b, o) => ({
|
|
47
|
-
type: KTMICRO_TYPES.decode(b[8] ?? 0),
|
|
56
|
+
type: KTMICRO_TYPES.decode((b[8] ?? 0) & ~typeFlag(o) & 0xff),
|
|
48
57
|
freq: readU16le(a, 8) * freqUnit(o),
|
|
49
58
|
q: readU16le(b, 6) / 1000,
|
|
50
59
|
gain: readI16le(a, 6) / 10
|
|
@@ -67,7 +76,7 @@ export const ktmicroCodec = {
|
|
|
67
76
|
packet(regs.freq, WRITE, [...le16(field(f.gain, 10, I16, 'gain') & 0xffff), ...le16(freq)]),
|
|
68
77
|
packet(regs.q, WRITE, [
|
|
69
78
|
...le16(field(f.q, 1000, U16, 'q')),
|
|
70
|
-
KTMICRO_TYPES.encode(f.type),
|
|
79
|
+
KTMICRO_TYPES.encode(f.type) | typeFlag(o),
|
|
71
80
|
0
|
|
72
81
|
])
|
|
73
82
|
];
|
|
@@ -97,11 +106,25 @@ export const ktmicroCodec = {
|
|
|
97
106
|
function request(ctx, bytes, what, timeout = 1000) {
|
|
98
107
|
return hidRequest(ctx.transport, REPORT_ID, bytes, (d) => d[0] === bytes[0] && d[4] === bytes[4], timeout, what);
|
|
99
108
|
}
|
|
100
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Sends a write. With `writeAck` it waits for the device to say it took; with `writeWait` it
|
|
111
|
+
* waits that long for an answer and goes on without one, whatever the answer holds.
|
|
112
|
+
*/
|
|
101
113
|
async function send(ctx, frame) {
|
|
102
|
-
const ack = ctx.options
|
|
103
|
-
if (ack === undefined)
|
|
104
|
-
|
|
114
|
+
const { writeAck: ack, writeWait } = ctx.options;
|
|
115
|
+
if (ack === undefined) {
|
|
116
|
+
if (!writeWait)
|
|
117
|
+
return sendFrame(ctx.transport, frame);
|
|
118
|
+
try {
|
|
119
|
+
await request(ctx, [...frame.data], `KT Micro write to register ${frame.data[0]}`, writeWait);
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
// Only the missing answer is let go; a send that fails stays an error.
|
|
123
|
+
if (!isBridgeError(e, 'timeout'))
|
|
124
|
+
throw e;
|
|
125
|
+
}
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
105
128
|
const what = `KT Micro write to register ${frame.data[0]}`;
|
|
106
129
|
const answer = await request(ctx, [...frame.data], what, WRITE_TIMEOUT);
|
|
107
130
|
if (answer[6] !== ack) {
|
|
@@ -145,9 +168,13 @@ export const ktmicroUsbHid = {
|
|
|
145
168
|
return { filters, preamp: readI8(preamp, 6) };
|
|
146
169
|
},
|
|
147
170
|
async push(ctx, request) {
|
|
148
|
-
const { enableRegister, frameDelay = 0, bandDelay = 0 } = ctx.options;
|
|
171
|
+
const { enableRegister, enableLast, frameDelay = 0, bandDelay = 0 } = ctx.options;
|
|
149
172
|
const frames = ktmicroCodec.encode(request, ctx.options);
|
|
150
|
-
if (enableRegister !== undefined) {
|
|
173
|
+
if (enableRegister !== undefined && enableLast) {
|
|
174
|
+
// The commit is the last frame: the switch goes in just before it.
|
|
175
|
+
frames.splice(-1, 0, hidFrame(REPORT_ID, packet(enableRegister, WRITE, le32(1))));
|
|
176
|
+
}
|
|
177
|
+
else if (enableRegister !== undefined) {
|
|
151
178
|
await writeRegister(ctx, enableRegister, 1);
|
|
152
179
|
}
|
|
153
180
|
else if (hasSlots(ctx.options) && (await readSlot(ctx)) === (ctx.bypass ?? 2)) {
|
|
@@ -187,15 +214,15 @@ export const ktmicroUsbHid = {
|
|
|
187
214
|
await selectSlot(ctx, enabled ? (slot ?? ctx.options.customSlot ?? 3) : (ctx.bypass ?? 2));
|
|
188
215
|
},
|
|
189
216
|
controls: {
|
|
190
|
-
// The KT0211L's DAC gain, as a step (1.5 dB each, 0 mutes) or, on some models, in dB: the
|
|
217
|
+
// The KT0211L's DAC gain (register 0x3b, or `gainRegister`), as a step (1.5 dB each, 0 mutes) or, on some models, in dB: the
|
|
191
218
|
// register holds minus ten times the dB.
|
|
192
219
|
globalGain: {
|
|
193
|
-
read: async (ctx) => (await readRegister(ctx,
|
|
194
|
-
write: (ctx, value) => writeRegister(ctx,
|
|
220
|
+
read: async (ctx) => (await readRegister(ctx, gainRegister(ctx.options), 'KT Micro DAC gain')) & 0x0f,
|
|
221
|
+
write: (ctx, value) => writeRegister(ctx, gainRegister(ctx.options), value)
|
|
195
222
|
},
|
|
196
223
|
globalGainDb: {
|
|
197
|
-
read: async (ctx) => 0 - (await readRegister(ctx,
|
|
198
|
-
write: (ctx, value) => writeRegister(ctx,
|
|
224
|
+
read: async (ctx) => 0 - (await readRegister(ctx, gainRegister(ctx.options), 'KT Micro DAC gain')) / 10,
|
|
225
|
+
write: (ctx, value) => writeRegister(ctx, gainRegister(ctx.options), Math.round(-value * 10))
|
|
199
226
|
}
|
|
200
227
|
}
|
|
201
228
|
};
|