I am trying to connect Tidal to processing, in which I'm using a Kinect v2 sensor to skeleton track people in a room.
I saw this: https://blog.tidalcycles.org/tidalcycles-and-processing/
But the GitHub looks quite old, just wondering if anyone has any good tips on using OSC with tidal, or any examples?
Yes that post is about sending stuff from tidal to processing I think.
When you start tidal it says something about listening to port 6010 - that's where you can send OSC from processing. You basically send to the /ctrl path, and add a string that is a name for the value, and the value itself. Here's an example that sends the x position of the mouse (from 0 .. 1) when you click it on the processing window.
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress tidal;
void setup() {
size(400,400);
frameRate(25);
oscP5 = new OscP5(this,12000);
tidal = new NetAddress("127.0.0.1",6010);
}
void draw() {
background(0);
}
void mousePressed() {
/* in the following different ways of creating osc messages are shown by example */
OscMessage myMessage = new OscMessage("/ctrl");
myMessage.add("mousex");
myMessage.add((float)mouseX/(float)width);
println((float)mouseX/(float)width);
/* send the message */
oscP5.send(myMessage, tidal);
}
Here's an example of reading that value:
d1 $ sound "bd*8" # pan (cF0 "mousex")
There's a bit more info here:
It would be good to make this page clearer with more examples though.
I am receiving messages from processing (Kinect skeleton tracker) into tidal.
This is the part of the code in processing where I sent the message:
myMessage = new OscMessage("/ctrl");
myMessage.add("sf"); // have tried with and without this
myMessage.add("hello");
myMessage.add(myVelocity1);// this is a float value like 0.3991282, have tried sending a string
That all looks fine. You're right to leave the 'sf' off, that bit is created automatically for you by the processing library (the 's' means the first parameter is a string, the 'f' means the second parameter is a float).
I think the problem could just be with 'squiz'. It doesn't have any effect (at least, none I've noticed) until you go over '1'. So you could add or multiply the value until you get the range you want, either in processing or tidal.
I could be wrong, but your code looks fine otherwise.
This all looks fine except it looks like processing is sending an integer not a float. That might be confusing things. Try changing myMessage.add(myVelocity1); to myMessage.add(float(myVelocity1));
I have checked this - processing is definitely sending a float.
I thought show (cF 0 "hello") would display the value being input to the pattern, since it is in place of a parameter, so, I don't get why it would always return 0.0?
But I notice that 'readMVar $ sInput tidal' returns
fromList [("hello",(0>1)|395.81597900390625f)]
the number 395.81597900390625 is what I sent from processing, and the f on the end seems to confirm it is a float?
So everything seems to be working - except the pattern doesn't receive the value still and show (cF 0 "hello") returns "(0>1)|0.0"
I am sending the osc message from another computer and using tidal <- startTidal superdirtTarget (defaultConfig {cCtrlAddr = "0.0.0.0", cCtrlPort = 6060}), but that shouldn't make any difference or does it?
show (cF 0 "hello") will always return 0.0 because it doesn't have access to the number you've sent until it's running as a pattern.
You're right, the readMVar $ sInput tidal output does show that the value is set as a float, so everything looks fine in terms of processing > tidal communications. So d1 $ sound "bd" # speed (cF 0 "hello") should really work with that value. 395 is high for a 'speed' value so you would probably only her the bd as a click if at all.
I'm very grateful for your help. Well I tried exactly what you said and the example you gave does work but required me to send the message from processing on the same computer using localhost. Perhaps this moves us a step closer to identifying the issue, but in my case I would like to have processing run on another computer.
The example you have worked when listening to messages from processing running locally.
d1 $ sound "bd" # speed (cF 0 "hello") - does receive the value from processing run locally so that's a good start
To see what's hapopening, I run:
import Control.Concurrent.MVar
readMVar $ sInput tidal
the input is the value sent from the local processing app. The value is 12.199999809265137 and I hear a pitched up 'bd'
11 is the value I sent from the remote computer and the name was "hello2", not sure why it sees the "hello" message as the same value but that's probably irrelevant.
It seems that the issue is that the pattern does not obtain the message data when the message is sent from a different computer.
Hi,
This is all very strange. You can see that the value is getting into the state there. At this point it really shouldn't matter which computer it came from. That one value seems to be set to match the other is really strange too.
I don't have access to another computer to test this myself.. But I think something else is going on here. You've described all the steps you've taken well and I just can't see why this wouldn't be working - it's really strange!