Skip to main content

A Python Lib to create a DMX compatible OSC server with handlers

Project description

DMX OSC Server

DMX OSC Server is a python lib to make it easier to create OSC Servers for the DMX Protocol.

It allows you to register fixtures are the wanted universe, starting address and channels. You will also be able to add an handler which will be called when a message is received for that fixture.

Installation

pip install DmxOscServer

Get Started

To create a simple DMX OSC Server that will listen on 0.0.0.0:9000 you can use this code:

from DmxOscServer import DmxOscServer

server = DmxOscServer()

# Define a 3 channel Fixture at address 0 at universe 0 which will execute my_rgb_handler when called
@server.define_fixture(0, 0, 3)
def my_rgb_handler(fixture, address, *args):
    print ("{} got {}".format(address, args))

server.run()

To make the define more readable, you can use the argument names

# Define a 3 channel Fixture at address 0 at universe 0 which will execute my_rgb_handler when called
@server.define_fixture(universe=0, starting_addr=0, channels=3)
def my_rgb_handler(fixture, address, *args):
    print ("{} has been set to {}".format(address, args))

To change the IP and/or port, you can specify that at the .run() method

server.run("10.10.123.5", 1234) # Will listen on 10.10.123.5:1234

It is also possible to use the Fixture class and the add_fixture method

from DmxOscServer import DmxOscServer, Fixture

def my_rgb_handler(fixture, address, *args):
    print ("{} has been set to {}".format(address, args))

server = DmxOscServer()
server.add_fixture(Fixture(0, 0, 3, my_rgb_handler)) # Register a 3 channel Fixture at address 0 at universe 0

And for the add_fixture method, you can also add multiple fixtures at once using:

from DmxOscServer import DmxOscServer, Fixture
server = DmxOscServer()
server.add_fixtures(
    Fixture(0, 0, 3, my_rgb_handler), # Register a 3 channel Fixture at address 0 of universe 0
    Fixture(0, 3, 3, my_rgb_handler), # Register a 3 channel Fixture at address 3 of universe 0
)

You can use the fixture.values property to see all the current values

@server.define_fixture(0, 0, 3)
def my_rgb_handler(fixture, address, *args):
    print (fixture.values)

The handler

The handler receives a call when a message is received for that fixture Arguments: (fixture, address, *args)

  • fixture is the fixture, so you have a reference
  • address is the message address (it starts at the starting_address, so use address - fixture.starting_addr if you want to have the internal address)
  • *args are the args of the message. It is almost always 1 int going from 0 to 1, so you can just use args[0] in your code and multiply it by your max value

The handler should never receive an address out of its address range, if the fixture is called correctly

More Documentation

More Documentation can be found at https://dmxoscserver.readthedocs.io/en/latest/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

DmxOscServer-1.0.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

DmxOscServer-1.0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file DmxOscServer-1.0.3.tar.gz.

File metadata

  • Download URL: DmxOscServer-1.0.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.3

File hashes

Hashes for DmxOscServer-1.0.3.tar.gz
Algorithm Hash digest
SHA256 7df5f28e580f68f488d95844f49904dd11a547cb70d6e06d5c71420e12ac1e43
MD5 28be121a3291fd595c6a15261cb62976
BLAKE2b-256 a674b4a0c64f9609d0a6202559750e36c6757073348fa229fe7104702d5383af

See more details on using hashes here.

File details

Details for the file DmxOscServer-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for DmxOscServer-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d09db14f9df7917d74beb2c925bd9178f0ac8b6b71c81a2336137ac6804f00a1
MD5 f640f429fd8617d6e7cee2969ca19a19
BLAKE2b-256 0f7f579c6525a1319cd663599ee87b1ec205d86103b4d38f9fd37856f2fab14c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page