Commit 7b0fde19 authored by Martin Fouilleul's avatar Martin Fouilleul
Browse files

intial commit

parents
.DS_Store
\ No newline at end of file
Copyright (c) 2019 Martin Fouilleul
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This repository is a support repository for my master thesis:
A middleware for handling temporal interactions in performing arts (2019)
It contains prototype implementations of the ideas proposed in this thesis. Since it should stay on sync with the document,
IT WILL LIKELY NOT BE UPDATED. Development of the BLITz middleware will continue, but not in this repository.
OSCPACK=oscpack_1_1_0
LIBLO=liblo-0.30
LIBO=libo-master
RTOSC=rtosc-master
BLITZ=../..
INCLUDE= $(addprefix -I, $(shell find $(BLITZ)/src -type d)) -I$(OSCPACK)/osc -I$(LIBLO) -I$(LIBO) -I$(RTOSC)/include/rtosc
SRC=$(OSCPACK)/osc/OscOutboundPacketStream.cpp $(OSCPACK)/osc/OscReceivedElements.cpp $(OSCPACK)/osc/OscTypes.cpp $(BLITZ)/src/osc.cpp $(BLITZ)/src/time/osx_time.cpp
LIBLO_LIB=-Lliblo-0.30/lib/ -llo
LIBO_LIB=-Llibo-master/ -lo
RTOSC_LIB=-L$(RTOSC)/build/ -lrtosc
PRODUCTDIR=bin
OPT=-std=c++11 -O3 -DPACKET_COUNT=100000000
COMPOSE_MSG_APIS=blitz_push blitz_fmt oscpack liblo libo rtosc
COMPOSE_BUNDLE_APIS=blitz_push blitz_fmt oscpack liblo libo rtosc
PARSE_MSG_APIS=blitz_iterator blitz_scan oscpack liblo libo rtosc
PARSE_BUNDLE_APIS=blitz_iterator blitz_scan oscpack libo rtosc # liblo does not have a public bundle parsing API
PRODUCTS=$(addprefix $(PRODUCTDIR)/, \
$(addprefix compose_msg_, $(COMPOSE_MSG_APIS)) \
$(addprefix compose_bundle_, $(COMPOSE_BUNDLE_APIS)) \
$(addprefix parse_msg_, $(PARSE_MSG_APIS)) \
$(addprefix parse_bundle_, $(PARSE_BUNDLE_APIS)))
all: $(PRODUCTS)
# Compose message
$(PRODUCTDIR)/compose_msg_blitz_push: src/compose_msg.cpp $(SRC) $(BLITZ)/src/osc.h | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_msg_blitz_push -DUSE_BLITZ_PUSH $(INCLUDE) src/compose_msg.cpp $(SRC)
$(PRODUCTDIR)/compose_msg_blitz_fmt: src/compose_msg.cpp $(SRC) $(BLITZ)/src/osc.h | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_msg_blitz_fmt -DUSE_BLITZ_FORMAT $(INCLUDE) src/compose_msg.cpp $(SRC)
$(PRODUCTDIR)/compose_msg_oscpack: src/compose_msg.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_msg_oscpack -DUSE_OSCPACK $(INCLUDE) src/compose_msg.cpp $(SRC)
$(PRODUCTDIR)/compose_msg_liblo: src/compose_msg.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_msg_liblo -DUSE_LIBLO $(INCLUDE) src/compose_msg.cpp $(SRC) $(LIBLO_LIB)
$(PRODUCTDIR)/compose_msg_libo: src/compose_msg.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_msg_libo -DUSE_LIBO $(INCLUDE) src/compose_msg.cpp $(SRC) $(LIBO_LIB)
$(PRODUCTDIR)/compose_msg_rtosc: src/compose_msg.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_msg_rtosc -DUSE_RTOSC $(INCLUDE) src/compose_msg.cpp $(SRC) $(RTOSC_LIB)
# Compose bundle
$(PRODUCTDIR)/compose_bundle_blitz_push: src/compose_bundle.cpp $(SRC) $(BLITZ)/src/osc.h | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_bundle_blitz_push -DUSE_BLITZ_PUSH $(INCLUDE) src/compose_bundle.cpp $(SRC)
$(PRODUCTDIR)/compose_bundle_blitz_fmt: src/compose_bundle.cpp $(SRC) $(BLITZ)/src/osc.h | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_bundle_blitz_fmt -DUSE_BLITZ_FORMAT $(INCLUDE) src/compose_bundle.cpp $(SRC)
$(PRODUCTDIR)/compose_bundle_oscpack: src/compose_bundle.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_bundle_oscpack -DUSE_OSCPACK $(INCLUDE) src/compose_bundle.cpp $(SRC)
$(PRODUCTDIR)/compose_bundle_liblo: src/compose_bundle.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_bundle_liblo -DUSE_LIBLO $(INCLUDE) src/compose_bundle.cpp $(SRC) $(LIBLO_LIB)
$(PRODUCTDIR)/compose_bundle_libo: src/compose_bundle.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_bundle_libo -DUSE_LIBO $(INCLUDE) src/compose_bundle.cpp $(SRC) $(LIBO_LIB)
$(PRODUCTDIR)/compose_bundle_rtosc: src/compose_bundle.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/compose_bundle_rtosc -DUSE_RTOSC $(INCLUDE) src/compose_bundle.cpp $(SRC) $(RTOSC_LIB)
# parse message
$(PRODUCTDIR)/parse_msg_blitz_iterator: src/parse_msg.cpp $(SRC) $(BLITZ)/src/osc.h | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_msg_blitz_iterator -DUSE_BLITZ_ITERATOR $(INCLUDE) src/parse_msg.cpp $(SRC)
$(PRODUCTDIR)/parse_msg_blitz_scan: src/parse_msg.cpp $(SRC) $(BLITZ)/src/osc.h | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_msg_blitz_scan -DUSE_BLITZ_SCAN $(INCLUDE) src/parse_msg.cpp $(SRC)
$(PRODUCTDIR)/parse_msg_oscpack: src/parse_msg.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_msg_oscpack -DUSE_OSCPACK $(INCLUDE) src/parse_msg.cpp $(SRC)
$(PRODUCTDIR)/parse_msg_liblo: src/parse_msg.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_msg_liblo -DUSE_LIBLO $(INCLUDE) src/parse_msg.cpp $(SRC) $(LIBLO_LIB)
$(PRODUCTDIR)/parse_msg_libo: src/parse_msg.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_msg_libo -DUSE_LIBO $(INCLUDE) src/parse_msg.cpp $(SRC) $(LIBO_LIB)
$(PRODUCTDIR)/parse_msg_rtosc: src/parse_msg.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_msg_rtosc -DUSE_RTOSC $(INCLUDE) src/parse_msg.cpp $(SRC) $(RTOSC_LIB)
# parse bundle
$(PRODUCTDIR)/parse_bundle_blitz_iterator: src/parse_bundle.cpp $(SRC) $(BLITZ)/src/osc.h | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_bundle_blitz_iterator -DUSE_BLITZ_ITERATOR $(INCLUDE) src/parse_bundle.cpp $(SRC)
$(PRODUCTDIR)/parse_bundle_blitz_scan: src/parse_bundle.cpp $(SRC) $(BLITZ)/src/osc.h | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_bundle_blitz_scan -DUSE_BLITZ_SCAN $(INCLUDE) src/parse_bundle.cpp $(SRC)
$(PRODUCTDIR)/parse_bundle_oscpack: src/parse_bundle.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_bundle_oscpack -DUSE_OSCPACK $(INCLUDE) src/parse_bundle.cpp $(SRC)
$(PRODUCTDIR)/parse_bundle_libo: src/parse_bundle.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_bundle_libo -DUSE_LIBO $(INCLUDE) src/parse_bundle.cpp $(SRC) $(LIBO_LIB)
$(PRODUCTDIR)/parse_bundle_rtosc: src/parse_bundle.cpp $(SRC) | $(PRODUCTDIR)
clang++ $(OPT) -o $(PRODUCTDIR)/parse_bundle_rtosc -DUSE_RTOSC $(INCLUDE) src/parse_bundle.cpp $(SRC) $(RTOSC_LIB)
# product directory
$(PRODUCTDIR) :
mkdir $(PRODUCTDIR)
run: $(PRODUCTS)
@echo "operation ; count ; time " | tee result.csv ; \
$(PRODUCTDIR)/compose_msg_blitz_push | tee -a result.csv ; \
$(PRODUCTDIR)/compose_msg_blitz_fmt | tee -a result.csv ; \
$(PRODUCTDIR)/compose_msg_oscpack | tee -a result.csv ; \
$(PRODUCTDIR)/compose_msg_rtosc | tee -a result.csv ; \
$(PRODUCTDIR)/compose_msg_liblo | tee -a result.csv ; \
$(PRODUCTDIR)/compose_msg_libo | tee -a result.csv ; \
$(PRODUCTDIR)/compose_bundle_blitz_push | tee -a result.csv ; \
$(PRODUCTDIR)/compose_bundle_blitz_fmt | tee -a result.csv ; \
$(PRODUCTDIR)/compose_bundle_oscpack | tee -a result.csv ; \
$(PRODUCTDIR)/compose_bundle_rtosc | tee -a result.csv ; \
$(PRODUCTDIR)/compose_bundle_liblo | tee -a result.csv ; \
$(PRODUCTDIR)/compose_bundle_libo | tee -a result.csv ; \
$(PRODUCTDIR)/parse_msg_blitz_iterator | tee -a result.csv ; \
$(PRODUCTDIR)/parse_msg_blitz_scan | tee -a result.csv ; \
$(PRODUCTDIR)/parse_msg_oscpack | tee -a result.csv ; \
$(PRODUCTDIR)/parse_msg_rtosc | tee -a result.csv ; \
$(PRODUCTDIR)/parse_msg_liblo | tee -a result.csv ; \
$(PRODUCTDIR)/parse_msg_libo | tee -a result.csv ; \
$(PRODUCTDIR)/parse_bundle_blitz_iterator | tee -a result.csv ; \
$(PRODUCTDIR)/parse_bundle_blitz_scan | tee -a result.csv ; \
$(PRODUCTDIR)/parse_bundle_oscpack | tee -a result.csv ; \
$(PRODUCTDIR)/parse_bundle_rtosc | tee -a result.csv ; \
$(PRODUCTDIR)/parse_bundle_libo | tee -a result.csv ;
clean:
rm -r bin
/*
Copyright (c) 2019 Martin Fouilleul
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include<stdio.h>
#include"OscOutboundPacketStream.h" // oscpack
#include"lo/lo_cpp.h" // liblo
#include"rtosc.h" // rtosc
#include"osc_bundle_u.h" // libo
#include"osc.h" // blitz osc
#include"platform_time.h"
#include"user_clock.h"
#ifndef PACKET_COUNT
#define PACKET_COUNT 10000000
#endif
//#define PACKET_COUNT 1
int main()
{
printf("compose bundles ");
#if USE_LIBLO
printf("using liblo");
#elif USE_LIBO
printf("using libo");
#elif USE_OSCPACK
printf("using oscpack");
#elif USE_RTOSC
printf("using rtosc");
#elif USE_BLITZ_PUSH
printf("using blitz osc (push API)");
#elif USE_BLITZ_FORMAT
printf("using blitz osc (format API)");
#else
#error No OSC API defined !
#endif
printf(" ; %i ; ", PACKET_COUNT);
const char* address1 = "/test/message/1";
const char* address2 = "/test/message/2";
const char* s1 = "This is test 1 !";
const char* s2 = "This is test 2 !";
int64 h1 = 1234;
int64 h2 = 5678;
double d1 = 3.14159;
double d2 = 1.6180;
const int buffSize = 2048;
char buffer[buffSize];
u64 start = GetSystemTimestamp();
for(int i=0; i<PACKET_COUNT; i++)
{
#if USE_LIBLO
lo::Message msg1("shd", s1, h1, d1);
lo::Message msg2("shd", s2, h2, d2);
lo::Bundle bundle;
bundle.add(address1, msg1);
bundle.add(address2, msg2);
size_t size = buffSize;
bundle.serialise(buffer, &size);
#elif USE_LIBO
t_osc_bndl_u *bundle = osc_bundle_u_alloc();
t_osc_msg_u* msg1 = osc_message_u_alloc();
osc_message_u_setAddress(msg1, address1),
osc_message_u_appendString(msg1, s1);
osc_message_u_appendInt64(msg1, h1);
osc_message_u_appendDouble(msg1, d1);
t_osc_msg_u* msg2 = osc_message_u_alloc();
osc_message_u_setAddress(msg1, address2),
osc_message_u_appendString(msg1, s2);
osc_message_u_appendInt64(msg1, h2);
osc_message_u_appendDouble(msg1, d2);
osc_bundle_u_addMsg(bundle, msg1);
osc_bundle_u_addMsg(bundle, msg2);
long size = osc_bundle_u_nserialize(NULL, 0, bundle);
osc_bundle_u_nserialize(buffer, size, bundle);
//NOTE(martin): apparently osc_bundle_u_addMsg() frees the message on our behalf...
osc_bundle_u_free(bundle);
#elif USE_OSCPACK
osc::OutboundPacketStream packet(buffer, buffSize);
//NOTE(martin): we have to explicitly cast to (osc::int64) otherwise calls to << are ambiguous
// even if its exactly the same type...
packet << osc::BeginBundle() <<
osc::BeginMessage(address1)
<< s1
<< (osc::int64)h1
<< d1
<< osc::EndMessage
<< osc::BeginMessage(address2)
<< s2
<< (osc::int64)h2
<< d2
<< osc::EndMessage
<< osc::EndBundle;
size_t size = packet.Size();
#elif USE_RTOSC
char buffer1[buffSize];
char buffer2[buffSize];
rtosc_message(buffer1, buffSize, address1, "shd", s1, h1, d1);
rtosc_message(buffer2, buffSize, address2, "shd", s2, h2, d2);
size_t size = rtosc_bundle(buffer, buffSize, 0, 2, buffer1, buffer2);
#elif USE_BLITZ_PUSH
osc_element elt;
OscBeginPacket(&elt, buffSize, buffer);
OscBeginBundle(&elt);
OscBeginMessage(&elt, address1);
OscPushString(&elt, s1);
OscPushInt64(&elt, h1);
OscPushDouble(&elt, d1);
OscEndMessage(&elt);
OscBeginMessage(&elt, address2);
OscPushString(&elt, s2);
OscPushInt64(&elt, h2);
OscPushDouble(&elt, d2);
OscEndMessage(&elt);
OscEndBundle(&elt);
OscEndPacket(&elt);
size_t size = OscElementSize(&elt);
#elif USE_BLITZ_FORMAT
osc_element elt;
OscBeginPacket(&elt, buffSize, buffer);
OscBeginBundle(&elt);
OscFormatMessage(&elt, address1, "shd", s1, h1, d1);
OscFormatMessage(&elt, address2, "shd", s2, h2, d2);
OscEndBundle(&elt);
OscEndPacket(&elt);
size_t size = OscElementSize(&elt);
#endif
}
u64 delta = GetSystemTimestamp() - start;
double length = TimestampToSeconds(delta);
printf("%.12f\n", length);
return(0);
}
/*
Copyright (c) 2019 Martin Fouilleul
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include<stdio.h>
#include"OscOutboundPacketStream.h" // oscpack
#include"lo/lo_cpp.h" // liblo
#include"rtosc.h" // rtosc
#include"osc_message_u.h" // libo
#include"osc.h" // blitz osc
#include"platform_time.h"
#include"user_clock.h"
#ifndef PACKET_COUNT
#define PACKET_COUNT 10000000
#endif
int main()
{
printf("compose messages ");
#if USE_LIBLO
printf("using liblo");
#elif USE_LIBO
printf("using libo");
#elif USE_OSCPACK
printf("using oscpack");
#elif USE_RTOSC
printf("using rtosc");
#elif USE_BLITZ_PUSH
printf("using blitz osc (push API)");
#elif USE_BLITZ_FORMAT
printf("using blitz osc (format API)");
#else
#error No OSC API defined !
#endif
printf(" ; %i ; ", PACKET_COUNT);
const char* address = "/foo/bar";
const char* s = "Hello, world !";
int64 h = 4000;
double d = 6.28218;
const int buffSize = 2048;
char buffer[buffSize];
u64 start = GetSystemTimestamp();
for(int i=0; i<PACKET_COUNT; i++)
{
#if USE_LIBLO
size_t size = buffSize;
lo_message lo = lo_message_new();
lo_message_add_string(lo, s);
lo_message_add_int64(lo, h);
lo_message_add_double(lo, d);
lo_message_serialise(lo, address, buffer, &size);
lo_message_free(lo);
#elif USE_LIBO
//NOTE(martin): this seems to be the only API to create a message ??
t_osc_msg_u* msg = osc_message_u_alloc();
osc_message_u_setAddress(msg, address),
osc_message_u_appendString(msg, s);
osc_message_u_appendInt64(msg, h);
osc_message_u_appendDouble(msg, d);
t_osc_msg_s* serialized = osc_message_u_serialize(msg);
osc_message_u_free(msg);
#elif USE_OSCPACK
osc::OutboundPacketStream packet(buffer, buffSize);
//NOTE(martin): we have to explicitly cast to (osc::int64) otherwise calls to << are ambiguous
// even if its exactly the same type...
packet << osc::BeginMessage(address)
<< s
<< (osc::int64)h
<< d
<< osc::EndMessage;
size_t size = packet.Size();
#elif USE_RTOSC
size_t size = rtosc_message(buffer, buffSize, address, "shd", s, h, d);
#elif USE_BLITZ_PUSH
osc_element elt;
OscBeginPacket(&elt, buffSize, buffer);
OscBeginMessage(&elt, address);
OscPushString(&elt, s);
OscPushInt64(&elt, h);
OscPushDouble(&elt, d);
OscEndMessage(&elt);
OscEndPacket(&elt);
size_t size = OscElementSize(&elt);
#elif USE_BLITZ_FORMAT
osc_element elt;
OscFormat(&elt, buffSize, buffer, address, "shd", s, h, d);
size_t size = OscElementSize(&elt);
#endif
}
u64 delta = GetSystemTimestamp() - start;
double length = TimestampToSeconds(delta);
printf("%.12f\n", length);
return(0);
}
/*
Copyright (c) 2019 Martin Fouilleul
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include<stdio.h>
#if USE_OSCPACK
#include"OscReceivedElements.h" // oscpack
#elif USE_LIBLO
#include"lo/lo_cpp.h" // liblo
#elif USE_RTOSC
#include"rtosc.h" // rtosc
#elif USE_LIBO
#include"osc_bundle_s.h"
#include"osc_bundle_iterator_s.h"
#include"osc_message_s.h" // libo
#include"osc_atom_s.h"
#include"osc_message_iterator_s.h"
#endif
#include"osc.h" // blitz osc
#include"platform_time.h"
#include"user_clock.h"
#ifndef PACKET_COUNT
#define PACKET_COUNT 10000000
#endif
int main()
{
printf("parsing bundles ");
#ifdef USE_OSCPACK
printf("using oscpack");
#elif USE_RTOSC
printf("using rtosc");
#elif USE_BLITZ_ITERATOR
printf("using blitz osc_iterator");
#elif USE_BLITZ_SCAN
printf("using blitz OscScan");
#elif USE_LIBO
printf("using libo");
#elif USE_LIBLO
#error "liblo does not provide a public API for deserializing/parsing bundles..."
#else
#error "No OSC API defined !"
#endif
printf(" ; %i ; ", PACKET_COUNT);
const char* address1 = "/test/message/1";
const char* address2 = "/test/message/2";
const char* s1 = "This is test 1 !";
const char* s2 = "This is test 2 !";
int64 h1 = 1234;
int64 h2 = 5678;
double d1 = 3.14159;
double d2 = 1.6180;
const int buffSize = 2048;
char buffer[buffSize];
int packetSize;
{
osc_element elt;
OscBeginPacket(&elt, buffSize, buffer);
OscBeginBundle(&elt, 0);
OscFormatMessage(&elt, address1, "shd", s1, h1, d1);
OscFormatMessage(&elt, address2, "shd", s2, h2, d2);
OscEndBundle(&elt);
OscEndPacket(&elt);
packetSize = OscElementSize(&elt);
}
volatile const char* pa; // parsed address
volatile const char* ps; // parsed string
volatile int64 ph; // parsed int
volatile double pd; // parsed double
u64 start = GetSystemTimestamp();
for(int i=0; i<PACKET_COUNT; i++)
{
#if USE_LIBO
// iterate over messages in an unserialized bundle
t_osc_bndl_it_s *b_it = osc_bndl_it_s_get(packetSize, buffer);
while(osc_bndl_it_s_hasNext(b_it))
{
t_osc_msg_s *msg_s = osc_bndl_it_s_next(b_it);
if(!strcmp(osc_message_s_getTypetags(msg_s)+1, "shd"))
{
t_osc_msg_it_s *m_it_s = osc_msg_it_s_get(msg_s);
t_osc_atom_s *atom = osc_msg_it_s_next(m_it_s);
ps = osc_atom_s_getData(atom);
atom = osc_msg_it_s_next(m_it_s);
ph = osc_atom_s_getInt64(atom);
atom = osc_msg_it_s_next(m_it_s);
pd = osc_atom_s_getDouble(atom);
osc_msg_it_s_destroy(m_it_s);
}
else
{
printf("typetags = %s\n", osc_message_s_getTypetags(msg_s));
ASSERT(0);
}
}
#elif USE_OSCPACK
try
{
osc::ReceivedPacket packet(buffer, packetSize);
ASSERT(packet.IsBundle());
osc::ReceivedBundle bundle(packet);
for(osc::ReceivedBundle::const_iterator it = bundle.ElementsBegin();