Skip to content

Instantly share code, notes, and snippets.

@cleemy-desu-wayo
Last active September 16, 2025 08:37
Receiving OSC Type Tag "T", "F", and "N" in SuperCollider

Receiving OSC Type Tag "T", "F", and "N" in SuperCollider

screenshot of SuperCollider

In SuperCollider 3.13.0, for receiving OSC messages, simply using OSCdef seems to handle OSC Type Tags "T", "F", and "N" correctly.

When sending, I don't know if there is an easy way like sendtyped in Pure Data (if anyone knows, please let me know).

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

a simple sample for sending "T" or "F" or "N", client_python-osc_t-f-n.py, is available here:
https://gist.github.com/cleemy-desu-wayo/590a22d5fb4e3f813b06dcc2fef9ae77

/*
* Receiving OSC Type Tag "T", "F", and "N" in SuperCollider
* written by cleemy desu wayo / Licensed under CC0 1.0
* 2025-09-16
* ----
* https://gist.github.com/cleemy-desu-wayo/ed47772c4e26841bb6ad17810c1953c1
*/
/*
* ==========================================================================
* simply print the received OSC messages
* ==========================================================================
*/
(
OSCdef(\osctest, { |...args| args.postln }, '/test', nil, 9002)
)
/*
* ==========================================================================
* check the internal handling of SuperCollider (which class it is), and
* do conditional branching
* ==========================================================================
*/
(
OSCdef(\osctest,
{ |args| case { args[1].class == True } { 'absolutely true'.postln }
{ args[1].class == False } { 'absolutely false'.postln }
{ args[1].class == Nil } { 'absolutely nil'.postln };
}, '/test', nil, 9002)
)
/*
* ==========================================================================
* play sawtooth wave (NOTE: requires doing "Boot Server" from menu)
* if OSC Type Tag is "T", 440Hz; if tag is "F", 220Hz; if tag is "N", 880Hz
* ==========================================================================
*/
(
var volume = 0.3;
var env = Env.perc(0.03, 0.9, 1, -4);
var play_saw = { |freq|
{
var envgen = EnvGen.kr(env);
Saw.ar(freq)!2 * volume * envgen
}.play;
};
OSCdef(\osctest,
{ |args| case { args[1].class == True } { 'absolutely true'.postln; play_saw.value(440) }
{ args[1].class == False } { 'absolutely false'.postln; play_saw.value(220) }
{ args[1].class == Nil } { 'absolutely nil'.postln; play_saw.value(880) };
}, '/test', nil, 9002);
play_saw.value(440);
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment