@djodjonx/x32-simulator 0.0.1

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.
Files changed (86) hide show
  1. package/.commitlintrc.json +3 -0
  2. package/.github/workflows/publish.yml +38 -0
  3. package/.husky/commit-msg +1 -0
  4. package/.husky/pre-commit +1 -0
  5. package/.oxlintrc.json +56 -0
  6. package/CHANGELOG.md +11 -0
  7. package/INSTALL.md +107 -0
  8. package/LICENSE +21 -0
  9. package/README.md +141 -0
  10. package/dist/UdpNetworkGateway-BrroQ6-Q.mjs +1189 -0
  11. package/dist/UdpNetworkGateway-Ccdd7Us5.cjs +1265 -0
  12. package/dist/index.cjs +7 -0
  13. package/dist/index.d.cts +207 -0
  14. package/dist/index.d.mts +207 -0
  15. package/dist/index.mjs +3 -0
  16. package/dist/server.cjs +1060 -0
  17. package/dist/server.d.cts +10 -0
  18. package/dist/server.d.mts +10 -0
  19. package/dist/server.mjs +1055 -0
  20. package/docs/OSC-Communication.md +184 -0
  21. package/docs/X32-INTERNAL.md +262 -0
  22. package/docs/X32-OSC.pdf +0 -0
  23. package/docs/behringer-x32-x32-osc-remote-protocol-en-44463.pdf +0 -0
  24. package/package.json +68 -0
  25. package/src/application/use-cases/BroadcastUpdatesUseCase.ts +120 -0
  26. package/src/application/use-cases/ManageSessionsUseCase.ts +9 -0
  27. package/src/application/use-cases/ProcessPacketUseCase.ts +26 -0
  28. package/src/application/use-cases/SimulationService.ts +122 -0
  29. package/src/domain/entities/SubscriptionManager.ts +126 -0
  30. package/src/domain/entities/X32State.ts +78 -0
  31. package/src/domain/models/MeterConfig.ts +22 -0
  32. package/src/domain/models/MeterData.ts +59 -0
  33. package/src/domain/models/OscMessage.ts +93 -0
  34. package/src/domain/models/X32Address.ts +78 -0
  35. package/src/domain/models/X32Node.ts +43 -0
  36. package/src/domain/models/types.ts +96 -0
  37. package/src/domain/ports/ILogger.ts +27 -0
  38. package/src/domain/ports/INetworkGateway.ts +8 -0
  39. package/src/domain/ports/IStateRepository.ts +16 -0
  40. package/src/domain/services/MeterService.ts +46 -0
  41. package/src/domain/services/OscMessageHandler.ts +88 -0
  42. package/src/domain/services/SchemaFactory.ts +308 -0
  43. package/src/domain/services/SchemaRegistry.ts +67 -0
  44. package/src/domain/services/StaticResponseService.ts +52 -0
  45. package/src/domain/services/strategies/BatchStrategy.ts +74 -0
  46. package/src/domain/services/strategies/MeterStrategy.ts +45 -0
  47. package/src/domain/services/strategies/NodeDiscoveryStrategy.ts +36 -0
  48. package/src/domain/services/strategies/OscCommandStrategy.ts +22 -0
  49. package/src/domain/services/strategies/StateAccessStrategy.ts +71 -0
  50. package/src/domain/services/strategies/StaticResponseStrategy.ts +42 -0
  51. package/src/domain/services/strategies/SubscriptionStrategy.ts +56 -0
  52. package/src/infrastructure/mappers/OscCodec.ts +54 -0
  53. package/src/infrastructure/repositories/InMemoryStateRepository.ts +21 -0
  54. package/src/infrastructure/services/ConsoleLogger.ts +177 -0
  55. package/src/infrastructure/services/UdpNetworkGateway.ts +71 -0
  56. package/src/presentation/cli/server.ts +194 -0
  57. package/src/presentation/library/library.ts +9 -0
  58. package/tests/application/use-cases/BroadcastUpdatesUseCase.test.ts +104 -0
  59. package/tests/application/use-cases/ManageSessionsUseCase.test.ts +12 -0
  60. package/tests/application/use-cases/ProcessPacketUseCase.test.ts +49 -0
  61. package/tests/application/use-cases/SimulationService.test.ts +77 -0
  62. package/tests/domain/entities/SubscriptionManager.test.ts +50 -0
  63. package/tests/domain/entities/X32State.test.ts +52 -0
  64. package/tests/domain/models/MeterData.test.ts +23 -0
  65. package/tests/domain/models/OscMessage.test.ts +38 -0
  66. package/tests/domain/models/X32Address.test.ts +30 -0
  67. package/tests/domain/models/X32Node.test.ts +30 -0
  68. package/tests/domain/services/MeterService.test.ts +27 -0
  69. package/tests/domain/services/OscMessageHandler.test.ts +51 -0
  70. package/tests/domain/services/SchemaRegistry.test.ts +47 -0
  71. package/tests/domain/services/StaticResponseService.test.ts +15 -0
  72. package/tests/domain/services/strategies/BatchStrategy.test.ts +41 -0
  73. package/tests/domain/services/strategies/MeterStrategy.test.ts +19 -0
  74. package/tests/domain/services/strategies/NodeDiscoveryStrategy.test.ts +22 -0
  75. package/tests/domain/services/strategies/StateAccessStrategy.test.ts +49 -0
  76. package/tests/domain/services/strategies/StaticResponseStrategy.test.ts +15 -0
  77. package/tests/domain/services/strategies/SubscriptionStrategy.test.ts +45 -0
  78. package/tests/infrastructure/mappers/OscCodec.test.ts +41 -0
  79. package/tests/infrastructure/repositories/InMemoryStateRepository.test.ts +29 -0
  80. package/tests/infrastructure/services/ConsoleLogger.test.ts +74 -0
  81. package/tests/infrastructure/services/UdpNetworkGateway.test.ts +61 -0
  82. package/tests/presentation/cli/server.test.ts +178 -0
  83. package/tests/presentation/library/library.test.ts +13 -0
  84. package/tsconfig.json +21 -0
  85. package/tsdown.config.ts +15 -0
  86. package/vitest.config.ts +9 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["@commitlint/config-conventional"]
