Skip to main content

Boom Box

             ┏┓ ┏━┓┏━┓┏┳┓┏┓ ┏━┓╻ ╻
    ╺━╸╺━╸   ┣┻┓┃ ┃┃ ┃┃┃┃┣┻┓┃ ┃┏╋┛   ╺━╸╺━╸
       ╺━╸   ┗━┛┗━┛┗━┛╹ ╹┗━┛┗━┛╹ ╹   ╺━╸

               ╭══════════════╮
╭───────────┬──┴──────────────┴──┬───────────╮
│(0) ___    │ ⯀  [:::::::] [] ( )│    ___ (0)│
│  /:::::\  │────────────────────│  /:::::\  │
│ |:::::::| │  │   ──    ──   │  │ |:::::::| │
│ |:::::::| │  │ ─(⚙)────(⚙)─ │  │ |:::::::| │
│  \:::::/  │  │────▯▯▯▯▯▯────│♫ │  \:::::/  │
╰────────────────────────────────┴───────────╯
Image: There's no stoppin' us!

This is a small cross-platform audio-file player module, useful for plain-to-fancy system sound events, rings, beeps, and the like. I couldn’t find a good one for this. “playsound” was very close at first glance but had a number of issues and has not been updated in a while.

BoomBox can wait for the file to finish or play in the background. It tries hard to support Windows, Mac, and Linux, and mostly succeeds. Though you could play an eight-minute Grateful Dead jam with it, you probably wouldn’t want to.

Usage

Quick start—a cross-platform player looks like this:

from boombox import BoomBox  # 📾 power on

boombox = BoomBox("There's_no_stoppin_us.opus")  # load 🖭

boombox.play()  # hit the [▶] button

The play function also returns the instance, so if in a hurry one could do:

boombox = BoomBox(slow_jam).play()  # or
BoomBox(slow_jam).play()

The latter less efficient for multiple calls, of course. There are a number of other keyword parameters that can be passed. Such as:

  • wait

  • timeout_ms

  • duration_ms

  • binary_path (ChildBoomBox only, to a CLI player)

Not all arguments are supported on every implementation, but they will not balk if given.

Implementations

There are a number of underlying implementations if you’d like to pick a specific one and bypass the platform default:

  • Windows

    • WinBoomBox (default, wav only)

    • PyAudioBoomBox - PyAudio (wav only)

    • ChildBoomBox - Command-line player (powershell, others)

  • Mac OSX:

    • MacOSBoomBox - PyObjc (default, multiformat)

    • PyAudioBoomBox - PyAudio (wav only)

    • ChildBoomBox - Command-line player (afplay, others)

  • POSIX:

    • GstBoomBox - Gstreamer (default, multiformat)

    • PyAudioBoomBox - PyAudio (wav only)

    • ChildBoomBox - Command-line player (paplay, aplay, others)

Simply add an import to your script to choose a different one:

from boombox import PyAudioBoomBox as BoomBox

You may have to install one of the audio libraries above for all of the functionality of Boom Box to work.

⏵ pip install --user boombox[all]  # or pyaudio, pyobjc, pygobject, etc

Playback Control

╭───────────────────────────────────────────╮
│ ╭───────────────────────────────────────╮ │
│ │ ╭───────────────────────────────────╮ │ │
│ │ │ /\ :  Electric Boogaloo     90 min│ │ │
│ │ │/──\: .....................  NR [✓]│ │ │
│ │ ╰───────────────────────────────────╯ │ │
│ │      //─\\   ╭....:....╮   //─\\      │ │
│ │     ││( )││  │)       (│  ││( )││     │ │
│ │      \\─//   ╰....:....╯   \\─//      │ │
│ │       _ _ ._  _ _ .__|_ _.._  _       │ │
│ │      (_(_)│ |(_(/_│  │_(_||_)(/_      │ │
│ │               low noise   |           │ │
│ ╰─────── ─────────────────────── ───────╯ │
│        /    []             []    \        │
│       /  ()                   ()  \       │
╰──────/─────────────────────────────\──────╯

A simple playback interface is returned by the instance:

boombox.stop()  # Enough!
boombox.play()  # One more time!

Tone Generation

Tones may be generated like so:

boombox.play_tone(frequency_hz, duration_ms, volume=.1)
▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂
╲▂▂▂▂╱╲▂▂▂▂╱╲▂▂▂
▔╲▂▂▂╱▔╲▂▂▂╱▔╲▂▂
▔▔╲▂▂╱▔▔╲▂▂╱▔▔╲▂
▔▔▔╲▂╱▔▔▔╲▂╱▔▔▔╲
▔▔▔▔╲╱▔▔▔▔╲╱▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

┏┓╻┏━┓   ┏━┓┏┓╻┏━╸   ╺┳┓┏━┓┏━╸┏━┓   ╻╺┳╸   ┏┓ ┏━╸╺┳╸╺┳╸┏━╸┏━┓   ╻
┃┗┫┃ ┃   ┃ ┃┃┗┫┣╸     ┃┃┃ ┃┣╸ ┗━┓   ┃ ┃    ┣┻┓┣╸  ┃  ┃ ┣╸ ┣┳┛   ╹
╹ ╹┗━┛   ┗━┛╹ ╹┗━╸   ╺┻┛┗━┛┗━╸┗━┛   ╹ ╹    ┗━┛┗━╸ ╹  ╹ ┗━╸╹┗╸   ╹

Metadata

Release files for boombox 0.61

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for boombox 0.61
File Size Uploaded
boombox-0.61.tar.gz 14.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for boombox 0.61
File Interpreter ABI Platform
boombox-0.61-py3-none-any.whl Python 3 none any Details

Total release size: 26.3 kB

Release files / boombox-0.61.tar.gz

Download URL boombox-0.61.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3125ebdd185eb0c1d696425409e2ea4b5a1ffbc7371f5c1bc61d5a8f29a40341
BLAKE2b-256 checksum
How to use checksums
0ed9225221a254fe4f5bf5edcbcfd603f17c0fad49e105edc1edafddbcdabcbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / boombox-0.61-py3-none-any.whl

Download URL boombox-0.61-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95187c16ba3d5d272e2722a64286386e738103aed29f791fd26d60533db77916
BLAKE2b-256 checksum
How to use checksums
7df4b582da22e7856541c023935b2187819c042bf8273fe16417de043686b927
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.61 This release

2 release files

0.56

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page