@trippnology/mixshell 0.7.0 → 0.7.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.
package/README.md CHANGED
@@ -34,7 +34,13 @@ npm install -g @trippnology/mixshell
34
34
  ```
35
35
 
36
36
  That's it — everything else MixShell needs, including its own copy of
37
- ffmpeg, is downloaded automatically during install.
37
+ ffmpeg, is downloaded automatically during install. One exception: the
38
+ default engine's `speaker` module compiles from source at install time.
39
+ On Windows that needs a C++ compiler: install the "Desktop development
40
+ with C++" workload of [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
41
+ (or tick "Tools for Native Modules" in the Node.js installer). Without
42
+ it the install still succeeds and MixShell plays through WebAudio
43
+ instead, with a message at first play. See Troubleshooting below.
38
44
 
39
45
  ## Usage
40
46
 
@@ -72,12 +78,12 @@ no extra setup, so you can skip this section unless something won't play
72
78
  or you like tinkering. Switch in **Settings → General → Audio Engine** —
73
79
  the choice is saved and takes effect the next time you press play.
74
80
 
75
- | | `ffmpeg` (default) | `webaudio` |
76
- | ------------ | ---------------------------------- | --------------------------------------------- |
77
- | Extra setup | none | Linux: needs `pipewire-jack` (see below) |
78
- | File types | anything ffmpeg can decode | MP3, FLAC, WAV, OGG, m4a |
79
- | Memory use | streams the file, stays constant | loads the whole file into memory (~21 MB/min) |
80
- | Sound device | pick any output device in Settings | system default only |
81
+ | | `ffmpeg` (default) | `webaudio` |
82
+ | ------------ | ----------------------------------------------- | --------------------------------------------- |
83
+ | Extra setup | Windows: C++ build tools (or WebAudio fallback) | Linux: needs `pipewire-jack` (see below) |
84
+ | File types | anything ffmpeg can decode | MP3, FLAC, WAV, OGG, m4a |
85
+ | Memory use | streams the file, stays constant | loads the whole file into memory (~21 MB/min) |
86
+ | Sound device | pick any output device in Settings | system default only |
81
87
 
82
88
  Which to pick? The default is the safe choice: no system dependencies,
83
89
  small memory footprint, and any output device. The `webaudio` option can
@@ -218,6 +224,26 @@ The `onboarded` flag tracks first-run setup and is maintained by
218
224
  it finishes anyway, and MixShell then fails at startup with a module
219
225
  error. If you see that, update Node rather than debugging the error.
220
226
 
227
+ **`speaker` failed to build on Windows.** At first play, a message says
228
+ the default audio engine did not install and WebAudio output is being
229
+ used. That means the native `speaker` module could not compile. To get
230
+ the default engine back:
231
+
232
+ 1. Install the [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
233
+ with the "Desktop development with C++" workload, or tick "Tools for
234
+ Native Modules" in the Node.js installer.
235
+ 2. Reinstall: `npm install -g @trippnology/mixshell`.
236
+
237
+ Use the **2022** Build Tools, not only Visual Studio 2026: releases
238
+ before this fix ship a build helper (`node-gyp`) that predates VS 2026
239
+ and reports `could not find a version of Visual Studio 2017 or newer`
240
+ even when 2026 is installed. Newer releases bundle a helper that
241
+ recognises it. If npm also reports `EPERM` while removing a folder such
242
+ as `node_modules\speaker\deps`, add an exclusion for `AppData\Roaming\npm`
243
+ in your antivirus, remove
244
+ `C:\Users\<you>\AppData\Roaming\npm\node_modules\@trippnology`, then
245
+ reinstall.
246
+
221
247
  **Optional dependencies.** Two npm packages MixShell uses are marked
222
248
  optional — npm tolerates their install failing and MixShell runs without
223
249
  them: `dbus-next` (media keys, above) and `node-web-audio-api` (the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trippnology/mixshell",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Terminal-based music player",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -48,7 +48,7 @@
48
48
  "commander": "15.1.0",
49
49
  "fft.js": "4.0.4",
50
50
  "music-metadata": "12.7.0",
51
- "speaker": "0.5.5"
51
+ "node-gyp": "13.1.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@biomejs/biome": "2.6.8",
@@ -57,10 +57,11 @@
57
57
  },
58
58
  "optionalDependencies": {
59
59
  "dbus-next": "0.10.2",
60
- "node-web-audio-api": "2.2.0"
60
+ "node-web-audio-api": "2.2.0",
61
+ "speaker": "0.5.5"
61
62
  },
62
63
  "overrides": {
63
- "node-gyp": "12.4.0"
64
+ "node-gyp": "13.1.0"
64
65
  },
65
66
  "allowScripts": {
66
67
  "@ffmpeg-installer/linux-x64@4.1.0": true,
@@ -1,5 +1,6 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
 
3
+ import { loadSpeaker } from '../engines/ffmpeg.js';
3
4
  import { createAudioEngine } from '../engines/index.js';
4
5
  import { markDeviceBroken, probeDevice } from '../utils/audioDevices.js';
5
6
  import { readMetadata } from '../utils/id3.js';
@@ -11,7 +12,12 @@ function resolveDevice(config) {
11
12
  }
12
13
 
13
14
  export class Player extends EventEmitter {
14
- constructor(playlist, config, analyzer = null, { probeDevice: probe } = {}) {
15
+ constructor(
16
+ playlist,
17
+ config,
18
+ analyzer = null,
19
+ { probeDevice: probe, speakerLoader = loadSpeaker } = {},
20
+ ) {
15
21
  super();
16
22
  this.playlist = playlist;
17
23
  this.config = config;
@@ -20,6 +26,9 @@ export class Player extends EventEmitter {
20
26
  // Device gate (issues/047): play-time probe of the resolved device,
21
27
  // injectable for tests.
22
28
  this._probe = probe ?? probeDevice;
29
+ // Optional native sink (issues/067): injectable for tests; the real
30
+ // loader throws MODULE_NOT_FOUND when speaker failed to build.
31
+ this._speakerLoader = speakerLoader;
23
32
  // speaker load canary: the native binding probes the literal ALSA
24
33
  // "default" at require time and SIGABRTs the process when that open
25
34
  // fails — regardless of the device we would then hand it. Canary
@@ -122,13 +131,28 @@ export class Player extends EventEmitter {
122
131
  if (name !== 'ffmpeg' || this._defaultChecked) return;
123
132
  this._defaultChecked = true;
124
133
  const ok = await this._probe('default');
125
- if (ok) return;
126
- this._forcedEngine = 'webaudio';
127
- this.emit(
128
- 'debug',
129
- 'audio: system default unusable — speaker load would abort; using webaudio for this session',
130
- );
131
- this.emit('engineFallback', 'ffmpeg');
134
+ if (!ok) {
135
+ this._forcedEngine = 'webaudio';
136
+ this.emit(
137
+ 'debug',
138
+ 'audio: system default unusable — speaker load would abort; using webaudio for this session',
139
+ );
140
+ this.emit('engineFallback', 'ffmpeg');
141
+ return;
142
+ }
143
+ // The ALSA probe passed, so loading the binding cannot SIGABRT.
144
+ // A failed optional build (issues/067) is the other reason ffmpeg
145
+ // cannot run — fall back the same way, with a reason for the toast.
146
+ try {
147
+ this._speakerLoader();
148
+ } catch {
149
+ this._forcedEngine = 'webaudio';
150
+ this.emit(
151
+ 'debug',
152
+ 'audio: speaker module unavailable — using webaudio for this session',
153
+ );
154
+ this.emit('engineFallback', 'ffmpeg', 'speaker-unavailable');
155
+ }
132
156
  }
133
157
 
134
158
  async _resolveDeviceForPlay() {
@@ -7,8 +7,9 @@ import ffmpeg from '@ffmpeg-installer/ffmpeg';
7
7
 
8
8
  // No top-level `speaker` import: loading the native binding can open ALSA
9
9
  // and abort the process on device-less systems. It is resolved lazily on
10
- // first real playback; tests inject a fake sink instead.
11
- const loadSpeaker = () => createRequire(import.meta.url)('speaker');
10
+ // first real playback; tests inject a fake sink instead. Exported so the
11
+ // Player can canary it before the first load (issues/067).
12
+ export const loadSpeaker = () => createRequire(import.meta.url)('speaker');
12
13
 
13
14
  const STDERR_BUF_CHARS = 2000;
14
15
 
@@ -516,6 +517,14 @@ export class FFmpegEngine extends EventEmitter {
516
517
  // Player can fall back to the system default instead of
517
518
  // skipping the queue track by track.
518
519
  err.device = this.device;
520
+ // An absent native binding (issues/067) reaches here when the
521
+ // Player preflight canary was bypassed — never leave a bare
522
+ // MODULE_NOT_FOUND stack as the user's only clue.
523
+ if (err.code === 'MODULE_NOT_FOUND' && /speaker/.test(err.message)) {
524
+ err.message =
525
+ 'Speaker audio module unavailable — WebAudio output will be used. See README → Troubleshooting. ' +
526
+ err.message;
527
+ }
519
528
  this.emit('error', err);
520
529
  return false;
521
530
  }
@@ -1510,7 +1510,20 @@ export function init(term, app, attachReady) {
1510
1510
  // speaker load canary (player): the ffmpeg engine cannot run on systems
1511
1511
  // whose system default the binding cannot open — play continues on
1512
1512
  // webaudio for the session.
1513
- player.on('engineFallback', (from) => {
1513
+ player.on('engineFallback', (from, reason) => {
1514
+ if (reason === 'speaker-unavailable') {
1515
+ const tools =
1516
+ process.platform === 'win32'
1517
+ ? ' (Visual Studio Build Tools + Python)'
1518
+ : '';
1519
+ log(
1520
+ `Audio engine ${from} could not load speaker${tools} — using WebAudio`,
1521
+ );
1522
+ showMessage(
1523
+ `Default audio engine did not install${tools} — using WebAudio; see README → Troubleshooting`,
1524
+ );
1525
+ return;
1526
+ }
1514
1527
  log(`Audio engine ${from} unusable (system default) — using WebAudio`);
1515
1528
  showMessage('System audio default unusable — using WebAudio output');
1516
1529
  });