|
|
4 years ago | |
|---|---|---|
| .gitignore | 4 years ago | |
| LICENSE | 4 years ago | |
| README.md | 4 years ago | |
| config.json | 4 years ago | |
| osc_client.py | 4 years ago | |
| osc_server.py | 4 years ago | |
README.md
osc_led
OSC control of LEDs for Jembo
Install dependencies
- Open lxterminal
- Copy/paste the following:
sudo apt-get install git
sudo pip3 install osc4py3
mkdir git
cd git
git clone https://git.sav.net.au/Public/osc_led.git
Setup Reaper, load the template
Set up reaper to listen on port 8000 and send to port 9000. Control surface mode: OSC Mode: Configure device IP + local port Device port: 9000 Device IP: 127.0.0.1 Local Listen port: 8000 Local IP: doesn't matter [1] Wait between packets: 100ms [2] Allow binding messages to REAPER actions and FX learn: [X]
Notes:
- I couldn't set the address to listen on in the GUI, but it binds to 0.0.0.0 so it's listening on every local address anyway.
- I've set this to 100ms for testing. If this is too long a latency it can be dropped, but the python components are set with thresholds between .5% and 1% of brightness and colour respectively before changing the LEDs so that grandients aren't crazily chatty.
Update the config file
The file is config.json, following json formatting. This file describes the elements connected via GPIO and how they interact with osc_server. It also sets the initial state of outputs when osc_server starts, or when the restart function is called. The base version is a reasonable starting point. There are 3 main sections. Note that JSON doesn't support comments (#) so these will need to be removed if these examples are used.
Inputs/buttons
This section is for any element that is read. At this point, we only deal with buttons.
# Inputs section
"inputs":{
# Button elements, a dict, so each name correlates to one element
"buttons":{
# Button named "restart"
"restart":{
# Connected to pin 2
"pin": 2,
# When the button is pressed, run the restart function
# The function needs to exist in osc_server as btn_<name>
"when_pressed": "restart"
}
}
}
Outputs
LEDs
Section for outputs. At the moment, only LEDs are supported.
# Outputs section
"outputs":{
# LEDs, an array of dicts
"leds":[
{
"name":"1", # A descriptive name, for logs
"pin": 21, # The pin it's connected to
"target": 3 # The OSC target. In this case, this is the number of the fx_param. In theory multiple LEDs could share a target to be controlled by one OSC message
"defaults": # Optional: defaults to set on startup
{
"state": 0 # Whether it's on or off, 1=on 0=off
"brightness": 1.0 # Brightness as a float, 0.0 to 1.0
}
},
# JSON allows us to condense the formatting, in this case one per line
{ "name":"2", "pin":20, "target":"4", "defaults": { "state":0,"brightness":1.0}},
{ "name":"3", "pin":16, "target":"5"},
{ "name":"4", "pin":12, "target":"6"},
{ "name":"5", "pin":5, "target":"7"}
]
}
Defaults
This section sets the defaults for outputs/LEDs where the elements themselves do not have defaults set.
# Defaults section
"defaults":{
# LEDs
"led":{
# Values as above.
"brightness": 1.0,
"colour": 1.0 ,
"state": 0
}
}
Start osc_server
- Open lxterminal
- Run the following:
cd ~/git/osc_led
./osc_server.py
Controlling Reaper
You can do it from reaper, or use some basic controls from osc_client.py
- Open lxterminal
cd ~/git/osc_led
./osc_client.py play
# OR
./osc_client.py stop
# OR
./osc_client.py restart