Home › Forums › Tips & Techniques › Script to rewrite OSC for Kyma
Tagged: OSC
- This topic has 1 reply, 1 voice, and was last updated 8 years, 7 months ago by
Cristian Vogel.
-
AuthorPosts
-
26 July 2016 at 11:02 #1029
I work with OSC a lot mostly for communicating between apps and code, rather than external controllers.
I would like to share a script that I created during my research residency at ZKM earlier this year, useful for rewriting from standard OSC message syntax to Kyma widgets – directly in the Kyma signal flow.
This can be very handy when working with a large OSC protocol, that has many repeated messages, for example the Sonic Emotions Wave I wavefield synthesis system or Iannix gesture sequencer. You can copy and paste a long list directly into the script.
Use this in a Script Sound and it will create widgets for you with the correct OSC formatting, contained in an array called ?IncomingOSCMessagesRewrittenForKyma
You will then need to collect this array using a SyntheticSpectrumFromArray or (if you are a NeverEngineLabs subscriber ) our ArrayToGlobal Controllers Class.
Good luck!
“### Rewrite OSC for Kyma Widgets
## # (c) 2016 neverenginelabs.com
###
”
| OSCMessagesRaw rewriter OSCMessagesRewrittenForKyma |OSCMessagesRaw := #(
“################################
Add your list of addresses below this line
enclosed in single quotes.
Kyma recognises float arguments over OSC
therefore add an ‘f’ seperated by spaces for each argument and you will get a seperate
widget for each message, as required by the Kyma protocol
################################”‘/position/x’
‘/position/xyz f f f’
‘/position/ad f f’).
rewriter:=
[:inputList |
| result |
result := OrderedCollection new.
inputList do: [:message |
| stem argCount |
stem := (‘osc_’&(message copyFrom: 2 to: message size) copyReplaceAll: #($/) with: #($_)).argCount := message occurrencesOf: $f.
(argCount > 0) ifTrue: [
(1 to: argCount) do: [:n |
stem := (stem copyUpTo: $ )&’__’&n.
result add: (stem asHotValue).
]
] ifFalse: [ result add: (stem asHotValue).]
].
result
].OSCMessagesRewrittenForKyma := rewriter value: OSCMessagesRaw.
(inputs at: 1)
start: 0 s
IncomingOSCMessagesRewrittenForKyma: OSCMessagesRewrittenForKyma26 July 2016 at 14:53 #1030I made a little mistake in the code posted above… but seems like the forum won’t let me edit my post. The rewrite block should read:
rewriter:=
[:inputList |
| result |
result := OrderedCollection new.
inputList do: [:message |
| stem argCount |
stem := (‘osc_’&(message copyFrom: 2 to: message size) copyReplaceAll: #($/) with: #($_)).argCount := message occurrencesOf: $f.
(argCount > 0) ifTrue: [
(1 to: argCount) do: [:n | |
arg |
arg := (stem copyUpTo: $ )&’__’&n.
result add: (arg asHotValue).
]
] ifFalse: [ result add: (stem asHotValue).]
].
result
]. -
AuthorPosts
- You must be logged in to reply to this topic.