Let me say that I have never used PureData or OSC before, and I just duplicated the schedule / patch shown to create the server / client.
1) server in PureData, client in MATLAB:
First, create a server in PureData:

Now here is a simple client implemented as a GUI in MATLAB:
function example_osc_client() handles = createGUI(); osc = []; function h = createGUI() h.fig = figure('Menubar','none', 'Resize','off', ... 'CloseRequestFcn',@onClose, ... 'Name','OSC Client', 'Position',[100 100 220 140]); movegui(h.fig, 'center') h.conn = uicontrol('Style','pushbutton', 'String','Connect', ... 'Callback',{@onClick,'connect'}, ... 'Parent',h.fig, 'Position',[20 20 80 20]); h.disconn = uicontrol('Style','pushbutton', 'String','Disconnect', ... 'Callback',{@onClick,'disconnect'}, ... 'Parent',h.fig, 'Position',[120 20 80 20]); h.slid = uicontrol('Style','slider', 'Callback',@onSlide, ... 'Min',-10, 'Max',10, 'Value',0, ... 'Parent',h.fig, 'Position',[30 60 160 20]); h.txt = uicontrol('Style','text', 'String','0.0', ... 'Parent',h.fig, 'Position',[80 100 60 20]); set([h.slid;h.disconn], 'Enable','off'); drawnow end function onClick(~,~,action) switch lower(action) case 'connect' osc = osc_new_address('127.0.0.1', 2222); set(handles.conn, 'Enable','off') set(handles.disconn, 'Enable','on') set(handles.slid, 'Enable','on') case 'disconnect' osc_free_address(osc); osc = []; set(handles.conn, 'Enable','on') set(handles.disconn, 'Enable','off') set(handles.slid, 'Enable','off') end drawnow end function onSlide(~,~) if isempty(osc), return; end val = single(get(handles.slid,'Value')); m = struct('path','/test', 'tt','f', 'data',{{val}}); osc_send(osc, m); set(handles.txt, 'String',num2str(val)) drawnow end function onClose(~,~) if ~isempty(osc) osc_free_address(osc); end delete(handles.fig); end end

When moving the slider, messages are sent to the server (using osc-mex ), and the values are displayed in the PureData Model.
During testing, I noticed that the double type is not supported, because in the PD log window I saw the following message:
unpackOSC: PrintTypeTaggedArgs: [64-bit float] not implemented
Thus, it was necessary either to manually distinguish the values as single , or to explicitly indicate the type of tooltip in the structure passed to osc_send OSC-MEX:
val = single(1); m = struct('path','/test', 'tt','f', 'data',{{val}}); osc_send(osc, m);
2) server in MATLAB, client in PureData:
Similarly, we create a client in PureData:

Again, here the server is implemented as a MATLAB GUI:
function example_osc_server() handles = createGUI(); osc = []; function h = createGUI() h.fig = figure('Menubar','none', 'Resize','off', ... 'CloseRequestFcn',@onClose, ... 'Name','OSC Server', 'Position',[100 100 220 140]); movegui(h.fig, 'center') h.start = uicontrol('Style','pushbutton', 'String','Start', ... 'Callback',{@onClick,'start'}, ... 'Parent',h.fig, 'Position',[20 20 80 20]); h.stop = uicontrol('Style','pushbutton', 'String','Stop', ... 'Callback',{@onClick,'stop'}, ... 'Parent',h.fig, 'Position',[120 20 80 20]); h.txt = uicontrol('Style','text', 'String','', ... 'Parent',h.fig, 'Position',[60 80 100 20]); set(h.stop, 'Enable','off'); drawnow expose h.timer = timer('TimerFcn',@receive, 'BusyMode','drop', ... 'ExecutionMode','fixedRate', 'Period',0.11); end function onClick(~,~,action) switch lower(action) case 'start' set(handles.start, 'Enable','off') set(handles.stop, 'Enable','on') osc = osc_new_server(2222); start(handles.timer); case 'stop' set(handles.start, 'Enable','on') set(handles.stop, 'Enable','off') osc_free_server(osc); osc = []; stop(handles.timer); end drawnow expose end function receive(~,~) if isempty(osc), return; end m = osc_recv(osc, 0.1); if isempty(m), return; end set(handles.txt, 'String',num2str(m{1}.data{1})) drawnow expose end function onClose(~,~) if ~isempty(osc) osc_free_server(osc); end stop(handles.timer); delete(handles.timer); delete(handles.fig); clear handles osc end end

The server side was a bit more complicated in MATLAB. The idea is that we do not want MATLAB to block endless waiting for messages. So I created a timer that runs every 0.11 seconds. Inside the timer function, we are trying to get the message in a blocking way, but with a timeout of 0.1 s. In this way, both the GUI and the MATLAB IDE remain responsive.
3) other combinations:
Using the solutions above, you can also open both the client and server in PureData or both the client and server in MATLAB. It should work anyway.
Finally, I have to say that it doesn’t matter if I use the host name as localhost or directly specify the IP address 127.0.0.1 .
NTN
EDIT:
I managed to build the OSC-MEX package myself, here are the steps. First download the osc-mex sources and its dependencies. This includes: liblo sources , pthreads-win32 binaries , premake4 executable.
1) Let's start by creating the liblo library:
- Copy "premake4.exe" to the "build" directory and run:
premake4 --platform=x32 vs2010 - open the generated liblo.sln solution file in VS2010. Select the "liblo" project and go to "Project> Properties". Add an
include folder containing the pthreads header files in the "Include Additional Directories" box. Similarly, add the lib folder for the linker and specify pthreadVC2.lib as an additional dependency. - Select the target "ReleaseLib" Win32 and create a project. This should create the final goal:
lib\ReleaseLib\liblo.lib
Note that by default , IPv6 support is disabled in liblo because OSC applications like Pd have problems with IPv6. If you still want to enable it, add the following line to the config.h file:
#define ENABLE_IPV6 1
2) Next, we compile MEX functions in MATLAB:
- Go to the folder containing the C-sources of the MEX functions
- copy
liblo.lib from the previous step to this directory. Also copy pthreadVC2.lib from the pthreads library. compile each function using:
mex -largeArrayDims -I../path/to/liblo-0.27 xxxxxx.c pthreadVC2.lib liblo.lib -lwsock32 -lws2_32 -liphlpapi
You should get six *.mexw32 files for each of the xxxxxx.c source files
- Finally copy the pthreads dll into the same folder:
pthreadVC2.dll
To save you trouble, here are the compiled MEX files created on WinXP 32-bit and Win8 64-bit using VS2010. Here are the sources if you want to compile it yourself (just create a solution in VS2010, then run osc_make.m in MATLAB)