Code Monkey home page Code Monkey logo

pyosc's Introduction

NOTE
    This documentation is very similar to the header in OSC.py. One day both should be merged and placed either
	in this file or in OSC.py to avoid diverging documentation.

DESCRIPTION
    This module contains an OpenSoundControl implementation (in Pure Python), based (somewhat) on the
    good old 'SimpleOSC' implementation by Daniel Holth & Clinton McChesney.

    This implementation is intended to still be 'Simple' to the user, but much more complete
    (with OSCServer & OSCClient classes) and much more powerful
    (the OSCMultiClient supports subscriptions & message-filtering,
    OSCMessage & OSCBundle are now proper container-types)

    ================
    OpenSoundControl
    ================

    OpenSoundControl is a network-protocol for sending (small) packets of addressed data over network sockets.
    The original OSC-implementation uses the UDP/IP protocol for sending and receiving packets.

	In early 2010 TCP was added as transport layer. The application of OSC as interprocess communication becomes more and more
	common and ask for increased reliability which can be accomodated by using TCP as transport. The OSC
	specifications 1.0 and 1.1 require that OSC data (messages and bundles) must be framed by their packet size
	as 32 bit integer in network byte order (which is big endian) when using streaming protocols. This new
	implementation provides server and client classes. Their use is illustrated in the testbench.

    OSC-packets come in two kinds:
    - OSC-messages consist of an 'address'-string (not to be confused with a (host:port) network-address!),
    followed by a string of 'typetags' associated with the message's arguments (ie. 'payload'),
    and finally the arguments themselves, encoded in an OSC-specific way.
    The OSCMessage class makes it easy to create & manipulate OSC-messages of this kind in a 'pythonesque' way
    (that is, OSCMessage-objects behave a lot like lists)

    - OSC-bundles are a special type of OSC-message containing only OSC-messages as 'payload'. Recursively.
    (meaning; an OSC-bundle could contain other OSC-bundles, containing OSC-bundles etc.)
    OSC-bundles start with the special keyword '#bundle' and do not have an OSC-address. (but the OSC-messages
    a bundle contains will have OSC-addresses!)
    Also, an OSC-bundle can have a timetag, essentially telling the receiving Server to 'hold' the bundle until
    the specified time.
    The OSCBundle class allows easy cration & manipulation of OSC-bundles.

    see also http://opensoundcontrol.org/spec-1_0

    ---------

    To send OSC-messages, you need an OSCClient, and to receive OSC-messages you need an OSCServer.

    The OSCClient uses an 'AF_INET / SOCK_DGRAM' type socket (see the 'socket' module) to send
    binary representations of OSC-messages to a remote host:port address.

    The OSCServer listens on an 'AF_INET / SOCK_DGRAM' type socket bound to a local port, and handles
    incoming requests. Either one-after-the-other (OSCServer) or in a multi-threaded / multi-process fashion
    (ThreadingOSCServer / ForkingOSCServer). If the Server has a callback-function (a.k.a. handler) registered
    to 'deal with' (i.e. handle) the received message's OSC-address, that function is called, passing it the (decoded) message

    The different OSCServers implemented here all support the (recursive) un-bundling of OSC-bundles,
    and OSC-bundle timetags.

    In fact, this implementation supports:

    - OSC-messages with 'i' (int32), 'f' (float32), 's' (string) and 'b' (blob / binary data) types
    - OSC-bundles, including timetag-support
    - OSC-address patterns including '*', '?', '{,}' and '[]' wildcards.

    (please *do* read the OSC-spec! http://opensoundcontrol.org/spec-1_0 it explains what these things mean.)

    In addition, the OSCMultiClient supports:
    - Sending a specific OSC-message to multiple remote servers
    - Remote server subscription / unsubscription (through OSC-messages, of course)
    - Message-address filtering.

	The streaming server and clients use SOCK_STREAM sockets. Since this protocol is connection oriented
	replies are usually sent to the peer and not to a random server/client as in UDP implementations. If
	one likes to send messages to other clients/servers, a separate connection has to be established.

    ---------

    Stock, V2_Lab, Rotterdam, 2008

    ----------
    Changelog:
    ----------
    v0.3.0  - 27 Dec. 2007
            Started out to extend the 'SimpleOSC' implementation (v0.2.3) by Daniel Holth & Clinton McChesney.
            Rewrote OSCMessage
            Added OSCBundle

    v0.3.1  - 3 Jan. 2008
            Added OSClient
            Added OSCRequestHandler, loosely based on the original CallbackManager
            Added OSCServer
            Removed original CallbackManager
            Adapted testing-script (the 'if __name__ == "__main__":' block at the end) to use new Server & Client

    v0.3.2  - 5 Jan. 2008
            Added 'container-type emulation' methods (getitem(), setitem(), __iter__() & friends) to OSCMessage
            Added ThreadingOSCServer & ForkingOSCServer
                    - 6 Jan. 2008
            Added OSCMultiClient
            Added command-line options to testing-script (try 'python OSC.py --help')

    v0.3.3  - 9 Jan. 2008
            Added OSC-timetag support to OSCBundle & OSCRequestHandler
            Added ThreadingOSCRequestHandler

    v0.3.4  - 13 Jan. 2008
            Added message-filtering to OSCMultiClient
            Added subscription-handler to OSCServer
            Added support fon numpy/scipy int & float types. (these get converted to 'standard' 32-bit OSC ints / floats!)
            Cleaned-up and added more Docstrings

    v0.3.5 - 14 aug. 2008
            Added OSCServer.reportErr(...) method

    v0.3.6 - 19 April 2010
            Added Streaming support (OSC over TCP)
            Updated documentation
            Moved pattern matching stuff into separate class (OSCAddressSpace) to
                facilitate implementation of different server and client architectures.
            Moved testing code into separate testbench (testbench.py)

    -----------------
    Original Comments
    -----------------

    > Open SoundControl for Python
    > Copyright (C) 2002 Daniel Holth, Clinton McChesney
    >
    > This library is free software; you can redistribute it and/or modify it under
    > the terms of the GNU Lesser General Public License as published by the Free
    > Software Foundation; either version 2.1 of the License, or (at your option) any
    > later version.
    >
    > This library is distributed in the hope that it will be useful, but WITHOUT ANY
    > WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    > PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    > details.

    > You should have received a copy of the GNU Lesser General Public License along
    > with this library; if not, write to the Free Software Foundation, Inc., 59
    > Temple Place, Suite 330, Boston, MA  02111-1307  USA

    > For questions regarding this module contact Daniel Holth <[email protected]>
    > or visit http://www.stetson.edu/~ProctoLogic/

    > Changelog:
    > 15 Nov. 2001:
    >       Removed dependency on Python 2.0 features.
    >       - dwh
    > 13 Feb. 2002:
    >       Added a generic callback handler.
    >       - dwh

INSTALLING
    To install, simply run

    $ sudo ./setup.py install

    and provide your password.
    That's it. After this, you can use the 'pyOSC' module in your python-scripts by doing

    import OSC

DOCUMENTATION
    To get help, run

    $ pydoc OSC

    or, from within a python-interpreter

    >>> import OSC
    >>> help(OSC)

TESTING
    This package contains an OSC-testing program (testbench.py).
    Please have a good look at the source for this program for an example on how to use this module.

    To get help on how to invoke the test-program, run

    $ python testbench.py --help

    Usage: testbench.py [options]

    testbench.py OpenSoundControl-for-Python Test Program

    Options:
      -h, --help                  show this help message and exit
      -l LISTEN, --listen=LISTEN  listen on given host[:port]. default = '0.0.0.0:2222'
      -s SENDTO, --sendto=SENDTO  send to given host[:port]. default = '127.0.0.1:2222'
      -t, --threading             Test ThreadingOSCServer
      -f, --forking	              Test ForkingOSCServer
      -u, --usage                 Show this help message and exit
      -c, --streaming             Test streaming OSC (OSC over TCP)

pyosc's People

Contributors

artfwo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyosc's Issues

Issues at first run

I'm getting this error when I try to import (just checked, also on installation..):
OSX 10.11, Python 3.4.3

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ ... /OSC.py", line 781
    binary = struct.pack('>LL', 0L, 1L)
                                 ^
SyntaxError: invalid syntax

Any idea?

handshake example

Can you provide an example of an handshake between server and client such that for every data being sent to server from client, the server has to request it to the client.

Error on install

After running pip install pyOSC or ./setup.py install on ubuntu 16.04 and mint 18.2 we get the following error preventing installation.

Collecting pyOSC
  Downloading https://files.pythonhosted.org/packages/7c/e4/6abb118cf110813a7922119ed0d53e5fe51c570296785ec2a39f37606d85/pyOSC-0.3.5b-5294.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g9knkxpt/pyOSC/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g9knkxpt/pyOSC/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-g9knkxpt/pyOSC/pip-egg-info
         cwd: /tmp/pip-install-g9knkxpt/pyOSC/
    Complete output (8 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-g9knkxpt/pyOSC/setup.py", line 5, in <module>
        import OSC
      File "/tmp/pip-install-g9knkxpt/pyOSC/OSC.py", line 735
        binary = struct.pack('>ll', 0L, 1L)
                                     ^
    SyntaxError: invalid syntax
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Problem running the example

Hi there,

Here is what I get when I try to run the sender example:

client.send( OSCMessage("/user/1", [1.0, 2.0, 3.0 ] ) )
TypeError: init() takes at most 2 arguments (3 given)

Thanks,

Python 3 Installation and use

Hi all,

I'm trying to install this on Python 3 but I keep getting a lot of errors like:

"AttributeError: module 'types' has no attribute..."

I tried changing this to reflect the changes in Python 3 but there is always a new error. Is there a way to install this for Python 3?

Thanks!

Example knect-snd.py broken

When I download pyosc via pip and try running the knect-snd.py example I get the following error:

Traceback (most recent call last):
File "BlankOSC.py", line 8, in
client.send( OSCMessage("/user/1", [1.0, 2.0, 3.0 ] ) )
TypeError: init() takes at most 2 arguments (3 given)

This is when I copy and paste the example, nothing else. OSC sending works find when I create an OSC message with no arguments then append address and data. Anything I'm missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.