OSC2Hue

Hello people,

I wondered what it would be like to livecode a single pixel sitting outside of my screen (e.g. a lamp) with the same tools I use for music (maybe for a unified performance).

As I have a few Philips Hue lamps I created this OSC bridge so I could livecode them with Tidal Cycles: GitHub - ilesinge/osc2hue: An OSC bridge to Philips Hue lights

If you want to test it, here is an integration guide for Tidal Cycles specifically:

For whoever tests it if any, I'd be curious to have your feedback about how it feels like.

1 Like

I don't have the Philips Hue light but I really like this idea. Do you have any videos showing this code in action? I'm wondering what the response time is. For example, would the equivalent of bd*32 produce flashing lights?

GIF_20250720_222734_067

I'm currently on the move so I can't create a proper video with sound & light sync but here you can see a small example.

You can actually adjust the negative latency of the events that are sent in the boot file, so they are pretty much in sync.

To flash lights you'd have to adjust the brightness down and up repeatedly such as (you can also set a fade duration):

d1 $ fast 8 $ light "1*2" # brightness "0 1"

Note that sending events too fast can currently create additional latency issues but I'll look into that, if not due to the Hue bridge itself.

3 Likes

Hey, you don’t have to own real Philips Hue lights anymore to play with OSC2Hue.

You can now livecode on-screen “lights” with Huemulator.

Note that OSC2Hue is also compatible with diyHue if you own other brands of LED lights system (or if you want to build your own!).

2 Likes

Hi there, I am trying to get to the controlling the lights with Tidal Cycles but am having trouble.

Currently I have the WIZ protocol Hue Lights, these generate an IP address that can be connected to via python with the following code to test it out.

https://youtube.com/shorts/OmqMyeirQ5M?feature=share

An example of what this script can do is in the youtube short.

from pywizlight import wizlight, PilotBuilder
import asyncio
import time
async def control_bulb():
#the bulb ip address was found in the App under the Lightbulb Device Info
#the bulbs work off the ESP WROOM chip, good to know for hardware replication
    bulb = wizlight("192.168.68.61")
    print("Turning bulb ON...")
    await bulb.turn_on()
    print("Setting to blue...")
    await bulb.turn_on(PilotBuilder(rgb=(0, 0, 255)))
    time.sleep(2)
    print("Setting to 30% brightness...")
    await bulb.turn_on(PilotBuilder(brightness=30))
    time.sleep(2)
    print("Setting to warm white...")
    await bulb.turn_on(PilotBuilder(brightness=100, colortemp=2700))
    time.sleep(2)
    print("Turning bulb OFF...")
    await bulb.turn_off()
    # Properly close the connection
    await bulb.async_close()
    print("Test complete!")
# Run with proper cleanup
try:
    asyncio.run(control_bulb())
except KeyboardInterrupt:
    print("\nScript interrupted")

My current problem is getting SuperCollider IDE to forward the OSC Messages it receives so that Python can receive the messages for parsing.

How did you setup SuperCollider IDE to not consume the messages? it appears that whenever I try to forward the OSC Messages to a new port, there is nothing to send because the OSC Message is consumed before it can be forwarded.

Ok. So I got this to work but the delay is bugging me.

https://youtube.com/shorts/3kRUKAftxP8?si=tajSdCI_zQvgCy-9

I still have to write up how I got the osc message to forward but under the OSC documentation was a how to for port forwarding.

Hi Paul.

In my case I want the OSC message to both consumed by Supercollider and OSC2Hue.

The BootTidal.hs modification listed here was sufficient:

Notice that you can adjust the oLatency property to take into account your specific network conditions. Events will be sent in advance.

I'm not sure to understand where your Python script sits? It's purpose replicates OSC2Hue but in a different language?

I saw your OP and got excited however I am still very much a newb with GO or the language of the scripts you wrote.

I could read and understand it but the workflow was completely alien to me. So yea, I just wanted to try and make it function in python for familiarities sake.

Theres a lot of possibilities in python to hack more functionality into the bulbs using more libraries.

I was thinking of using an MPU6050 to control max brightness of one bulb while tidal controls the pulse of other bulbs.

1 Like

I completely understand, and hacking it yourself is even more fulfilling.
As I said in my previous message, the trick is to manage the delay on Supercollider's side, not on your script side, so that the events are sent in advance with a specific timing you decide.

Target {oName = "hue",          -- Or anything you want
        oAddress = "localhost", -- The host on which your script is listening
        oPort = 8080,           -- The port your script is listening
        oLatency = 0.2,         -- Tweak the delay here
        oSchedule = Live, 
        oWindow = Nothing,
        oHandshake = False,
        oBusPort = Nothing
}