python-osc


Namepython-osc JSON
Version 1.8.3 PyPI version JSON
download
home_page
SummaryOpen Sound Control server and client implementations in pure Python
upload_time2023-08-05 18:19:45
maintainer
docs_urlNone
author
requires_python>=3.7
licenseThis is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to <http://unlicense.org/>
keywords osc sound midi music
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==========
python-osc
==========

Open Sound Control server and client implementations in **pure python**.

.. image:: https://github.com/attwad/python-osc/actions/workflows/python-test.yml/badge.svg
    :target: https://github.com/attwad/python-osc/actions/workflows/python-test.yml


Current status
==============

This library was developed following the
`OpenSoundControl Specification 1.0 <https://opensoundcontrol.stanford.edu/spec-1_0.html>`_
and is currently in a stable state.

Features
========

* UDP blocking/threading/forking/asyncio server implementations
* UDP client
* int, int64, float, string, double, MIDI, timestamps, blob, nil OSC arguments
* simple OSC address<->callback matching system
* extensive unit test coverage
* basic client and server examples

Documentation
=============

Available at https://python-osc.readthedocs.io/.

Installation
============

python-osc is a pure python library that has no external dependencies,
to install it just use pip (prefered):

.. image:: https://img.shields.io/pypi/v/python-osc.svg
    :target: https://pypi.python.org/pypi/python-osc

.. code-block:: bash

    $ pip install python-osc

Examples
========

Simple client
-------------

.. code-block:: python

  """Small example OSC client

  This program sends 10 random values between 0.0 and 1.0 to the /filter address,
  waiting for 1 seconds between each value.
  """
  import argparse
  import random
  import time

  from pythonosc import udp_client


  if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", default="127.0.0.1",
        help="The ip of the OSC server")
    parser.add_argument("--port", type=int, default=5005,
        help="The port the OSC server is listening on")
    args = parser.parse_args()

    client = udp_client.SimpleUDPClient(args.ip, args.port)

    for x in range(10):
      client.send_message("/filter", random.random())
      time.sleep(1)

Simple server
-------------

