Skip to content

Instantly share code, notes, and snippets.

@cleemy-desu-wayo
Last active September 29, 2025 23:31
OSC Type Tag "T", "F", and "N" in Processing 4

OSC Type Tag "T", "F", and "N" in Processing 4

screenshot of Processing 4

Processing 4.4.7 with oscP5 0.9.9 seems to handle OSC Type Tags "T", "F", and "N" correctly.

see also about Pure Data (Purr Data):
https://gist.github.com/cleemy-desu-wayo/9d314e448b9f0edffcb2ffa503c3e824

see also about SuperCollider:
https://gist.github.com/cleemy-desu-wayo/ed47772c4e26841bb6ad17810c1953c1

two simple samples for python-osc, one for sending and one for receiving "T", "F", or "N", are available here:
https://gist.github.com/cleemy-desu-wayo/590a22d5fb4e3f813b06dcc2fef9ae77

/*
* Receiving OSC Type Tag "T", "F", and "N" in Processing
* written by cleemy desu wayo / Licensed under CC0 1.0
* 2025-09-29
* ----
* possibly the updated version is here:
* https://gist.github.com/cleemy-desu-wayo/e966a18706530e3af61867b2b3808d24
*
* ----
* require: oscP5
* (this code has been confirmed to work with Processing 4.4.7 and oscP5 0.9.9)
*
*/
import oscP5.*;
import netP5.*;
OscP5 osc;
int port = 9003; // change this line appropriately
int col_red = 0;
int col_green = 0;
int col_blue = 0;
int anime_phase_max = 40;
int anime_phase = 0;
void setup() {
size(400, 400);
background(color(0, 0, 0));
frameRate(60);
osc = new OscP5(this, port);
}
void draw() {
if (anime_phase >= 1) {
col_red = int(col_red / anime_phase * (anime_phase - 1));
col_green = int(col_green / anime_phase * (anime_phase - 1));
col_blue = int(col_blue / anime_phase * (anime_phase - 1));
anime_phase -= 1;
}
if (anime_phase == 0) {
col_red = 0;
col_green = 0;
col_blue = 0;
anime_phase = -1;
}
background(color(col_red, col_green, col_blue));
}
void oscEvent(OscMessage msg) {
if(msg.checkAddrPattern("/test") == false) return;
print("typetag: " + msg.typetag());
switch(msg.typetag().substring(0, 1)) {
case "T":
println(" ---- absolutely true");
col_red = 63;
col_green = 63;
col_blue = 255;
anime_phase = anime_phase_max;
break;
case "F":
println(" ---- absolutely false");
col_red = 255;
col_green = 63;
col_blue = 63;
anime_phase = anime_phase_max;
break;
case "N":
println(" ---- absolutely nil");
col_red = 127;
col_green = 127;
col_blue = 127;
anime_phase = anime_phase_max;
break;
default:
println("");
}
}
/*
* Sending OSC Type Tag "T", "F", and "N" in Processing
* written by cleemy desu wayo / Licensed under CC0 1.0
* 2025-09-29
* ----
* possibly the updated version is here:
* https://gist.github.com/cleemy-desu-wayo/e966a18706530e3af61867b2b3808d24
*
* ----
* require: oscP5, controlP5
* (this code has been confirmed to work with Processing 4.4.7 and oscP5 0.9.9)
*
*/
import oscP5.*;
import netP5.*;
import controlP5.*;
OscP5 osc;
NetAddress destHost;
ControlP5 cp5;
int listenPort = 9004; // change this line appropriately
int destPort = 9003; // change this line appropriately
String fontName = "Noto Sans Mono"; // change this line appropriately
void setup() {
osc = new OscP5(this, listenPort);
destHost = new NetAddress("localhost", destPort);
frameRate(60);
size(290, 560);
cp5 = new ControlP5(this);
PFont pfont = createFont(fontName, 14, true);
ControlFont font = new ControlFont(pfont);
int btnWidth = 250;
int btnHeight = 40;
int btnMarginX = 20;
int btnMarginY = 20;
String[] btnName = new String[9];
btnName[0] = "button01"; btnName[1] = "button02"; btnName[2] = "button03";
btnName[3] = "button04"; btnName[4] = "button05"; btnName[5] = "button06";
btnName[6] = "button07"; btnName[7] = "button08"; btnName[8] = "button09";
String[] btnCaption = new String[9];
btnCaption[0] = "send /test T"; btnCaption[1] = "send /test F";
btnCaption[2] = "send /test N"; btnCaption[3] = "send /test TFN";
btnCaption[4] = "send /test sT aaa1"; btnCaption[5] = "send /test iiiT 1 2 3";
btnCaption[6] = "send /test Tiii 4 5 6"; btnCaption[7] = "send /test iiiN 7 8 9";
btnCaption[8] = "send /test Niii 10 11 12";
for(int i = 0; i < btnName.length; i++) {
cp5.addButton(btnName[i])
.setPosition(btnMarginX, btnMarginY + (btnHeight + btnMarginY) * i)
.setSize(btnWidth, btnHeight)
.setCaptionLabel(btnCaption[i])
.setFont(font)
;
cp5.getController(btnName[i]).getCaptionLabel().toUpperCase(false);
}
}
void draw() { }
void button01() {
OscMessage msg = new OscMessage("/test");
msg.add(true);
osc.send(msg, destHost);
}
void button02() {
OscMessage msg = new OscMessage("/test");
msg.add(false);
osc.send(msg, destHost);
}
void button03() {
OscMessage msg = new OscMessage("/test");
msg.add();
osc.send(msg, destHost);
}
void button04() {
OscMessage msg = new OscMessage("/test");
msg.add(true).add(false).add();
osc.send(msg, destHost);
}
void button05() {
OscMessage msg = new OscMessage("/test");
msg.add("aaa1").add(true);
osc.send(msg, destHost);
}
void button06() {
OscMessage msg = new OscMessage("/test");
msg.add(new int[] {1, 2, 3}).add(true);
osc.send(msg, destHost);
}
void button07() {
OscMessage msg = new OscMessage("/test");
msg.add(true).add(new int[] {4, 5, 6});
osc.send(msg, destHost);
}
void button08() {
OscMessage msg = new OscMessage("/test");
msg.add(new int[] {7, 8, 9}).add();
osc.send(msg, destHost);
}
void button09() {
OscMessage msg = new OscMessage("/test");
msg.add().add(new int[] {10, 11, 12});
osc.send(msg, destHost);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment