![]() |
#1 |
Human being with feelings
Join Date: Dec 2021
Posts: 4
|
![]()
I've had one of those RGB bulbs for a while, and thought - wouldn't it be cool to turn it red when recording in REAPER? I tried it and of course, it's possible with ReaScript! Technically you could control any smart home device with this, as long as it has an API.
![]() First we need the 'recording trigger script', which is a simple deferred function which runs in a loop and checks the current recording status. I wish that ReaScript had triggers / event hooks for this, but polling works just fine actually. If the recording state changes - it executes a Python script that changes the bulb color. To change the lights you'll likely need to create an account on the device manufacturer's developer portal. I have a Tuya bulb so I used the tinytuya library for Python to set the bulb color, and followed the instructions on the README to set up API access. If you have Philips Hue, you might use a library like phue. Not sure about other manufacturers, but check on their website and it's likely they also have API support! Here is a video of it in action Here's the recording trigger script: Code:
starttime=os.time() lasttime=starttime local wasRecording = reaper.GetPlayState() & 4 == 4 local function runloop() local isRecording = reaper.GetPlayState() & 4 == 4 local newtime=os.time() if newtime-lasttime >= 1 then lasttime=newtime if (not wasRecording and isRecording) then reaper.ExecProcess('cmd.exe /C ""<python.exe location>" "<set bulb red colour script>""', 5000) else if (not isRecording and wasRecording) then reaper.ExecProcess('cmd.exe /C ""<python.exe location>" "<set bulb white colour script>""', 5000) end end wasRecording = isRecording end reaper.defer(runloop) end runloop() ![]() |
![]() |
![]() |
![]() |
#2 |
Human being with feelings
Join Date: May 2009
Posts: 29,389
|
![]()
Nice job!
And welcome. ![]()
__________________
Music is what feelings sound like. |
![]() |
![]() |
![]() |
#3 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
So cool !
I use second screen or mobile to show red square to participant when record active but with light bulb it is quite fancy ! I wonder what are the other possibilities...^^ Including devices like littlebits or arduino... Some fancy things could be done !
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#4 | |
Human being with feelings
Join Date: May 2009
Posts: 29,389
|
![]() Quote:
![]() https://forum.cockos.com/showpost.ph...69&postcount=7 https://forum.cockos.com/showthread.php?t=203449 https://forum.cockos.com/showthread.php?t=165165 https://forum.cockos.com/showthread.php?t=202644 https://www.youtube.com/watch?v=uf4IKTfbi64 The setup I have with the Faderport is the light turns red during record, green during playback and white when stopped. I also have/had a light in the hallway, so that if I'm recording and the wife is coming my way, she knows "Caution: tape is rolling".
__________________
Music is what feelings sound like. |
|
![]() |
![]() |
![]() |
#5 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
@karbo
Do you have a video of your set up ? it seems awesome !
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#6 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
@vbash
You put the lua code but do you also have python code to share ? 🤓
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#7 | ||
Human being with feelings
Join Date: Dec 2021
Posts: 4
|
![]() Quote:
![]() Quote:
Code:
import tinytuya d = tinytuya.BulbDevice(DEVICE_ID, LOCAL_IP_ADDRESS, LOCAL_KEY) d.set_version(3.3) data = d.status() if (data['dps']['20']): # if bulb is on d.set_colour(255, 0, 0) # turn it red |
||
![]() |
![]() |
![]() |
#8 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
It looks indeed so simple on code side... I need to go ASAP to a friends studio which has smart lights in the whole room, he has no idea that he could do that with them haha
Tough, not sure what brand he has. Code will vary for sure.
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#9 |
Human being with feelings
Join Date: May 2017
Location: Somewhere over the Rainbow
Posts: 6,854
|
![]()
I wonder, if it's possible to hook into the Lightbulb's API. That way, we could have an extension, that's talking directly to the lightbulb, without having to run python via commandline in reascript.
It would allow more immediate control of the lightbulb with no delay, maybe even having multple states for multi-colored lightbulbs, green for nothing is happening, yellow for tracks are armed, red for recording.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - ReaGirl - a GuiLib for guis working for blind people |
![]() |
![]() |
![]() |
#10 | |
Human being with feelings
Join Date: May 2009
Posts: 29,389
|
![]() Quote:
My original version is via reaper extension and it talks directly to that endpoint - well I call an external script because I didn't know how to do a web request in C++ but achieves the same goal plenty fast enough - and I like the external script as I can modify it on demand. I just wrote and added code to the FaderPortXT branch I own. If you see my other post, mine already does multiple colors based on state. Green = Playback Red = Recording White = Stopped ^Because all those transport events already fire in the csurf API. Etc.
__________________
Music is what feelings sound like. Last edited by karbomusic; 12-24-2021 at 11:46 AM. |
|
![]() |
![]() |
![]() |
#11 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
vbash solution is full scripts, this is nice :P
Though I wonder how much lag it has. On the video color transition is smooth so it is hard to evaluate.
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#12 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
Yesterday I finally got the occasion to go into a friend studio where he has 6 WIFI Tuya lights, so I was finally able to try it!
Damn the set up is complex. Creating account on Tuya cloud as regular user, as developper, creating project, subscripting to at least 3 services with expirtation date, having tochange browser cause for some reason popups which should appears to allow that doesn't work on firefox, got local keys after python + pip + tinytuya + scan + wizard etc.... ... and worst of all, trying to get the 6 lights to be recocgnized. Always one missing... Maybe weak wifi but anyway... In the end I do have a successful script but it is so slow to run, can take 3-5 seconds to turn all the light on. I guess for one light near the router it is ok, but 6 a bit far and it is barely usable :S What astonished me is how complex it is to just tell a light to change color. Sending message which seems to pass to continent level server etc, having to register some developper API keys online... Took about 3 hours to explore these... This seems so overkill compare to the 'simplicity' of the result. The complex part isn't the python code, but all which is before, and the sync lights parts. Make me wonder if there isn't more simple system than tuya, something with direct wifi only or bluetooth for eg (like when controlling a gopro), cause tuya... Exhausting ! Well, it would have been surely more easy if their website wasn't that buggy. @vbash You are definitely very patient to have gone to all this haha :P Anyway, this was interesting to explore :P Maybe works better with simpler set ups and very good wifi connection. Cheers !
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#13 | |
Human being with feelings
Join Date: May 2009
Posts: 29,389
|
![]() Quote:
Right now I'm in the middle of a DIY project using addressable LED strips and an ESP32 microprocessor which allows me to run them remotely over WiFi. This isn't for Reaper but for lighting in my office and areas in the house, but I'll possibly replace the Hue/Reaper/Transport setup with this in the near future because it is more versatile and will work with simple local GET requests. It's a little too low-level hardware wise for most here I assume and C++ for programing the microprocessor but if anyone is serious about doing similar I'll share out the github link. Here's some testing last week where I'm using aluminum tracks with milky white lenses (facing the wall for testing indirect lighting). The web app is running on the microprocessor so it is fully self-contained, no web, no signups etc..
__________________
Music is what feelings sound like. |
|
![]() |
![]() |
![]() |
#14 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
@karbo
No Tuya and other complicated cloud based subscripting or anything with this method ? Does it run local without internet ?
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#15 | |
Human being with feelings
Join Date: May 2009
Posts: 29,389
|
![]() Quote:
Ya' have to write the code against the API to use all these features but that's easy for you. There is absolutely zero dependency on any third-party as far as signups go and you can pretty much make it do whatever you want. ESP32 and ESP8266 are extremely popular, with outstanding DIY community support and API documentation. These same processors are the guts of many existing "name brand" IoT and home automation products. I've been working with them since about 2014. You can plug via USB into your computer and start programming immediately. The best toolchain/programming setup right now is likely VSCode with the PlatformIO extension installed. https://randomnerdtutorials.com/projects-esp32/
__________________
Music is what feelings sound like. Last edited by karbomusic; 02-12-2022 at 10:18 AM. |
|
![]() |
![]() |
![]() |
#16 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
@karbo
Sounds nice on paper, especially the no subscrition part :P So what device would I need for eg to explore that ? is there some kind of compatible RGB light bulbs ? i have to look for ESP32 kind of lights ?
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#17 | |
Human being with feelings
Join Date: May 2009
Posts: 29,389
|
![]() Quote:
A little creative thinking can likely result in something better than a bulb. So WS2812b or WS2813 LED strips or matrixes. For the device, maybe a little starter kit like this. Just because there are some extra components so you can hook things up and experiment and learn how to blink a regular LED first: https://www.amazon.com/ESP32-WROVER-.../dp/B09BC1N9LL ^That helps bridge the gap on how to hook stuff up to the device, which is usually just 3 small wires. Once you got that, the rest is just code which you are already great at. You're just doing stuff you already know and some of that is talking directly to the wires/gadgets you hookup, in this case addressable LEDs. Just be careful, if the lightbulb goes off (in your head), it can be kind of addicting because there are so many uses.
__________________
Music is what feelings sound like. |
|
![]() |
![]() |
![]() |
#18 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
Thanks for the infos!
Yes I would prefer a bulb, cause I want the "lamp" design. But I keep your solution in mind, maybe at some point... :P But for sure, tiny tuya wasn't that "plug and play" as I would have expect. :S I wonder if philips hue as such intricating activations etc. but it is definitely more expensive.
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#19 |
Human being with feelings
Join Date: May 2009
Posts: 29,389
|
![]()
You sign up as developer to access the API documentation but using that API doesn't require using their cloud. Your code is talking directly to your Hue hardware.
__________________
Music is what feelings sound like. |
![]() |
![]() |
![]() |
#20 |
Human being with feelings
Join Date: Dec 2021
Posts: 4
|
![]()
Yeah the Tuya setup process sucked! Although I hope it is communicating via local network first since you provide the LOCAL_KEY, but not 100% sure.
@karbomusic interesting stuff! Thanks for sharing, this could be the basis for the next studio evolution ![]() Another way to do this without using third-party APIs would be Home Assistant (https://www.home-assistant.io, you need to set up a local server for this) and then add Tuya support via this integration: https://github.com/rospogrigio/localtuya/. I haven't tried this, but sounds like a nice local solution, even better if you have a Raspberry Pi laying around to use as your 'automation station'. |
![]() |
![]() |
![]() |
#21 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
@vbash
Maybe better with hole assistant, more expensive though 😔 Sure thing is that just telling a rgb lamp near to you to turn red is far from straightforward. I had the feeling to hack something, as if the industry wasn't their yet. It really should be simpler. 😆
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#22 | |
Human being with feelings
Join Date: May 2009
Posts: 29,389
|
![]() Quote:
With one Phillips Hue bulb and 2 HTTP requests you're up and running. You won't even need the API, I'll just send you the command directly (or you can download any free app that controls them, and press F12 in your browser to see what command(s) it sends). It's just an HTTP request with a PUT verb in JSON format: Turn the light red: Code:
request = new XMLHttpRequest(); request.open("PUT", "http://IPOfYourHueBridge/api/YourLocalUserName/groups/2/action", false); request.send("{\"on\":true,\"bri\":255,\"sat\":255,\"hue\":0}"); You can do this or some version of it in a reaper script (see other threads).
__________________
Music is what feelings sound like. Last edited by karbomusic; 02-16-2022 at 08:58 AM. |
|
![]() |
![]() |
![]() |
#23 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
@karbomusic
Then philips hue seems definitely to be the way of simplicity ! ![]() simple HTTP requests, I'm ok with that!
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#24 | |
Human being with feelings
Join Date: May 2009
Posts: 29,389
|
![]() Quote:
![]() If you get these, I would suggest getting a developer account. I never really get any spam that I know of, it's just so they know how many are using the API and the API docs are really good.
__________________
Music is what feelings sound like. |
|
![]() |
![]() |
![]() |
#25 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
https://forum.cockos.com/showpost.ph...58&postcount=1 Maybe Lua Socket for ReaScript can interest some people here ?
![]()
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation Last edited by X-Raym; 04-26-2022 at 02:58 PM. |
![]() |
![]() |
![]() |
#26 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,672
|
![]()
Edited.
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
![]() |
![]() |
![]() |
#27 |
Human being with feelings
Join Date: May 2022
Posts: 1
|
![]()
The review is great, thank you. I also have a smart bulb, and it also can be programmed.
Thanks for sharing this code, and I think I will make use of it someday. I really want to synchronize all the three bulbs that I have. These color-changing RGB LED light bulbs make my house look much better, and I love the atmosphere that they create inside. The house looks like a place from Nicolas Winding Refn’s movie. They can be programmed to turn on or turn off at a particular time or change lights depending on a certain schedule. But they cannot shine red when you start recording. So, thanks for the code. Last edited by bignottalle; 05-16-2022 at 12:35 PM. |
![]() |
![]() |
![]() |
Thread Tools | |
|
|