boombox


Nameboombox JSON
Version 0.56 PyPI version JSON
download
home_pagehttps://github.com/mixmastamyk/boombox
SummaryA short, cross-platform, pure-python audio file player and tone-generating module.
upload_time2020-03-17 00:03:49
maintainer
docs_urlNone
authorMike Miller
requires_python
licenseLGPLv3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
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)


::

    ▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂
    ╲▂▂▂▂╱╲▂▂▂▂╱╲▂▂▂
    ▔╲▂▂▂╱▔╲▂▂▂╱▔╲▂▂
    ▔▔╲▂▂╱▔▔╲▂▂╱▔▔╲▂
    ▔▔▔╲▂╱▔▔▔╲▂╱▔▔▔╲
    ▔▔▔▔╲╱▔▔▔▔╲╱▔▔▔▔
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mixmastamyk/boombox",
    "name": "boombox",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Mike Miller",
    "author_email": "mixmastamyk@github.com",
    "download_url": "https://files.pythonhosted.org/packages/45/c3/7ecdc5bce7fee41413f6a6f2dc811a9353ee25666c16d4bf1d24b4c49188/boombox-0.56.tar.gz",
    "platform": "",
    "description": "\nBoom\u200aBox\n=============\n\n::\n\n                 \u250f\u2513 \u250f\u2501\u2513\u250f\u2501\u2513\u250f\u2533\u2513\u250f\u2513 \u250f\u2501\u2513\u257b \u257b\n        \u257a\u2501\u2578\u257a\u2501\u2578   \u2523\u253b\u2513\u2503 \u2503\u2503 \u2503\u2503\u2503\u2503\u2523\u253b\u2513\u2503 \u2503\u250f\u254b\u251b   \u257a\u2501\u2578\u257a\u2501\u2578\n           \u257a\u2501\u2578   \u2517\u2501\u251b\u2517\u2501\u251b\u2517\u2501\u251b\u2579 \u2579\u2517\u2501\u251b\u2517\u2501\u251b\u2579 \u2579   \u257a\u2501\u2578\n\n                   \u256d\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256e\n    \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n    \u2502(0) ___    \u2502 \u2bc0  [:::::::] [] ( )\u2502    ___ (0)\u2502\n    \u2502  /:::::\\  \u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502  /:::::\\  \u2502\n    \u2502 |:::::::| \u2502  \u2502   \u2500\u2500    \u2500\u2500   \u2502  \u2502 |:::::::| \u2502\n    \u2502 |:::::::| \u2502  \u2502 \u2500(\u2699)\u2500\u2500\u2500\u2500(\u2699)\u2500 \u2502  \u2502 |:::::::| \u2502\n    \u2502  \\:::::/  \u2502  \u2502\u2500\u2500\u2500\u2500\u25af\u25af\u25af\u25af\u25af\u25af\u2500\u2500\u2500\u2500\u2502\u266b \u2502  \\:::::/  \u2502\n    \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\n.. image:: https://raw.githubusercontent.com/mixmastamyk/boombox/master/media/electric-boogaloo-sm.jpg\n    :align: center\n    :alt: Image: There's no stoppin' us!\n    :target: https://www.youtube.com/watch?v=bFaPBFd6QRk\n    :width: 90%\n\n|\n\nThis is a small cross-platform audio-file player module,\nuseful for plain-to-fancy system sound events, rings, beeps, and the like.\nI couldn't find a good one for this.\n\"playsound\" was very close at first glance but had a number of issues and\nhas not been updated in a while.\n\nBoomBox can wait for the file to finish or play in the background.\nIt tries hard to support Windows, Mac, and Linux, and mostly succeeds.\nThough you could play an eight-minute Grateful Dead jam with it,\nyou probably wouldn't want to.\n\n\n.. ~ It's a one file pure-python module that can easily be copied into a project\n.. ~ if need be.   NOT\u00a0ANYMORE\n.. ~ \u250f\u2513 \u250f\u2501\u2513\u250f\u2501\u2513\u250f\u2533\u2513\u250f\u2513 \u250f\u2501\u2513\u257b \u257b\n.. ~ \u2523\u253b\u2513\u2503 \u2503\u2503 \u2503\u2503\u2503\u2503\u2523\u253b\u2513\u2503 \u2503\u250f\u254b\u251b\n.. ~ \u2517\u2501\u251b\u2517\u2501\u251b\u2517\u2501\u251b\u2579 \u2579\u2517\u2501\u251b\u2517\u2501\u251b\u2579 \u2579\n\n\nUsage\n-------------------\n\nQuick start\u2014a cross-platform player looks like this:\n\n.. code-block:: python\n\n    from boombox import BoomBox  # power on\n\n    boombox = BoomBox(\"There's_no_stoppin_us.ogg\")  # load cassette\n\n    boombox.play() \u00a0# hit the \u23ef button\n\n\nThe play function also returns the instance,\nso if in a hurry one could do:\n\n.. code-block:: python\n\n    boombox = BoomBox(slow_jam).play()  # or\n    BoomBox(slow_jam).play()\n\n\nThe latter less efficient for multiple calls, of course.\nThere are a number of other keyword parameters that can be passed.\nSuch as:\n\n- ``wait``\n- ``timeout_ms``\n- ``duration_ms``\n- ``binary_path`` (ChildBoomBox only, to a CLI player)\n\nNot all arguments are supported on every implementation,\nbut they will not balk if given.\n\n\nImplementations\n-------------------\n\nThere are a number of underlying implementations if you'd like to pick a\nspecific one and bypass the platform default:\n\n- Windows\n\n  - WinBoomBox (default, wav only)\n  - PyAudioBoomBox - `PyAudio <https://people.csail.mit.edu/hubert/pyaudio/docs/>`_ (wav only)\n  - ChildBoomBox - Command-line player (powershell, others)\n\n.. ~ spacer\n\n- Mac OSX:\n\n  - MacOSBoomBox - `PyObjc <https://pypi.org/project/pyobjc/>`_ (default, multiformat)\n  - PyAudioBoomBox - `PyAudio <https://people.csail.mit.edu/hubert/pyaudio/docs/>`_ (wav only)\n  - ChildBoomBox - Command-line player (afplay, others)\n\n.. ~ spacer\n\n- POSIX:\n\n  - GstBoomBox - `Gstreamer <https://gstreamer.freedesktop.org/documentation/installing/on-linux.html>`_\n    (default, multiformat)\n  - PyAudioBoomBox - `PyAudio <https://people.csail.mit.edu/hubert/pyaudio/docs/>`_ (wav only)\n  - ChildBoomBox - Command-line player (paplay, aplay, others)\n\n\nSimply add an import to your script to choose a different one:\n\n.. code-block:: python\n\n    from boombox import PyAudioBoomBox as BoomBox\n\n\nYou may have to install one of the audio libraries above for all of the\nfunctionality of Boom\u200aBox to work.\n\n::\n\n    \u23f5 pip install --user boombox[all]  # or pyaudio, pyobjc, pygobject, etc\n\n\nPlayback Control\n-------------------\n\n::\n\n    \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n    \u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e \u2502\n    \u2502 \u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e \u2502 \u2502\n    \u2502 \u2502 \u2502 /\\ :  Electric Boogaloo     90 min\u2502 \u2502 \u2502\n    \u2502 \u2502 \u2502/\u2500\u2500\\: .....................  NR [\u2713]\u2502 \u2502 \u2502\n    \u2502 \u2502 \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502 \u2502\n    \u2502 \u2502      //\u2500\\\\   \u256d....:....\u256e   //\u2500\\\\      \u2502 \u2502\n    \u2502 \u2502     \u2502\u2502( )\u2502\u2502  \u2502)       (\u2502  \u2502\u2502( )\u2502\u2502     \u2502 \u2502\n    \u2502 \u2502      \\\\\u2500//   \u2570....:....\u256f   \\\\\u2500//      \u2502 \u2502\n    \u2502 \u2502       _ _ ._  _ _ .__|_ _.._  _       \u2502 \u2502\n    \u2502 \u2502      (_(_)\u2502 |(_(/_\u2502  \u2502_(_||_)(/_      \u2502 \u2502\n    \u2502 \u2502               low noise   |           \u2502 \u2502\n    \u2502 \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502\n    \u2502        /    []             []    \\        \u2502\n    \u2502       /  ()                   ()  \\       \u2502\n    \u2570\u2500\u2500\u2500\u2500\u2500\u2500/\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\\\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\n\nA simple playback interface is returned by the instance:\n\n.. code-block:: python\n\n    boombox.stop()  # Enough!\n    boombox.play()  #\u00a0One more time!\n\n\nTone Generation\n-------------------\n\nTones may be generated like so:\n\n.. code-block:: python\n\n        boombox.play_tone(frequency_hz, duration_ms, volume=.1)\n\n\n::\n\n    \u2582\u2582\u2582\u2582\u2582\u2582\u2582\u2582\u2582\u2582\u2582\u2582\u2582\u2582\u2582\u2582\n    \u2572\u2582\u2582\u2582\u2582\u2571\u2572\u2582\u2582\u2582\u2582\u2571\u2572\u2582\u2582\u2582\n    \u2594\u2572\u2582\u2582\u2582\u2571\u2594\u2572\u2582\u2582\u2582\u2571\u2594\u2572\u2582\u2582\n    \u2594\u2594\u2572\u2582\u2582\u2571\u2594\u2594\u2572\u2582\u2582\u2571\u2594\u2594\u2572\u2582\n    \u2594\u2594\u2594\u2572\u2582\u2571\u2594\u2594\u2594\u2572\u2582\u2571\u2594\u2594\u2594\u2572\n    \u2594\u2594\u2594\u2594\u2572\u2571\u2594\u2594\u2594\u2594\u2572\u2571\u2594\u2594\u2594\u2594\n    \u2594\u2594\u2594\u2594\u2594\u2594\u2594\u2594\u2594\u2594\u2594\u2594\u2594\u2594\u2594\u2594\n\n    \u250f\u2513\u257b\u250f\u2501\u2513   \u250f\u2501\u2513\u250f\u2513\u257b\u250f\u2501\u2578   \u257a\u2533\u2513\u250f\u2501\u2513\u250f\u2501\u2578\u250f\u2501\u2513   \u257b\u257a\u2533\u2578   \u250f\u2513 \u250f\u2501\u2578\u257a\u2533\u2578\u257a\u2533\u2578\u250f\u2501\u2578\u250f\u2501\u2513   \u257b\n    \u2503\u2517\u252b\u2503 \u2503   \u2503 \u2503\u2503\u2517\u252b\u2523\u2578     \u2503\u2503\u2503 \u2503\u2523\u2578 \u2517\u2501\u2513   \u2503 \u2503    \u2523\u253b\u2513\u2523\u2578  \u2503  \u2503 \u2523\u2578 \u2523\u2533\u251b   \u2579\n    \u2579 \u2579\u2517\u2501\u251b   \u2517\u2501\u251b\u2579 \u2579\u2517\u2501\u2578   \u257a\u253b\u251b\u2517\u2501\u251b\u2517\u2501\u2578\u2517\u2501\u251b   \u2579 \u2579    \u2517\u2501\u251b\u2517\u2501\u2578 \u2579  \u2579 \u2517\u2501\u2578\u2579\u2517\u2578   \u2579\n",
    "bugtrack_url": null,
    "license": "LGPLv3",
    "summary": "A short, cross-platform, pure-python audio file  player and tone-generating module.",
    "version": "0.56",
    "project_urls": {
        "Download": "https://github.com/mixmastamyk/boombox/get/default.tar.gz",
        "Homepage": "https://github.com/mixmastamyk/boombox"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c9045fd43f9a71b145d00c7c78b8a7f6d2060590952c889fd2530cd7108edb6",
                "md5": "b64ed1061131a562ef991fed26a977b7",
                "sha256": "f14488865296f527138613cacffb687ff3fa1a5d501c510fe8b1da4d671a568c"
            },
            "downloads": -1,
            "filename": "boombox-0.56-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b64ed1061131a562ef991fed26a977b7",
            "packagetype": "bdist_wheel",
            "python_version": "3.7",
            "requires_python": null,
            "size": 11972,
            "upload_time": "2020-03-17T00:03:51",
            "upload_time_iso_8601": "2020-03-17T00:03:51.378353Z",
            "url": "https://files.pythonhosted.org/packages/4c/90/45fd43f9a71b145d00c7c78b8a7f6d2060590952c889fd2530cd7108edb6/boombox-0.56-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45c37ecdc5bce7fee41413f6a6f2dc811a9353ee25666c16d4bf1d24b4c49188",
                "md5": "f782c1ca515edd57ead639c0fe703813",
                "sha256": "3aa021162a96a8317ff5b94632edaefe4e13731666095be07b133aa0f42da3cf"
            },
            "downloads": -1,
            "filename": "boombox-0.56.tar.gz",
            "has_sig": false,
            "md5_digest": "f782c1ca515edd57ead639c0fe703813",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9356,
            "upload_time": "2020-03-17T00:03:49",
            "upload_time_iso_8601": "2020-03-17T00:03:49.591937Z",
            "url": "https://files.pythonhosted.org/packages/45/c3/7ecdc5bce7fee41413f6a6f2dc811a9353ee25666c16d4bf1d24b4c49188/boombox-0.56.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-03-17 00:03:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mixmastamyk",
    "github_project": "boombox",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "boombox"
}
        
Elapsed time: 0.23740s