Open Sound Control (OSC) is a networking protocol for real-time musical control information. It was introduced in 1997 by the Center for New Music and Audio Technologies (CNMAT) in Berkeley. It is transport-independent--it can be used over UDP, TDP, WiFi, serial connections, and even within applications. We use it to transfer musical control information from the microcontroller to a computer, which is shown below as a laptop:
The FT232 chip interfaces the microcontroller with a standard Universal Serial Bus (USB) connector. We can use the USB link to open an OSC connection. The microcontroller acts as an OSC client by sending OSC messages. An application running on the computer, such as Pd, acts as an OSC server by receiving and interpreting the OSC messages.
To add OSC functionality to your program
It may be easier to hack one of the examples that uses OSC, but here are the main elements required:
Add $(AVRLIB)/uart.c $(AVRLIB)/ccrma/osc.c $(AVRLIB)/timerx8.c to the SRC line in the makefile so that the compiler knows which additional library source code is needed.
Add the proper includes at the top of the source file.
#include "uart.h" #include "ccrma/osc.h" #include "timerx8.h"
Somewhere early in your program initialize the UART, OSC, the timer, and set the rate at which we communicate over the serial link.
uartInit(); oscInit(); timerInit(); uartSetBaudRate(115200);
Then you can for example send messages using void oscSendMessageInt(char *address, u32 arg) and void oscSendMessageInt(char *address, u32 arg, u32 arg2) // to send two values at once