Socket
Socket
Sign inDemoInstall

boombox

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boombox

A short, cross-platform, pure-python audio file player and tone-generating module.


Maintainers
1

Boomโ€ŠBox

::

             โ”โ”“ โ”โ”โ”“โ”โ”โ”“โ”โ”ณโ”“โ”โ”“ โ”โ”โ”“โ•ป โ•ป
    โ•บโ”โ•ธโ•บโ”โ•ธ   โ”ฃโ”ปโ”“โ”ƒ โ”ƒโ”ƒ โ”ƒโ”ƒโ”ƒโ”ƒโ”ฃโ”ปโ”“โ”ƒ โ”ƒโ”โ•‹โ”›   โ•บโ”โ•ธโ•บโ”โ•ธ
       โ•บโ”โ•ธ   โ”—โ”โ”›โ”—โ”โ”›โ”—โ”โ”›โ•น โ•นโ”—โ”โ”›โ”—โ”โ”›โ•น โ•น   โ•บโ”โ•ธ

               โ•ญโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฎ
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚(0) ___    โ”‚ โฏ€  [:::::::] [] ( )โ”‚    ___ (0)โ”‚
โ”‚  /:::::\  โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚  /:::::\  โ”‚
โ”‚ |:::::::| โ”‚  โ”‚   โ”€โ”€    โ”€โ”€   โ”‚  โ”‚ |:::::::| โ”‚
โ”‚ |:::::::| โ”‚  โ”‚ โ”€(โš™)โ”€โ”€โ”€โ”€(โš™)โ”€ โ”‚  โ”‚ |:::::::| โ”‚
โ”‚  \:::::/  โ”‚  โ”‚โ”€โ”€โ”€โ”€โ–ฏโ–ฏโ–ฏโ–ฏโ–ฏโ–ฏโ”€โ”€โ”€โ”€โ”‚โ™ซ โ”‚  \:::::/  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

.. image:: https://raw.githubusercontent.com/mixmastamyk/boombox/master/media/electric-boogaloo-sm.jpg :align: center :alt: Image: There's no stoppin' us! :target: https://www.youtube.com/watch?v=bFaPBFd6QRk :width: 90%

|

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.

.. ~ It's a one file pure-python module that can easily be copied into a project .. ~ if need be. NOTย ANYMORE .. ~ โ”โ”“ โ”โ”โ”“โ”โ”โ”“โ”โ”ณโ”“โ”โ”“ โ”โ”โ”“โ•ป โ•ป .. ~ โ”ฃโ”ปโ”“โ”ƒ โ”ƒโ”ƒ โ”ƒโ”ƒโ”ƒโ”ƒโ”ฃโ”ปโ”“โ”ƒ โ”ƒโ”โ•‹โ”› .. ~ โ”—โ”โ”›โ”—โ”โ”›โ”—โ”โ”›โ•น โ•นโ”—โ”โ”›โ”—โ”โ”›โ•น โ•น

Usage

Quick startโ€”a cross-platform player looks like this:

.. code-block:: python

from boombox import BoomBox  # power on

boombox = BoomBox("There's_no_stoppin_us.ogg")  # load cassette

boombox.play() ย # hit the โฏ button

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

.. code-block:: python

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 <https://people.csail.mit.edu/hubert/pyaudio/docs/>_ (wav only)
    • ChildBoomBox - Command-line player (powershell, others)

.. ~ spacer

  • Mac OSX:

    • MacOSBoomBox - PyObjc <https://pypi.org/project/pyobjc/>_ (default, multiformat)
    • PyAudioBoomBox - PyAudio <https://people.csail.mit.edu/hubert/pyaudio/docs/>_ (wav only)
    • ChildBoomBox - Command-line player (afplay, others)

.. ~ spacer

  • POSIX:

    • GstBoomBox - Gstreamer <https://gstreamer.freedesktop.org/documentation/installing/on-linux.html>_ (default, multiformat)
    • PyAudioBoomBox - PyAudio <https://people.csail.mit.edu/hubert/pyaudio/docs/>_ (wav only)
    • ChildBoomBox - Command-line player (paplay, aplay, others)

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

.. code-block:: python

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:

.. code-block:: python

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

Tone Generation

Tones may be generated like so:

.. code-block:: python

    boombox.play_tone(frequency_hz, duration_ms, volume=.1)

::

โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚โ–‚
โ•ฒโ–‚โ–‚โ–‚โ–‚โ•ฑโ•ฒโ–‚โ–‚โ–‚โ–‚โ•ฑโ•ฒโ–‚โ–‚โ–‚
โ–”โ•ฒโ–‚โ–‚โ–‚โ•ฑโ–”โ•ฒโ–‚โ–‚โ–‚โ•ฑโ–”โ•ฒโ–‚โ–‚
โ–”โ–”โ•ฒโ–‚โ–‚โ•ฑโ–”โ–”โ•ฒโ–‚โ–‚โ•ฑโ–”โ–”โ•ฒโ–‚
โ–”โ–”โ–”โ•ฒโ–‚โ•ฑโ–”โ–”โ–”โ•ฒโ–‚โ•ฑโ–”โ–”โ–”โ•ฒ
โ–”โ–”โ–”โ–”โ•ฒโ•ฑโ–”โ–”โ–”โ–”โ•ฒโ•ฑโ–”โ–”โ–”โ–”
โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”

โ”โ”“โ•ปโ”โ”โ”“   โ”โ”โ”“โ”โ”“โ•ปโ”โ”โ•ธ   โ•บโ”ณโ”“โ”โ”โ”“โ”โ”โ•ธโ”โ”โ”“   โ•ปโ•บโ”ณโ•ธ   โ”โ”“ โ”โ”โ•ธโ•บโ”ณโ•ธโ•บโ”ณโ•ธโ”โ”โ•ธโ”โ”โ”“   โ•ป
โ”ƒโ”—โ”ซโ”ƒ โ”ƒ   โ”ƒ โ”ƒโ”ƒโ”—โ”ซโ”ฃโ•ธ     โ”ƒโ”ƒโ”ƒ โ”ƒโ”ฃโ•ธ โ”—โ”โ”“   โ”ƒ โ”ƒ    โ”ฃโ”ปโ”“โ”ฃโ•ธ  โ”ƒ  โ”ƒ โ”ฃโ•ธ โ”ฃโ”ณโ”›   โ•น
โ•น โ•นโ”—โ”โ”›   โ”—โ”โ”›โ•น โ•นโ”—โ”โ•ธ   โ•บโ”ปโ”›โ”—โ”โ”›โ”—โ”โ•ธโ”—โ”โ”›   โ•น โ•น    โ”—โ”โ”›โ”—โ”โ•ธ โ•น  โ•น โ”—โ”โ•ธโ•นโ”—โ•ธ   โ•น

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc