nu_plugin_audio 0.2.4

A nushell plugin to make and play sounds
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# nu_plugin_audio


[![Nushell](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FSuaveIV%2Fnu_plugin_audio%2Fmain%2FCargo.toml&query=%24.dependencies%5B%22nu-plugin%22%5D.version&label=nushell&color=blue&logo=nushell)](https://www.nushell.sh/)
[![crates.io](https://img.shields.io/crates/v/nu_plugin_audio.svg)](https://crates.io/crates/nu_plugin_audio)
[![Downloads](https://img.shields.io/crates/d/nu_plugin_audio.svg)](https://crates.io/crates/nu_plugin_audio)

A [Nushell](https://www.nushell.sh/) plugin to generate and play sounds. It supports tone generation, metadata manipulation, and playback for multiple audio formats.

## Origins and Attribution


This project is a continuation and expansion of the original `nu_plugin_audio_hook` created by [fmotalleb](https://github.com/fmotalleb/nu_plugin_audio_hook). Due to real-world circumstances, the original author plans to archive their repository and step away from development. They gave explicit permission to fork the project and keep the code alive. I am incredibly grateful for their hard work in laying the foundation for this tool.

---

## Features


- `sound beep` - Play a simple beep sound.
- `sound make` - Generate a noise with a given frequency and duration.
- `sound meta` - Retrieve metadata (duration, artist, album, etc.) from an audio file.
- `sound meta set` - Modify metadata tags in an audio file using format-agnostic key names.
- `sound play` - Play an audio file with a live progress display and interactive controls. By default, it supports FLAC, WAV, MP3, OGG, AAC, and MP4 playback. Use the `all-decoders` feature for an expanded set like minimp3 or 64-bit support.

---

## Usage


### Generate a simple noise


```bash
sound make 1000 200ms
```

### Generate a noise sequence


```bash
[ 300.0, 500.0, 1000.0, 400.0, 600.0 ] | each { |it| sound make $it 150ms }
```

### Generate a noise with 50% volume


```bash
sound make 1000 200ms -a 0.5
```

### Save a generated tone to a file


```bash
sound make 1000 200ms --data | save --raw output.wav
```

### Play an audio file (first 3 seconds only)


```bash
sound play audio.mp3 -d 3sec
```

### Play an audio file starting at 2x volume


```bash
sound play audio.mp3 -a 2.0
```

### Play an audio file starting at 50% volume


```bash
sound play audio.mp3 -a 0.5
```

### Play silently (no terminal output for scripts or background tasks)


```bash
sound play audio.mp3 --no-progress
```

### Play with Nerd Font icons


```bash
sound play audio.mp3 --nerd-fonts
```

### Retrieve metadata from an audio file


```bash
sound meta audio.mp3
```

Example output:

```nushell
╭───────────────┬────────────────────────────╮
│ size          │ 6.4 MiB                    │
│ format        │ mp3                        │
│ bitrate       │ 320                        │
│ audio_bitrate │ 320                        │
│ artist        │ SINGER                     │
│ title         │ TITLE                      │
│ album         │ ALBUM                      │
│ albumartist   │ SINGER                     │
│ comment       │ Tagged with MusicBrainz    │
│ date          │ 2024-03-15                 │
│ genre         │ Rock                       │
│ track_no      │ 1                          │
│ total_tracks  │ 12                         │
│ artwork       │ [list 1 item]              │
│ duration      │ 4:05                       │
│ sample_rate   │ 44100                      │
│ channels      │ 2                          │
╰───────────────┴────────────────────────────╯
```

The `artwork` field is a list of records, one per embedded image:

```nushell
sound meta audio.mp3 | get artwork
# ╭───┬───────────────┬────────────┬──────────╮
# │ # │ pic_type      │ mime_type  │ size     │

# ├───┼───────────────┼────────────┼──────────┤

# │ 0 │ CoverFront    │ image/jpeg │ 127.3 KB │

# ╰───┴───────────────┴────────────┴──────────╯

```

FLAC and lossless files additionally expose `bit_depth`:

```nushell
sound meta audio.flac | select size format bitrate bit_depth
# ╭───────────┬──────────╮
# │ size      │ 42.3 MiB │

# │ format    │ flac     │

# │ bitrate   │ 1411     │

# │ bit_depth │ 24       │

# ╰───────────┴──────────╯

```

### Modify metadata (change the artist tag)


```bash
sound meta set audio.mp3 -k artist -v "new-artist"
```

Key names are case-insensitive. `artist`, `Artist`, and `ARTIST` all work. Key names are format-agnostic. The same key works across MP3, FLAC, OGG, and MP4 files. Use `sound meta --all` to list every available key name.

### Set a comment tag


```bash
sound meta set audio.mp3 -k comment -v "ripped from vinyl"
```

### Set ReplayGain values


```bash
sound meta set audio.mp3 -k replaygain_track_gain -v "-6.2 dB"
sound meta set audio.mp3 -k replaygain_track_peak -v "0.998"
```

### List all available metadata key names


```bash
sound meta --all
```

Key names are normalised to lowercase before lookup, so `Artist`, `ARTIST`, and `artist` are all accepted. The table below shows every supported key grouped by category.

#### Core identity


| Key | Maps to |
| --- | --- |
| `album` | Album title |
| `albumartist` | Album-level artist |
| `albumsortorder` | Album title sort order |
| `artist` | Track artist |
| `artistsortorder` | Track artist sort order |
| `title` | Track title |
| `titlesortorder` | Track title sort order |
| `subtitle` | Track subtitle |
| `setsubtitle` | Set/disc subtitle |

#### People & roles


| Key | Maps to |
| --- | --- |
| `composer` | Composer |
| `composersortorder` | Composer sort order |
| `conductor` | Conductor |
| `label` | Record label |
| `lyricist` | Lyricist |
| `movement` | Movement name |
| `movementnumber` | Movement number |
| `movementtotal` | Total movements |
| `organization` | Publisher |
| `producer` | Producer |
| `publisher` | Publisher (alias for `organization`) |
| `remixer` | Remixer / mix artist |
| `work` | Work title |

#### Dates


| Key | Maps to |
| --- | --- |
| `date` | Recording date (ISO 8601, e.g. `2024-03-15`) |
| `originalyear` | Original release date |
| `releasedate` | Release date |
| `year` | Release year (bare integer) |

#### Identifiers


| Key | Maps to |
| --- | --- |
| `barcode` | Release barcode (EAN/UPC) |
| `cataloguenumber` | Catalogue number |
| `isrc` | ISRC |

#### Style & content


| Key | Maps to |
| --- | --- |
| `bpm` | BPM (decimal string) |
| `comment` | Comment |
| `compilation` | Compilation flag (`1` / `0`) |
| `copyright` | Copyright message |
| `discnumber` | Disc number |
| `encodedby` | Encoded by |
| `encodingsettings` | Encoder settings |
| `genre` | Genre |
| `grouping` | Content group / grouping |
| `initialkey` | Initial key (e.g. `Am`) |
| `language` | Language |
| `lyrics` | Lyrics text |
| `mood` | Mood |
| `originalalbum` | Original album title |
| `originalartist` | Original artist |
| `script` | Script (e.g. `Latin`) |
| `track` | Track number |

#### ReplayGain


| Key | Maps to |
| --- | --- |
| `replaygain_album_gain` | Album gain (dB string, e.g. `-6.5 dB`) |
| `replaygain_album_peak` | Album peak (float string, e.g. `0.998`) |
| `replaygain_track_gain` | Track gain |
| `replaygain_track_peak` | Track peak |

---

## Live Playback Display


When you play a file, `sound play` renders a live progress bar to stderr:

```nushell
▶  0:42 / 4:05  [██████████░░░░░░░░░░░░░░░░░░░░]  17%  🔊 [████████░░░░░░] 100%
```

Because the display writes to stderr, stdout remains clean. Piping the result of `sound play` to another command works without any garbled output. Use `--no-progress` (`-q`) to suppress the display entirely.

### Nerd Font mode


If you have a [Nerd Font](https://www.nerdfonts.com) installed and configured in your terminal, pass `--nerd-fonts` (`-n`) or set `NERD_FONTS=1` in your environment for richer icons:

```nushell
  0:42 / 4:05  [██████████░░░░░░░░░░░░░░░░░░░░]  17%   [████████░░░░░░] 100%
```

To enable permanently, add this to your `env.nu`:

```nushell
$env.NERD_FONTS = "1"
```

---

## Interactive Controls


For files longer than **1 minute**, interactive keyboard controls are enabled automatically:

| Key | Action |
| --- | --- |
| `Space` | Play / pause |
| `` or `l` | Seek forward 5 seconds |
| `` or `h` | Seek backward 5 seconds |
| `` or `k` | Volume up 5% |
| `` or `j` | Volume down 5% |
| `m` | Toggle mute |
| `q` or `Esc` | Stop and quit |

The control hint is shown inline on the progress bar and updates live to reflect the current state:

```nushell
▶  0:42 / 4:05  [██████████░░░░░░░░░░░░░░░░░░░░]  17%  🔊 [████████░░░░░░] 100%  « [SPACE/pause] »  [↑↓/kj] vol  [m] mute  [q] quit
```

Use `--no-progress` to disable terminal output and controls. This is recommended when you run tasks in the background or pipe output.

---

## Installation


### Linux requirements (ALSA)


Before installing on Linux, make sure the ALSA development package is present:

| Distro | Command |
| --- | --- |
| Debian / Ubuntu | `sudo apt install libasound2-dev pkg-config` |
| Fedora / RHEL | `sudo dnf install alsa-lib-devel pkgconf-pkg-config` |
| Arch | `sudo pacman -S alsa-lib pkgconf` |
| openSUSE | `sudo zypper install alsa-lib-devel pkg-config` |

### Using [nupm]https://github.com/nushell/nupm (Recommended)


```nushell
git clone https://github.com/SuaveIV/nu_plugin_audio.git
nupm install --path nu_plugin_audio -f
```

### Shell Installer (Linux / macOS)


No Rust toolchain required. Run this in your terminal, then register the plugin in Nushell:

```bash
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/SuaveIV/nu_plugin_audio/releases/latest/download/nu_plugin_audio-installer.sh | sh
```

```nushell
plugin add ~/.cargo/bin/nu_plugin_audio
```

> **Note:** The shell installer covers x86_64 Linux, x86_64 macOS, and ARM64 macOS (Apple Silicon).
> ARM64 Linux (`aarch64-unknown-linux-gnu`) is not included in the installer — use the
> [Manual Download]#manual-download or [`cargo install`]#cargo-install method instead.

### PowerShell Installer (Windows)


No Rust toolchain required. Run this in PowerShell, then register the plugin in Nushell:

```powershell
irm https://github.com/SuaveIV/nu_plugin_audio/releases/latest/download/nu_plugin_audio-installer.ps1 | iex
```

```nushell
plugin add ($env.USERPROFILE | path join ".cargo" "bin" "nu_plugin_audio.exe")
```

### cargo-binstall


Installs a prebuilt binary from the GitHub release, falling back to a source build automatically:

```nushell
cargo binstall nu_plugin_audio
plugin add ~/.cargo/bin/nu_plugin_audio
```

### cargo install


Builds from source using the published crate on [crates.io](https://crates.io/crates/nu_plugin_audio):

```nushell
cargo install nu_plugin_audio --locked
plugin add ~/.cargo/bin/nu_plugin_audio
```

### Manual Download


Download the prebuilt binary for your platform from the [Releases page](https://github.com/SuaveIV/nu_plugin_audio/releases), extract it, and register it:

```nushell
plugin add path/to/nu_plugin_audio
```

Prebuilt binaries are available for the following targets:

| Target | Notes |
| --- | --- |
| `x86_64-unknown-linux-gnu` | x86_64 Linux |
| `aarch64-unknown-linux-gnu` | ARM64 Linux — built with `--features=all-decoders` |
| `x86_64-apple-darwin` | x86_64 macOS |
| `aarch64-apple-darwin` | ARM64 macOS (Apple Silicon) |
| `x86_64-pc-windows-msvc` | x86_64 Windows |

Each archive has a matching `.sha256` checksum file on the release page.

### Compile from Source


Only needed if you want custom feature flags:

```nushell
git clone https://github.com/SuaveIV/nu_plugin_audio.git
cd nu_plugin_audio
cargo build -r --locked --features=all-decoders
plugin add target/release/nu_plugin_audio
```

---

## Supported formats


### Default install


Enabled out of the box with no extra flags (includes all Symphonia codecs):

| Format | Feature flag | Notes |
| --- | --- | --- |
| MP3 | `symphonia-all` | Via Symphonia; better accuracy than minimp3 |
| FLAC | `symphonia-all` | Lossless compression |
| OGG Vorbis | `symphonia-all` | Open lossy format |
| WAV | `symphonia-all` | Uncompressed PCM |
| AAC | `symphonia-all` | Used by Apple, YouTube, most streaming services |
| MP4 / M4A | `symphonia-all` | Container for AAC and ALAC |
| ALAC | `symphonia-all` | Apple Lossless |
| ADPCM | `symphonia-all` | Adaptive PCM; common in games |
| CAF | `symphonia-all` | Core Audio Format; Apple professional audio |
| MKV / WebM (Opus) | `symphonia-all` | Open container with Opus codec |

### With `--features=all-decoders`


Everything above plus expanded capabilities:

| Format | Feature flag | Notes |
| --- | --- | --- |
| MP3 (minimp3) | `minimp3` | Lightweight alternative MP3 decoder |
| 64-bit precision | `64bit` | f64 sample precision |

> **Note:** The `default` feature includes `rodio/symphonia-all`, providing support for almost every common audio format out of the box.

### Compile with specific formats only


Users who want a smaller binary can build with the `lite` feature, which only includes a minimal set of decoders:

```bash
cargo build -r --locked --no-default-features --features=lite
```

> **Note:** `cargo install` always uses the `default` feature set. Custom features require a source build.

---

## Contributors


See [CONTRIBUTORS.md](CONTRIBUTORS.md) for the full list of contributors.