Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miniontoby/dmxoscserver
A python lib to make it easier to create OSC Servers for the DMX Protocol
https://github.com/miniontoby/dmxoscserver
dmx osc python qlcplus server
Last synced: 7 days ago
JSON representation
A python lib to make it easier to create OSC Servers for the DMX Protocol
- Host: GitHub
- URL: https://github.com/miniontoby/dmxoscserver
- Owner: Miniontoby
- License: other
- Created: 2023-07-30T19:18:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-11T10:34:26.000Z (over 1 year ago)
- Last Synced: 2024-10-14T11:39:08.177Z (about 1 month ago)
- Topics: dmx, osc, python, qlcplus, server
- Language: Python
- Homepage: https://dmxoscserver.readthedocs.io/en/latest/
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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.Originally designed for QLC+, but it should work with any program that sends to the `//dmx/` path
It can receive single argument messages, like `//dmx/ ` (so you can set the channels to 3 and do channel 1 for red, 2 for green and 3 for blue)
It can also receive an array argument, like `//dmx/ [, , ]`
And it can also receive 3 arguments, like `//dmx/ `
## Installation
```bash
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:
```py
from DmxOscServer import DmxOscServerserver = 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
```py
# 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
```py
server.run("10.10.123.5", 1234) # Will listen on 10.10.123.5:1234
```If your addresses receive arrays or multiple args, add the `channel_as_array=True` argument
```py
# Define a 3 channel array based 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, channel_as_array=True)
def my_rgb_handler(fixture, address, *args):
print ("{} has been set to {}".format(address, args))
```It is also possible to use the `Fixture` class and the `add_fixture` method
```py
from DmxOscServer import DmxOscServer, Fixturedef 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 not array based Fixture at address 0 at universe 0
server.add_fixture(Fixture(0, 3, 3, my_rgb_handler, True)) # Register a 3 channel array based Fixture at address 0 at universe 0
```And for the `add_fixture` method, you can also add multiple fixtures at once using:
```py
from DmxOscServer import DmxOscServer, Fixture
server = DmxOscServer()
server.add_fixtures(
Fixture(0, 0, 3, my_rgb_handler), # Register a 3 channel not array based Fixture at address 0 of universe 0
Fixture(0, 3, 3, my_rgb_handler, True), # Register a 3 channel array based Fixture at address 3 of universe 0
)
```You can use the `fixture.values` property to see all the current values
```py
@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 valueThe 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/