OSC library (Oscuino) for the Spark Core
Let's keep in touch :
- http://www.trublion.org
- https://www.facebook.com/trubliondotorg
- https://twitter.com/trubliondotorg
- contact_AT_trublion_DOT_org
We've been working on porting the [Oscuino library] (https://github.com/CNMAT/OSC) to the Spark Core, and we've faced the same problems as the ones mentioned in that thread by jfenwick.
Instead of rewriting the UDPSend()
function of the OSCMessage
and OSCBundle
classes, we've identified that the issues came from the Spark's core-firmware code (UDP
class in spark_wiring_udp.cpp
).
We've overloaded the misfunctioning functions (i.e. beginPacket()
, endPacket()
and write()
), and added proper includes in the Oscuino files, as explained in the following.
Our library is provided with Puredata and Max/MSP example patches to test the functionalities of our code.
This code will only work with the most recent versions of the core-firmware (or the current online compiler of the cloud), since we use the CFLAGS += -DSPARK
recently defined in the makefile
.
- We have overloaded the mysfunctioning UDP functions of the Spark Core (
myUDP
class inapplication.cpp
)
-
Proper includes have been added to
OSCData.h
andOSCMessage.h
-
We do not use the
OSCTiming
class andOSCBoards.h
(both must be rewritten to work with the Spark) -
All modifications are labelled with the following comment :
// Simon+Emilien-OSCUINO
3. Setup (we're compiling our code with make
as explained in the documentation ) :
-
Put
OSCBundle.cpp
,OSCData.cpp
,OSCMatch.c
,OSCMessage.cpp
andbuild.mk
intocore-firmware/src/OSC
-
Put
OSCBundle.h
,OSCData.h
,OSCMatch.h
andOSCMessage.h
intocore-firmware/inc/OSC
-
Put the IP address of your computer into
application.cpp
(search for the comment// put the IP address of your computer here
)
-
Wire LEDs to the
D0
andD1
pins -
Send
OSCMessages
andOSCBundles
to the Spark Core on port8888
-
Receive
OSCMessages
andOSCBundles
from the Spark Core on port9999
-
The IP of the Core is automatically sent at startup as an
OSCMessage
(OSC address =/coreip
) -
The Spark Core will manage either
OSCMessages
orOSCBundles
(not both at the same time) -
5 OSC addresses are taken into account by our test application:
/manageMessages
(no arguments) will switch the Core to managingOSCMessages
(OSCBundles
will be ignored)/manageBundles
(no arguments) will switch the Core to managingOSCBundles
(OSCMessages
will be ignored)/sendTestMsg
(no arguments) will ask the Core to send anOSCMessage
for test (its address is/testmessage
)/sendTestBndl
(no arguments) will ask the Core to send anOSCBundle
for test (its address is/testbundle/*
)/led
followed by two ints will switch on/off the two LEDs [The 1st int is the pin number (0 forD0
, 1 forD1
). The 2nd int is the LED state (0 forLOW
, 1 forHIGH
)]
-
To test our Max/MSP patch, download and install the Max OSC library made by the CNMAT
-
Start the patch and reboot the Spark Core (short press the "RST" button)
-
The IP address of the Core is automatically setup (it is sent as an
OSCMessage
when the Core boots and registered to theudpsend
object) -
By default, the Core will manage
OSCMessages
(OSCBundles
are ignored at startup) -
Test the functionalities