[PD] Pd-list Digest, Vol 120, Issue 36

Dan Wilcox danomatika at gmail.com
Wed Mar 11 21:45:52 CET 2015


If you're already using liblo (which is a great library BTW), you don't
need oscpack. They both work with OSC.

I think you're missing some understanding on the fundamentals of OSC. An
OSC message has an address and a number of arguments, so a "list" in OSC
will just be a message with that number of arguments. To read them out in
C++ with liblo (or pretty much any other OSC library), you get the message
and check that the address is what you expect, check the number of
arguments, and for each argument, you check the type (int, float, stirring,
etc), and then pull the actual value as the type you want out. Basically
something like this in pseudo C++ :

if (message.address == "/expected/path" ){

  vector<float> list;
  for( int i = 0; i < message.numArguments; ++i) {

    if (message.argumentType(i) == FLOAT) {

      list.push_back(message.argumentAsFloat(i))

   }
}

liblo is a C library and what I wrote above is more applicable to oscpack
which uses classes, but the liblo function calls do exactly the same thing.
Also, you can check agains the type string as well which has 1 char per
type aka sending a message for pd like "/hello" 1.2 2.3 4.5 will have the
types string of "fff" for 3 float arguments.

On a related point, I have a C++ wrapper liblo library that makes it work
like oscpack :D https://github.com/danomatika/oscframework

---------- Forwarded message ----------
> From: Py Fave <pyfave at gmail.com>
> To:
> Cc: "pd-list at lists.iem.at" <pd-list at lists.iem.at>
> Date: Wed, 11 Mar 2015 15:42:11 +0100
> Subject: Re: [PD] communicating with c++ app using OSC
> i have seen this used successfully on c++ side
>
> oscpack -- Open Sound Control packet manipulation library
> http://www.audiomulch.com/~rossb/code/oscpack
>
>
>
> 2015-03-11 8:56 GMT+01:00 Jamie Bullock <jamie at jamiebullock.com>:
>
>>
>> Hi Paul,
>>
>> std::vector doesn't make a good container for OSC messages, as message
>> argument  types aren't generally contiguous (a message could be two ints
>> and a float, for example).
>>
>> Instead you need some intermediate data structures to handle argument
>> lists, introspecting types from arguments and unpacking values. This is
>> what oscpack does:
>>
>>
>> https://code.google.com/p/oscpack/source/browse/trunk/examples/SimpleReceive.cpp
>>
>> It's straightforward to use and I've found it reliable.
>>
>> Jamie
>>
>>
>> On Tue, Mar 10, 2015 at 7:42 pm, Paul Keyes <spskeyes at gmail.com> wrote:
>>
>> If I really want to use OSC is there a simple way to do it?
>>
>> On Fri, Oct 24, 2014 at 4:10 PM, Miller Puckette <msp at ucsd.edu> wrote:
>>
>>> Hi Paul -
>>>
>>> No need to use OSC for this - you can just use "netsend". THere's sample
>>> code for receiving from netsend in pd/src/u_pdreceive.c.
>>>
>>> cheers
>>> Miller
>>>
>>> On Fri, Oct 24, 2014 at 03:21:22PM -0300, Paul Keyes wrote:
>>> > Hi,
>>> >
>>> > I'm sending a list from pd to a c++/liblo app like so:
>>> >
>>> > [mylist]
>>> > |
>>> > [list prepend /osc_addr]
>>> > |
>>> > [list trim]
>>> > |
>>> > [packOSC]
>>> >
>>> > ...
>>> >
>>> > How can I read this list into an array or vector in the c++ app?
>>> > There seems to be lots of libraries, I've been testing liblo, but
>>> nothing
>>> > straightforward for receiving a list.
>>> >
>>> > Any help is greatly appreciated!
>>>
>>
-- 
Dan Wilcox
@danomatika
danomatika.com
robotcowboy.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20150311/84415bcf/attachment.html>


More information about the Pd-list mailing list