3
+ }
@@ -0,0 +1,38 @@
1
+ name: Publish Package to npmjs
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ id-token: write # Required for OIDC
10
+ contents: write # Required to create GitHub Releases
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - uses: actions/setup-node@v4
19
+ with:
20
+ node-version: '20.x'
21
+ registry-url: 'https://registry.npmjs.org'
22
+
23
+ # Ensure npm is up-to-date
24
+ - name: Update npm
25
+ run: npm install -g npm@latest
26
+
27
+ - run: npm ci
28
+ - run: npm run build
29
+ - run: npm test
30
+ - run: npm publish --provenance --access public
31
+ env:
32
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
33
+
34
+ - name: Create GitHub Release
35
+ uses: softprops/action-gh-release@v2
36
+ with:
37
+ generate_release_notes: true
38
+ make_latest: true
@@ -0,0 +1 @@
1
+ npx --no -- commitlint --edit $1
@@ -0,0 +1 @@
1
+ npx lint-staged
package/.oxlintrc.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
3
+ "plugins": [
4
+ "typescript",
5
+ "vitest",
6
+ "unicorn",
7
+ "oxc",
8
+ "import",
9
+ "jsdoc"
10
+ ],
11
+ "categories": {
12
+ "correctness": "error",
13
+ "suspicious": "error",
14
+ "pedantic": "off",
15
+ "style": "off",
16
+ "perf": "warn"
17
+ },
18
+ "rules": {
19
+ "import/prefer-default-export": "off",
20
+ "import/no-named-export": "off",
21
+ "unicorn/filename-case": "off",
22
+ "eslint/no-magic-numbers": "off",
23
+ "eslint/max-lines-per-function": "off",
24
+ "eslint/max-statements": "off",
25
+ "eslint/max-params": "off",
26
+ "eslint/max-lines": "off",
27
+ "unicorn/no-zero-fractions": "off",
28
+ "eslint/sort-keys": "off",
29
+ "eslint/sort-imports": "off",
30
+ "typescript/consistent-type-imports": "off",
31
+ "jsdoc/require-param-type": "off",
32
+ "jsdoc/require-returns-type": "off",
33
+ "jsdoc/require-returns": "off",
34
+ "typescript/no-inferrable-types": "off",
35
+ "unicorn/prefer-top-level-await": "off",
36
+ "unicorn/no-null": "off",
37
+ "unicorn/prevent-abbreviations": "off",
38
+ "eslint/id-length": "off"
39
+ },
40
+ "overrides": [
41
+ {
42
+ "files": ["tests/**/*.ts"],
43
+ "rules": {
44
+ "eslint/no-magic-numbers": "off"
45
+ }
46
+ }
47
+ ],
48
+ "settings": {
49
+ "vitest": {
50
+ "typecheck": true
51
+ }
52
+ },
53
+ "env": {
54
+ "builtin": true
55
+ }
56
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### 0.0.1 (2026-01-08)
6
+
7
+
8
+ ### Features
9
+
10
+ * implement x32 simulation logic ([2b40d1c](https://github.com/djodjonx/x32-simulator/commit/2b40d1c9173f4c0653097334ab3c0bd96e2cf966))
11
+ * initial project scaffold ([a0552c1](https://github.com/djodjonx/x32-simulator/commit/a0552c1a47baa2e578fe816231c697cfa20f7f62))
package/INSTALL.md ADDED
@@ -0,0 +1,107 @@
1
+ # Development Guide
2
+
3
+ This guide is for developers who want to contribute to the `x32-simulator` project or build it from source.
4
+
5
+ ## 📋 Prerequisites
6
+
7
+ * **Node.js**: Version 20 or higher is required.
8
+ * Verify with `node -v`
9
+ * **npm**: Comes bundled with Node.js.
10
+
11
+ ## 🛠️ Setup
12
+
13
+ 1. **Clone the repository:**
14
+ ```bash
15
+ git clone https://github.com/djodjonx/x32-simulator.git
16
+ cd x32-simulator
17
+ ```
18
+
19
+ 2. **Install dependencies:**
20
+ We use `npm ci` for reliable builds based on `package-lock.json`.
21
+ ```bash
22
+ npm ci
23
+ ```
24
+
25
+ ## 💻 Development Workflow
26
+
27
+ ### Running in Watch Mode
28
+ For rapid development, use the dev script. It re-bundles the project on file changes.
29
+ ```bash
30
+ npm run dev
31
+ ```
32
+
33
+ ### Running Tests
34
+ We use **Vitest** for testing.
35
+
36
+ * **Run all tests:**
37
+ ```bash
38
+ npm test
39
+ ```
40
+ * **Run with coverage:**
41
+ ```bash
42
+ npm run test:coverage
43
+ ```
44
+ * **Watch mode (TDD):**
45
+ ```bash
46
+ npm run test:watch
47
+ ```
48
+
49
+ ### Code Quality
50
+ Ensure your code meets the project standards before committing.
51
+
52
+ * **Linting (Oxlint):**
53
+ ```bash
54
+ npm run lint
55
+ ```
56
+ * **Type Checking:**
57
+ ```bash
58
+ npm run type-check
59
+ ```
60
+
61
+ ## 🏗️ Building
62
+
63
+ To build the project for production distribution:
64
+
65
+ ```bash
66
+ npm run build
67
+ ```
68
+
69
+ This uses `tsdown` to bundle the code into the `dist/` directory:
70
+ * `dist/server.mjs`: The executable CLI.
71
+ * `dist/index.mjs` / `.cjs`: The library entry points.
72
+
73
+ ## 📂 Project Structure
74
+
75
+ The project follows a **Clean Architecture** / **Hexagonal** structure:
76
+
77
+ ```
78
+ src/
79
+ ├── application/ # Use Cases (Business Logic orchestration)
80
+ ├── domain/ # Core Business Logic (Entities, Models, Ports)
81
+ ├── infrastructure/ # External adapters (UDP, Logging, Repositories)
82
+ └── presentation/ # Entry points
83
+ ├── cli/ # CLI Server implementation
84
+ └── library/ # Library exports
85
+ ```
86
+
87
+ ## 🚀 Releasing
88
+
89
+ We use `standard-version` to automate versioning and changelog generation.
90
+
91
+ 1. **Create a release:**
92
+ ```bash
93
+ npm run release
94
+ ```
95
+ This command will:
96
+ * Bump the version in `package.json`.
97
+ * Update `CHANGELOG.md`.
98
+ * Commit these changes.
99
+ * Create a git tag (e.g., `v1.1.0`).
100
+
101
+ 2. **Push changes:**
102
+ ```bash
103
+ git push --follow-tags
104
+ ```
105
+
106
+ 3. **Publish:**
107
+ The GitHub Action workflow will automatically detect the new tag, build the project, and publish it to NPM.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jonathan Moutier
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # X32 Digital Mixer Simulator
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@djodjonx/x32-simulator.svg)](https://www.npmjs.com/package/@djodjonx/x32-simulator)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ A fully functional **Behringer X32 / Midas M32 OSC Simulator**.
7
+
8
+ This tool allows developers to build, test, and debug X32/M32 remote control applications without needing physical hardware. It accurately replicates the mixer's state management, OSC protocol quirks, and network behavior.
9
+
10
+ ---
11
+
12
+ ## 🚀 Features
13
+
14
+ * **Complete State Simulation**: Simulates ~4000+ OSC parameters including Channels, Buses, Matrices, FX, Routing, and Config.
15
+ * **Accurate OSC Protocol**: Supports `node-osc` based communication over UDP.
16
+ * **Subscription Management**: Handles `/xremote`, `/subscribe`, and `/renew` logic for client updates.
17
+ * **Meter Simulation**: Generates synthetic meter data for `/meters/0` through `/meters/15` endpoints.
18
+ * **Dual Mode**: Run as a **Standalone CLI Server** or embed as a **Library** in your Node.js tests.
19
+ * **Zero Dependencies** (runtime): The published package bundles everything needed.
20
+
21
+ ---
22
+
23
+ ## 📦 Installation
24
+
25
+ ### As a CLI Tool (Global)
26
+ Install globally to run the simulator from anywhere in your terminal.
27
+
28
+ ```bash
29
+ npm install -g @djodjonx/x32-simulator
30
+ ```
31
+
32
+ ### As a Library (Local)
33
+ Install in your project to use it in integration tests.
34
+
35
+ ```bash
36
+ npm install --save-dev @djodjonx/x32-simulator
37
+ ```
38
+
39
+ ---
40
+
41
+ ## 🖥️ CLI Usage
42
+
43
+ Start the simulator server:
44
+
45
+ ```bash
46
+ x32-simulator
47
+ ```
48
+
49
+ ### Options
50
+
51
+ | Flag | Alias | Description | Default |
52
+ |------|-------|-------------|---------|
53
+ | `--port` | `-p` | UDP Port to listen on | `10023` |
54
+ | `--host` | `-h` | IP Address to bind to | `0.0.0.0` |
55
+
56
+ **Example:**
57
+ ```bash
58
+ x32-simulator --port 5000 --host 127.0.0.1
59
+ ```
60
+
61
+ ### 🌐 Network Setup (IP Aliasing)
62
+
63
+ If you need to simulate a specific console IP (e.g., `192.168.1.100`) that is not assigned to your machine, you must create a **Network Alias**. This allows the simulator to "own" that IP locally.
64
+
65
+ | OS | Create Alias Command | Remove Alias Command |
66
+ |----|----------------------|----------------------|
67
+ | **macOS** | `sudo ifconfig lo0 alias <IP>` | `sudo ifconfig lo0 -alias <IP>` |
68
+ | **Linux** | `sudo ip addr add <IP>/32 dev lo` | `sudo ip addr del <IP>/32 dev lo` |
69
+ | **Windows** | `netsh interface ip add address "Loopback" <IP> 255.255.255.255` | `netsh interface ip delete address "Loopback" <IP>` |
70
+
71
+ > **Note (Windows):** Requires the "Microsoft Loopback Adapter" to be installed and named "Loopback" in your Network Connections.
72
+
73
+ ### Interactive Commands
74
+ Once running, the CLI accepts these commands:
75
+ * `reset`: Resets all faders and parameters to default values.
76
+ * `stop` / `exit`: Shuts down the server.
77
+
78
+ ---
79
+
80
+ ## 📚 Library Usage
81
+
82
+ Perfect for integration testing your X32 client apps.
83
+
84
+ ```typescript
85
+ import { SimulationService, UdpNetworkGateway, ConsoleLogger, InMemoryStateRepository, SchemaFactory, SchemaRegistry, OscCodec } from '@djodjonx/x32-simulator';
86
+
87
+ // 1. Setup Dependencies
88
+ const logger = ConsoleLogger.getInstance();
89
+ const schemaRegistry = new SchemaRegistry(new SchemaFactory());
90
+ const codec = new OscCodec(schemaRegistry);
91
+ const gateway = new UdpNetworkGateway(logger, codec);
92
+ const repository = new InMemoryStateRepository(logger, schemaRegistry);
93
+
94
+ // 2. Initialize Service
95
+ const simulator = new SimulationService(
96
+ gateway,
97
+ logger,
98
+ repository,
99
+ schemaRegistry,
100
+ 10023, // Port
101
+ '127.0.0.1' // Host
102
+ );
103
+
104
+ // 3. Start & Stop
105
+ await simulator.start();
106
+ console.log('Simulator running...');
107
+
108
+ // ... run your tests ...
109
+
110
+ await simulator.stop();
111
+ ```
112
+
113
+ ---
114
+
115
+ ## 🎛️ Simulated OSC Map
116
+
117
+ The simulator covers a vast majority of the X32 OSC command set:
118
+
119
+ | Category | OSC Path Pattern | Description |
120
+ |----------|------------------|-------------|
121
+ | **Channels** | `/ch/{01..32}/...` | Config, Preamp, Gate, Dyn, EQ, Mix, Sends |
122
+ | **Buses** | `/bus/{01..16}/...` | Config, Dyn, EQ, Mix, Sends |
123
+ | **DCA** | `/dca/{1..8}/...` | Config, Fader, Mute |
124
+ | **Matrix** | `/mtx/{01..06}/...` | Config, Dyn, EQ, Mix |
125
+ | **Aux In** | `/auxin/{01..08}/...` | Config, Preamp, EQ, Mix |
126
+ | **FX Returns** | `/fxrtn/{01..08}/...` | Config, EQ, Mix |
127
+ | **Effects** | `/fx/{1..8}/...` | Type, Parameters, Source |
128
+ | **Headamps** | `/headamp/{000..127}/...` | Gain, Phantom Power |
129
+ | **Routing** | `/config/routing/...` | Input, Output, Card, AES50 Routing |
130
+ | **Status** | `/-stat/...` | Selected Channel, Sends on Fader, Screen State |
131
+ | **Meters** | `/meters/...` | Meter data blobs (simulated noise) |
132
+
133
+ ---
134
+
135
+ ## 🤝 Contributing
136
+
137
+ We welcome contributions! Please see [INSTALL.md](./INSTALL.md) for development instructions.
138
+
139
+ ## 📄 License
140
+
141
+ MIT © [Jonathan Moutier](https://github.com/djodjonx)