#audio-player #nu-shell #audio-plugin #mp3

bin+lib nu_plugin_audio_hook

A nushell plugin to make and play sounds

12 unstable releases (3 breaking)

0.103.0 Mar 20, 2025
0.2.8 Dec 23, 2024
0.2.7 Nov 17, 2024
0.1.12 Feb 12, 2024
0.1.3 Nov 8, 2023

#223 in Audio

Download history 116/week @ 2024-12-18 32/week @ 2024-12-25 8/week @ 2025-01-08 91/week @ 2025-02-05 33/week @ 2025-02-12 10/week @ 2025-02-19 2/week @ 2025-02-26 137/week @ 2025-03-19 4/week @ 2025-03-26 3/week @ 2025-04-02

144 downloads per month

MIT and maybe CC-PDDC

29KB
606 lines

๐ŸŽต nu_plugin_audio_hook

A Nushell plugin for generating and playing sounds. Supports beeping, tone generation, metadata manipulation, and playback for multiple audio formats.


โœจ 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 ID3 metadata frames in an audio file. More about ID3.
  • sound play โ†’ Play an audio file. By default, supports FLAC, WAV, MP3, and OGG. Use the all-decoders feature to enable AAC and MP4 playback.

๐Ÿ“Œ Usage

Generate a simple noise

sound make 1000 200ms

Generate a noise sequence

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

Play an audio file (first 3 seconds only)

sound play audio.mp3 -d 3sec

Retrieve metadata from an audio file

sound meta audio.mp4

Example Output:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ duration     โ”‚ 4min 5sec 551ms 20ยตs 408ns โ”‚
โ”‚ artist       โ”‚ SINGER                     โ”‚
โ”‚ title        โ”‚ TITLE                      โ”‚
โ”‚ album        โ”‚ ALBUM                      โ”‚
โ”‚ album_artist โ”‚ SINGER                     โ”‚
โ”‚ track_no     โ”‚ 1                          โ”‚
โ”‚ total_tracks โ”‚ 1                          โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Modify ID3 metadata (change the artist tag)

sound meta set audio.mp3 -k TPE1 -v new-artist

Play an MP3 file using its metadata duration

sound meta audio.mp4 | sound play audio.mp3 -d $in.duration

List all available ID3 frame names

sound meta list

๐Ÿ”ง Installation

git clone https://github.com/FMotalleb/nu_plugin_audio_hook.git  
nupm install --path nu_plugin_audio_hook -f  

๐Ÿ› ๏ธ Manual Compilation

git clone https://github.com/FMotalleb/nu_plugin_audio_hook.git  
cd nu_plugin_audio_hook  
cargo build -r --features=all-decoders  
plugin add target/release/nu_plugin_audio_hook  

๐Ÿ“ฆ Install via Cargo (using git)

cargo install --git https://github.com/FMotalleb/nu_plugin_audio_hook.git --features=all-decoders  
plugin add ~/.cargo/bin/nu_plugin_audio_hook  

Since I live in Iran and crates.io often restricts package updates, the version there might be outdated.

cargo install nu_plugin_audio_hook --features=all-decoders  
plugin add ~/.cargo/bin/nu_plugin_audio_hook  

๐Ÿ” Supported Features

You can enable specific features when compiling or installing:

  • full โ†’ Enables all features below.
  • flac (default) โ†’ FLAC format support.
  • vorbis (default) โ†’ OGG Vorbis support.
  • wav (default) โ†’ WAV format support.
  • minimp3 โ†’ MP3 decoding.
  • symphonia-all โ†’ Enables all Symphonia-based decoders:
    • symphonia-aac โ†’ AAC decoding.
    • symphonia-flac โ†’ FLAC decoding.
    • symphonia-isomp4 โ†’ MP4 (audio) decoding.
    • symphonia-mp3 (default) โ†’ MP3 decoding.
    • symphonia-vorbis โ†’ OGG Vorbis decoding.
    • symphonia-wav โ†’ WAV decoding.

Dependencies

~25โ€“61MB
~1M SLoC