.. code-block:: python

  """Small example OSC server

  This program listens to several addresses, and prints some information about
  received packets.
  """
  import argparse
  import math

  from pythonosc.dispatcher import Dispatcher
  from pythonosc import osc_server

  def print_volume_handler(unused_addr, args, volume):
    print("[{0}] ~ {1}".format(args[0], volume))

  def print_compute_handler(unused_addr, args, volume):
    try:
      print("[{0}] ~ {1}".format(args[0], args[1](volume)))
    except ValueError: pass

  if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
        default="127.0.0.1", help="The ip to listen on")
    parser.add_argument("--port",
        type=int, default=5005, help="The port to listen on")
    args = parser.parse_args()

    dispatcher = Dispatcher()
    dispatcher.map("/filter", print)
    dispatcher.map("/volume", print_volume_handler, "Volume")
    dispatcher.map("/logvolume", print_compute_handler, "Log volume", math.log)

    server = osc_server.ThreadingOSCUDPServer(
        (args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()

Building bundles
----------------

.. code-block:: python

    from pythonosc import osc_bundle_builder
    from pythonosc import osc_message_builder

    bundle = osc_bundle_builder.OscBundleBuilder(
        osc_bundle_builder.IMMEDIATELY)
    msg = osc_message_builder.OscMessageBuilder(address="/SYNC")
    msg.add_arg(4.0)
    # Add 4 messages in the bundle, each with more arguments.
    bundle.add_content(msg.build())
    msg.add_arg(2)
    bundle.add_content(msg.build())
    msg.add_arg("value")
    bundle.add_content(msg.build())
    msg.add_arg(b"\x01\x02\x03")
    bundle.add_content(msg.build())

    sub_bundle = bundle.build()
    # Now add the same bundle inside itself.
    bundle.add_content(sub_bundle)
    # The bundle has 5 elements in total now.

    bundle = bundle.build()
    # You can now send it via a client as described in other examples.

License?
========
Unlicensed, do what you want with it. (http://unlicense.org)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "python-osc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "osc,sound,midi,music",
    "author": "",
    "author_email": "attwad <tmusoft@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/2b/23/2dba900b73bae16117c9d69b44774865392dc30bbc80faa7b5b5fc524fc9/python-osc-1.8.3.tar.gz",
    "platform": null,
    "description": "==========\npython-osc\n==========\n\nOpen Sound Control server and client implementations in **pure python**.\n\n.. image:: https://github.com/attwad/python-osc/actions/workflows/python-test.yml/badge.svg\n    :target: https://github.com/attwad/python-osc/actions/workflows/python-test.yml\n\n\nCurrent status\n==============\n\nThis library was developed following the\n`OpenSoundControl Specification 1.0 <https://opensoundcontrol.stanford.edu/spec-1_0.html>`_\nand is currently in a stable state.\n\nFeatures\n========\n\n* UDP blocking/threading/forking/asyncio server implementations\n* UDP client\n* int, int64, float, string, double, MIDI, timestamps, blob, nil OSC arguments\n* simple OSC address<->callback matching system\n* extensive unit test coverage\n* basic client and server examples\n\nDocumentation\n=============\n\nAvailable at https://python-osc.readthedocs.io/.\n\nInstallation\n============\n\npython-osc is a pure python library that has no external dependencies,\nto install it just use pip (prefered):\n\n.. image:: https://img.shields.io/pypi/v/python-osc.svg\n    :target: https://pypi.python.org/pypi/python-osc\n\n.. code-block:: bash\n\n    $ pip install python-osc\n\nExamples\n========\n\nSimple client\n-------------\n\n.. code-block:: python\n\n  \"\"\"Small example OSC client\n\n  This program sends 10 random values between 0.0 and 1.0 to the /filter address,\n  waiting for 1 seconds between each value.\n  \"\"\"\n  import argparse\n  import random\n  import time\n\n  from pythonosc import udp_client\n\n\n  if __name__ == \"__main__\":\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--ip\", default=\"127.0.0.1\",\n        help=\"The ip of the OSC server\")\n    parser.add_argument(\"--port\", type=int, default=5005,\n        help=\"The port the OSC server is listening on\")\n    args = parser.parse_args()\n\n    client = udp_client.SimpleUDPClient(args.ip, args.port)\n\n    for x in range(10):\n      client.send_message(\"/filter\", random.random())\n      time.sleep(1)\n\nSimple server\n-------------\n\n.. code-block:: python\n\n  \"\"\"Small example OSC server\n\n  This program listens to several addresses, and prints some information about\n  received packets.\n  \"\"\"\n  import argparse\n  import math\n\n  from pythonosc.dispatcher import Dispatcher\n  from pythonosc import osc_server\n\n  def print_volume_handler(unused_addr, args, volume):\n    print(\"[{0}] ~ {1}\".format(args[0], volume))\n\n  def print_compute_handler(unused_addr, args, volume):\n    try:\n      print(\"[{0}] ~ {1}\".format(args[0], args[1](volume)))\n    except ValueError: pass\n\n  if __name__ == \"__main__\":\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--ip\",\n        default=\"127.0.0.1\", help=\"The ip to listen on\")\n    parser.add_argument(\"--port\",\n        type=int, default=5005, help=\"The port to listen on\")\n    args = parser.parse_args()\n\n    dispatcher = Dispatcher()\n    dispatcher.map(\"/filter\", print)\n    dispatcher.map(\"/volume\", print_volume_handler, \"Volume\")\n    dispatcher.map(\"/logvolume\", print_compute_handler, \"Log volume\", math.log)\n\n    server = osc_server.ThreadingOSCUDPServer(\n        (args.ip, args.port), dispatcher)\n    print(\"Serving on {}\".format(server.server_address))\n    server.serve_forever()\n\nBuilding bundles\n----------------\n\n.. code-block:: python\n\n    from pythonosc import osc_bundle_builder\n    from pythonosc import osc_message_builder\n\n    bundle = osc_bundle_builder.OscBundleBuilder(\n        osc_bundle_builder.IMMEDIATELY)\n    msg = osc_message_builder.OscMessageBuilder(address=\"/SYNC\")\n    msg.add_arg(4.0)\n    # Add 4 messages in the bundle, each with more arguments.\n    bundle.add_content(msg.build())\n    msg.add_arg(2)\n    bundle.add_content(msg.build())\n    msg.add_arg(\"value\")\n    bundle.add_content(msg.build())\n    msg.add_arg(b\"\\x01\\x02\\x03\")\n    bundle.add_content(msg.build())\n\n    sub_bundle = bundle.build()\n    # Now add the same bundle inside itself.\n    bundle.add_content(sub_bundle)\n    # The bundle has 5 elements in total now.\n\n    bundle = bundle.build()\n    # You can now send it via a client as described in other examples.\n\nLicense?\n========\nUnlicensed, do what you want with it. (http://unlicense.org)\n",
    "bugtrack_url": null,
    "license": "This is free and unencumbered software released into the public domain.  Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.  In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  For more information, please refer to <http://unlicense.org/> ",
    "summary": "Open Sound Control server and client implementations in pure Python",
    "version": "1.8.3",
    "project_urls": {
        "Repository": "https://github.com/attwad/python-osc"
    },
    "split_keywords": [
        "osc",
        "sound",
        "midi",
        "music"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e4d6bff3a75ab880aded4ced078e391265c17fc220fc11cc535de1975513b230",
                "md5": "ffc94a719e48c04c89d7ad46d4f5662f",
                "sha256": "6fa7e5cf7690057712c26e5f67a747126e6a5f481a40792aad0f25ac3edee815"
            },
            "downloads": -1,
            "filename": "python_osc-1.8.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ffc94a719e48c04c89d7ad46d4f5662f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 33208,
            "upload_time": "2023-08-05T18:19:44",
            "upload_time_iso_8601": "2023-08-05T18:19:44.020416Z",
            "url": "https://files.pythonhosted.org/packages/e4/d6/bff3a75ab880aded4ced078e391265c17fc220fc11cc535de1975513b230/python_osc-1.8.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2b232dba900b73bae16117c9d69b44774865392dc30bbc80faa7b5b5fc524fc9",
                "md5": "df6bdd3d4a32f908931b307f722a6e1d",
                "sha256": "a5ce1ba56c8d82df51cb3f2946b5dd33a70522791acc4b8564e62d2b20ad9caa"
            },
            "downloads": -1,
            "filename": "python-osc-1.8.3.tar.gz",
            "has_sig": false,
            "md5_digest": "df6bdd3d4a32f908931b307f722a6e1d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 25137,
            "upload_time": "2023-08-05T18:19:45",
            "upload_time_iso_8601": "2023-08-05T18:19:45.403463Z",
            "url": "https://files.pythonhosted.org/packages/2b/23/2dba900b73bae16117c9d69b44774865392dc30bbc80faa7b5b5fc524fc9/python-osc-1.8.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-05 18:19:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "attwad",
    "github_project": "python-osc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "python-osc"
}
        
Elapsed time: 0.09816s