├── .gitignore ├── Doxyfile ├── LICENSE ├── README.md ├── doc ├── html │ ├── annotated.html │ ├── bc_s.png │ ├── classes.html │ ├── classtnyosc_1_1_bundle-members.html │ ├── classtnyosc_1_1_bundle.html │ ├── classtnyosc_1_1_message-members.html │ ├── classtnyosc_1_1_message.html │ ├── closed.png │ ├── doxygen.css │ ├── doxygen.png │ ├── files.html │ ├── functions.html │ ├── functions_func.html │ ├── functions_vars.html │ ├── globals.html │ ├── globals_defs.html │ ├── index.html │ ├── installdox │ ├── jquery.js │ ├── nav_f.png │ ├── nav_h.png │ ├── open.png │ ├── search │ │ ├── all_61.html │ │ ├── all_62.html │ │ ├── all_63.html │ │ ├── all_64.html │ │ ├── all_68.html │ │ ├── all_6d.html │ │ ├── all_6e.html │ │ ├── all_73.html │ │ ├── all_74.html │ │ ├── classes_62.html │ │ ├── classes_6d.html │ │ ├── close.png │ │ ├── defines_68.html │ │ ├── defines_6e.html │ │ ├── files_74.html │ │ ├── functions_61.html │ │ ├── functions_62.html │ │ ├── functions_63.html │ │ ├── functions_64.html │ │ ├── functions_6d.html │ │ ├── functions_73.html │ │ ├── mag_sel.png │ │ ├── nomatches.html │ │ ├── search.css │ │ ├── search.js │ │ ├── search_l.png │ │ ├── search_m.png │ │ ├── search_r.png │ │ └── variables_62.html │ ├── tab_a.png │ ├── tab_b.png │ ├── tab_h.png │ ├── tab_s.png │ ├── tabs.css │ ├── tnyosc_09_09_8h.html │ ├── tnyosc_09_09_8h_source.html │ ├── tnyosc_8hpp.html │ └── tnyosc_8hpp_source.html └── latex │ ├── Makefile │ ├── annotated.tex │ ├── classtnyosc_1_1_bundle.tex │ ├── classtnyosc_1_1_message.tex │ ├── doxygen.sty │ ├── files.tex │ ├── refman.tex │ ├── tnyosc_09_09_8h.tex │ └── tnyosc_8hpp.tex ├── include ├── tnyosc-dispatch.hpp └── tnyosc.hpp ├── src └── tnyosc-dispatch.cc └── tests ├── pattern_match_test.cc ├── tnyosc-dispatch_test.cc ├── tnyosc_net_test.cc └── tnyosc_test.cc /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | 4 | tests/tnyosc_net_test 5 | tests/tnyosc-dispatch_test 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Toshiro Yamada 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. The name of the author may not be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 17 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tnyosc 2 | 3 | ## Tiny Open Sound Control Library 4 | 5 | tnyosc is a tiny Open Sound Control library written in C++ for creating and parsing (or dispatching) OSC-compliant messages. tnyosc supports Open Sound Control 1.0 and 1.1 types and other nonstandard types, and bundles. 6 | 7 | This has been tested on OS X 10.6 and Linux (CentOS). It should work with any POSIX systems. Windows support is on it's way but I can't tell you when it would be out since I don't have a need for it yet. I can put more effort in it if anyone is interested though! 8 | 9 | To use the library to just create and send Open Sound Control message, you just need `tnyosc.hpp` header file. 10 | 11 | If you're interested in parsing or dispatching received OSC messages, you need both `tnyosc.hpp` and `tnyosc-dispatch.hpp` headers and `tnyosc-dispatch.cc` source files. 12 | 13 | ## tnyosc Example 14 | 15 | ### Creating and Sending OSC Messages 16 | 17 | Here's an example of creating a OSC message and inserting it in a bundle: 18 | 19 | // create a OSC message with OSC Address "/test" 20 | tnyosc::Message msg("/test"); 21 | 22 | // add a few arguments 23 | msg.append(1000); // int32 type 24 | msg.append(1.0f); // float32 type 25 | msg.append("hello tnyosc"); // OSC-string type 26 | 27 | // Messages can be bundled easily 28 | tnyosc::Bundle bundle; 29 | bundle.append(msg); 30 | 31 | To access the buffer as a char array and get its size: 32 | 33 | tnyosc::Message msg; 34 | char* data = msg.data(); 35 | size_t size = msg.size(); 36 | 37 | You can call the same functions for bundle: 38 | 39 | tnyosc::Bundle bundle; 40 | char* data = bundle.data(); 41 | size_t size = bundle.size(); 42 | 43 | Here's a complete example using boost::asio to send a OSC message over UDP: 44 | 45 | #include "tnyosc.hpp" 46 | #include 47 | 48 | #define HOST ("127.0.0.1") 49 | #defin PORT ("7400") 50 | 51 | using boost::asio::ip:udp; 52 | 53 | int main(int argc, const char* argv[]) 54 | { 55 | // boost::asio library for sending UDP packets 56 | boost::asio::io_service io_service; 57 | udp::socket socket(io_service, udp::endpoint(udp::v4(), 0)); 58 | udp::resolver resolver(io_service); 59 | udp::resolver::query query(udp::v4(), HOST, PORT); 60 | udp::resolver::iterator iterator = resolver.resolve(query); 61 | 62 | // create a OSC message 63 | tnyosc::Message msg("/test"); 64 | msg.append("hello tnyosc"); 65 | 66 | // send the message 67 | socket.send_to(boost::asio::buffer(msg.data(), msg.size()), *iterator); 68 | 69 | return 0; 70 | } 71 | 72 | A similar example is inside `tnyosc_net_test.cc`. 73 | 74 | ### Dispatching OSC Messages 75 | 76 | `tnyosc-dispatch.hpp` and `tnyosc-dispatch.cc` include code for dispatching received OSC messages. It is designed so that it does not enforce particular threading model and user have more control over how to organize their code. 77 | 78 | Dispatching OSC message is a little more involved because OSC methods (aka callback functions) need to be registered and OSC messages need to be parsed and matched against the methods. 79 | 80 | First, we need to define a OSC method. The method has a signature: 81 | 82 | void method(const std::string& address, 83 | const std::vector& argv, 84 | void* user_data); 85 | 86 | `address` is the OSC Address, which looks like a URL. 87 | `argv` is arguments in the OSC message. 88 | `user_data` is user specified pointer to a data that was set when registering the method. 89 | 90 | We can then add this method to the `Dispatcher` class with the matching signature. 91 | 92 | Dispatcher dispatcher; 93 | dispatcher.add_method("/match/address", /* match exactly with this OSC address */ 94 | NULL, /* no arguments specified */ 95 | &method, /* pointer to the OSC method */ 96 | NULL); /* no user data specified */ 97 | 98 | Then, once a raw OSC message is received, it can invoke the method by 99 | 100 | char* msg_data; 101 | size_t msg_size; 102 | 103 | // ... fill msg_data and msg_size with received raw OSC message 104 | 105 | // Get a matched callback list 106 | std::list callback_list = dispatcher.match_methods(msg_data, msg_size); 107 | 108 | // We can iterate through the list and invoke all OSC methods 109 | std::list::iterator it = callback_list.begin(); 110 | for (; it != callback_list.end(); ++it) { 111 | (*it)->method(((*it)->address, (*it)->argv, (*it)->user_data); 112 | } 113 | 114 | A full example can be found in `tnyosc-dispatch_test.cc`. 115 | 116 | ## BSD-License 117 | 118 | Copyright (c) 2011 Toshiro Yamada 119 | 120 | All rights reserved. 121 | 122 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 123 | 124 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 125 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 126 | 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. 127 | 128 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 129 | 130 | 131 | -------------------------------------------------------------------------------- /doc/html/annotated.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: Class List 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 | 59 |
60 |
61 |
62 |
Class List
63 |
64 |
65 |
Here are the classes, structs, unions and interfaces with brief descriptions:
66 | 67 | 68 |
tnyosc::Bundle
tnyosc::Message
69 |
70 | 71 | 76 | 77 | 78 |
79 | 82 |
83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /doc/html/bc_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/bc_s.png -------------------------------------------------------------------------------- /doc/html/classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: Class Index 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 | 59 |
60 |
61 |
62 |
Class Index
63 |
64 |
65 |
B | M
66 | 67 |
  B  
68 |
Bundle (tnyosc)   
  M  
69 |
Message (tnyosc)   
B | M
70 |
71 | 72 | 77 | 78 | 79 |
80 | 83 |
84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /doc/html/classtnyosc_1_1_bundle-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: Member List 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 | 59 | 65 |
66 |
67 |
68 |
tnyosc::Bundle Member List
69 |
70 |
71 | This is the complete list of members for tnyosc::Bundle, including all inherited members. 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 |
append(const Message *message)tnyosc::Bundle [inline]
append(const Bundle *bundle)tnyosc::Bundle [inline]
append(const Message &message) (defined in tnyosc::Bundle)tnyosc::Bundle [inline]
append(const Bundle &bundle) (defined in tnyosc::Bundle)tnyosc::Bundle [inline]
Bundle()tnyosc::Bundle [inline]
byte_array() const tnyosc::Bundle [inline]
clear()tnyosc::Bundle [inline]
data() const tnyosc::Bundle [inline]
set_timetag(uint64_t ntp_time)tnyosc::Bundle [inline]
size() const tnyosc::Bundle [inline]
~Bundle() (defined in tnyosc::Bundle)tnyosc::Bundle [inline]
84 | 85 | 90 | 91 | 92 |
93 | 96 |
97 | 98 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /doc/html/classtnyosc_1_1_message-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: Member List 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 | 59 | 65 |
66 |
67 |
68 |
tnyosc::Message Member List
69 |
70 |
71 | This is the complete list of members for tnyosc::Message, including all inherited members. 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 |
address() const tnyosc::Message [inline]
append(int32_t v) (defined in tnyosc::Message)tnyosc::Message [inline]
append(float v) (defined in tnyosc::Message)tnyosc::Message [inline]
append(const std::string &v) (defined in tnyosc::Message)tnyosc::Message [inline]
append(int64_t v) (defined in tnyosc::Message)tnyosc::Message [inline]
append(double v) (defined in tnyosc::Message)tnyosc::Message [inline]
append(char v) (defined in tnyosc::Message)tnyosc::Message [inline]
append_array(void *array, size_t size) (defined in tnyosc::Message)tnyosc::Message [inline]
append_blob(void *blob, uint32_t size) (defined in tnyosc::Message)tnyosc::Message [inline]
append_cstring(const char *v, size_t len) (defined in tnyosc::Message)tnyosc::Message [inline]
append_current_time() (defined in tnyosc::Message)tnyosc::Message [inline]
append_false() (defined in tnyosc::Message)tnyosc::Message [inline]
append_impulse() (defined in tnyosc::Message)tnyosc::Message [inline]
append_midi(uint8_t port, uint8_t status, uint8_t data1, uint8_t data2) (defined in tnyosc::Message)tnyosc::Message [inline]
append_null() (defined in tnyosc::Message)tnyosc::Message [inline]
append_time(uint64_t v) (defined in tnyosc::Message)tnyosc::Message [inline]
append_true() (defined in tnyosc::Message)tnyosc::Message [inline]
byte_array() const tnyosc::Message [inline]
clear()tnyosc::Message [inline]
data() const tnyosc::Message [inline]
Message(const std::string &address="/tnyosc")tnyosc::Message [inline, explicit]
Message(const char *address)tnyosc::Message [inline, explicit]
set_address(const std::string &address)tnyosc::Message [inline]
set_address(const char *address)tnyosc::Message [inline]
size() const tnyosc::Message [inline]
~Message() (defined in tnyosc::Message)tnyosc::Message [inline]
99 | 100 | 105 | 106 | 107 |
108 | 111 |
112 | 113 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /doc/html/closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/closed.png -------------------------------------------------------------------------------- /doc/html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/doxygen.png -------------------------------------------------------------------------------- /doc/html/files.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: File List 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 | 58 |
59 |
60 |
61 |
File List
62 |
63 |
64 |
Here is a list of all documented files with brief descriptions:
65 | 66 |
tnyosc.hpp [code]Tnyosc main (and only) header file
67 |
68 | 69 | 74 | 75 | 76 |
77 | 80 |
81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /doc/html/functions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: Class Members 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 | 59 | 65 |
66 |
67 |
Here is a list of all documented class members with links to the class documentation for each member:
103 |
104 | 105 | 110 | 111 | 112 |
113 | 116 |
117 | 118 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /doc/html/functions_func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: Class Members - Functions 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 | 59 | 65 |
66 |
67 |   103 |
104 | 105 | 110 | 111 | 112 |
113 | 116 |
117 | 118 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /doc/html/functions_vars.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyosc++: Class Members - Variables 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyosc++ 1
23 |
Tiny Open Sound Control header-only library
24 |
28 |
29 | 52 | 59 | 66 |
67 |
68 |   73 |
74 | 75 | 80 | 81 | 82 |
83 | 86 |
87 | 88 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /doc/html/globals.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: File Members 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 | 58 | 64 |
65 |
66 |
Here is a list of all documented file members with links to the documentation:
74 |
75 | 76 | 81 | 82 | 83 |
84 | 87 |
88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /doc/html/globals_defs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: File Members 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 | 58 | 64 |
65 |
66 |   74 |
75 | 76 | 81 | 82 | 83 |
84 | 87 |
88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /doc/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: Main Page 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 |
53 |
54 |
55 |
tnyos Documentation
56 |
57 |
58 |
59 | 60 | 65 | 66 | 67 |
68 | 71 |
72 | 73 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /doc/html/installdox: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | %subst = ( ); 4 | $quiet = 0; 5 | 6 | while ( @ARGV ) { 7 | $_ = shift @ARGV; 8 | if ( s/^-// ) { 9 | if ( /^l(.*)/ ) { 10 | $v = ($1 eq "") ? shift @ARGV : $1; 11 | ($v =~ /\/$/) || ($v .= "/"); 12 | $_ = $v; 13 | if ( /(.+)\@(.+)/ ) { 14 | if ( exists $subst{$1} ) { 15 | $subst{$1} = $2; 16 | } else { 17 | print STDERR "Unknown tag file $1 given with option -l\n"; 18 | &usage(); 19 | } 20 | } else { 21 | print STDERR "Argument $_ is invalid for option -l\n"; 22 | &usage(); 23 | } 24 | } 25 | elsif ( /^q/ ) { 26 | $quiet = 1; 27 | } 28 | elsif ( /^\?|^h/ ) { 29 | &usage(); 30 | } 31 | else { 32 | print STDERR "Illegal option -$_\n"; 33 | &usage(); 34 | } 35 | } 36 | else { 37 | push (@files, $_ ); 38 | } 39 | } 40 | 41 | foreach $sub (keys %subst) 42 | { 43 | if ( $subst{$sub} eq "" ) 44 | { 45 | print STDERR "No substitute given for tag file `$sub'\n"; 46 | &usage(); 47 | } 48 | elsif ( ! $quiet && $sub ne "_doc" && $sub ne "_cgi" ) 49 | { 50 | print "Substituting $subst{$sub} for each occurrence of tag file $sub\n"; 51 | } 52 | } 53 | 54 | if ( ! @files ) { 55 | if (opendir(D,".")) { 56 | foreach $file ( readdir(D) ) { 57 | $match = ".html"; 58 | next if ( $file =~ /^\.\.?$/ ); 59 | ($file =~ /$match/) && (push @files, $file); 60 | ($file =~ /\.svg/) && (push @files, $file); 61 | ($file =~ "navtree.js") && (push @files, $file); 62 | } 63 | closedir(D); 64 | } 65 | } 66 | 67 | if ( ! @files ) { 68 | print STDERR "Warning: No input files given and none found!\n"; 69 | } 70 | 71 | foreach $f (@files) 72 | { 73 | if ( ! $quiet ) { 74 | print "Editing: $f...\n"; 75 | } 76 | $oldf = $f; 77 | $f .= ".bak"; 78 | unless (rename $oldf,$f) { 79 | print STDERR "Error: cannot rename file $oldf\n"; 80 | exit 1; 81 | } 82 | if (open(F,"<$f")) { 83 | unless (open(G,">$oldf")) { 84 | print STDERR "Error: opening file $oldf for writing\n"; 85 | exit 1; 86 | } 87 | if ($oldf ne "tree.js") { 88 | while () { 89 | s/doxygen\=\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\" (xlink:href|href|src)=\"\2/doxygen\=\"$1:$subst{$1}\" \3=\"$subst{$1}/g; 90 | print G "$_"; 91 | } 92 | } 93 | else { 94 | while () { 95 | s/\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\", \"\2/\"$1:$subst{$1}\" ,\"$subst{$1}/g; 96 | print G "$_"; 97 | } 98 | } 99 | } 100 | else { 101 | print STDERR "Warning file $f does not exist\n"; 102 | } 103 | unlink $f; 104 | } 105 | 106 | sub usage { 107 | print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n"; 108 | print STDERR "Options:\n"; 109 | print STDERR " -l tagfile\@linkName tag file + URL or directory \n"; 110 | print STDERR " -q Quiet mode\n\n"; 111 | exit 1; 112 | } 113 | -------------------------------------------------------------------------------- /doc/html/nav_f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/nav_f.png -------------------------------------------------------------------------------- /doc/html/nav_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/nav_h.png -------------------------------------------------------------------------------- /doc/html/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/open.png -------------------------------------------------------------------------------- /doc/html/search/all_61.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | address 13 | tnyosc::Message 14 |
15 |
16 | 25 |
Searching...
26 |
No Matches
27 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /doc/html/search/all_62.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | Bundle 13 | tnyosc 14 |
15 |
16 |
17 |
18 | Bundle 19 | tnyosc::Bundle 20 |
21 |
22 | 31 |
Searching...
32 |
No Matches
33 | 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /doc/html/search/all_63.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 | 18 |
19 |
Searching...
20 |
No Matches
21 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /doc/html/search/all_64.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | data 13 | 17 |
18 |
19 |
Searching...
20 |
No Matches
21 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /doc/html/search/all_68.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | htonll 13 | tnyosc.hpp 14 |
15 |
16 |
Searching...
17 |
No Matches
18 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /doc/html/search/all_6d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | Message 13 | tnyosc 14 |
15 |
16 | 25 |
Searching...
26 |
No Matches
27 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /doc/html/search/all_6e.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | ntohll 13 | tnyosc.hpp 14 |
15 |
16 |
Searching...
17 |
No Matches
18 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /doc/html/search/all_73.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 | 19 |
20 |
21 | set_timetag 22 | tnyosc::Bundle 23 |
24 |
25 |
26 |
27 | size 28 | 32 |
33 |
34 |
Searching...
35 |
No Matches
36 | 42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /doc/html/search/all_74.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | tnyosc.hpp 13 |
14 |
15 |
Searching...
16 |
No Matches
17 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/html/search/classes_62.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | Bundle 13 | tnyosc 14 |
15 |
16 |
Searching...
17 |
No Matches
18 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /doc/html/search/classes_6d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | Message 13 | tnyosc 14 |
15 |
16 |
Searching...
17 |
No Matches
18 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /doc/html/search/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/search/close.png -------------------------------------------------------------------------------- /doc/html/search/defines_68.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | htonll 13 | tnyosc.hpp 14 |
15 |
16 |
Searching...
17 |
No Matches
18 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /doc/html/search/defines_6e.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | ntohll 13 | tnyosc.hpp 14 |
15 |
16 |
Searching...
17 |
No Matches
18 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /doc/html/search/files_74.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | tnyosc.hpp 13 |
14 |
15 |
Searching...
16 |
No Matches
17 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/html/search/functions_61.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | address 13 | tnyosc::Message 14 |
15 |
16 | 25 |
Searching...
26 |
No Matches
27 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /doc/html/search/functions_62.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | Bundle 13 | tnyosc::Bundle 14 |
15 |
16 | 25 |
Searching...
26 |
No Matches
27 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /doc/html/search/functions_63.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 | 18 |
19 |
Searching...
20 |
No Matches
21 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /doc/html/search/functions_64.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | data 13 | 17 |
18 |
19 |
Searching...
20 |
No Matches
21 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /doc/html/search/functions_6d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 | 19 |
Searching...
20 |
No Matches
21 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /doc/html/search/functions_73.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 | 19 |
20 |
21 | set_timetag 22 | tnyosc::Bundle 23 |
24 |
25 |
26 |
27 | size 28 | 32 |
33 |
34 |
Searching...
35 |
No Matches
36 | 42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /doc/html/search/mag_sel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/search/mag_sel.png -------------------------------------------------------------------------------- /doc/html/search/nomatches.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
No Matches
10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /doc/html/search/search.css: -------------------------------------------------------------------------------- 1 | /*---------------- Search Box */ 2 | 3 | #FSearchBox { 4 | float: left; 5 | } 6 | 7 | #searchli { 8 | float: right; 9 | display: block; 10 | width: 170px; 11 | height: 36px; 12 | } 13 | 14 | #MSearchBox { 15 | white-space : nowrap; 16 | position: absolute; 17 | float: none; 18 | display: inline; 19 | margin-top: 8px; 20 | right: 0px; 21 | width: 170px; 22 | z-index: 102; 23 | } 24 | 25 | #MSearchBox .left 26 | { 27 | display:block; 28 | position:absolute; 29 | left:10px; 30 | width:20px; 31 | height:19px; 32 | background:url('search_l.png') no-repeat; 33 | background-position:right; 34 | } 35 | 36 | #MSearchSelect { 37 | display:block; 38 | position:absolute; 39 | width:20px; 40 | height:19px; 41 | } 42 | 43 | .left #MSearchSelect { 44 | left:4px; 45 | } 46 | 47 | .right #MSearchSelect { 48 | right:5px; 49 | } 50 | 51 | #MSearchField { 52 | display:block; 53 | position:absolute; 54 | height:19px; 55 | background:url('search_m.png') repeat-x; 56 | border:none; 57 | width:116px; 58 | margin-left:20px; 59 | padding-left:4px; 60 | color: #909090; 61 | outline: none; 62 | font: 9pt Arial, Verdana, sans-serif; 63 | } 64 | 65 | #FSearchBox #MSearchField { 66 | margin-left:15px; 67 | } 68 | 69 | #MSearchBox .right { 70 | display:block; 71 | position:absolute; 72 | right:10px; 73 | top:0px; 74 | width:20px; 75 | height:19px; 76 | background:url('search_r.png') no-repeat; 77 | background-position:left; 78 | } 79 | 80 | #MSearchClose { 81 | display: none; 82 | position: absolute; 83 | top: 4px; 84 | background : none; 85 | border: none; 86 | margin: 0px 4px 0px 0px; 87 | padding: 0px 0px; 88 | outline: none; 89 | } 90 | 91 | .left #MSearchClose { 92 | left: 6px; 93 | } 94 | 95 | .right #MSearchClose { 96 | right: 2px; 97 | } 98 | 99 | .MSearchBoxActive #MSearchField { 100 | color: #000000; 101 | } 102 | 103 | /*---------------- Search filter selection */ 104 | 105 | #MSearchSelectWindow { 106 | display: none; 107 | position: absolute; 108 | left: 0; top: 0; 109 | border: 1px solid #90A5CE; 110 | background-color: #F9FAFC; 111 | z-index: 1; 112 | padding-top: 4px; 113 | padding-bottom: 4px; 114 | -moz-border-radius: 4px; 115 | -webkit-border-top-left-radius: 4px; 116 | -webkit-border-top-right-radius: 4px; 117 | -webkit-border-bottom-left-radius: 4px; 118 | -webkit-border-bottom-right-radius: 4px; 119 | -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); 120 | } 121 | 122 | .SelectItem { 123 | font: 8pt Arial, Verdana, sans-serif; 124 | padding-left: 2px; 125 | padding-right: 12px; 126 | border: 0px; 127 | } 128 | 129 | span.SelectionMark { 130 | margin-right: 4px; 131 | font-family: monospace; 132 | outline-style: none; 133 | text-decoration: none; 134 | } 135 | 136 | a.SelectItem { 137 | display: block; 138 | outline-style: none; 139 | color: #000000; 140 | text-decoration: none; 141 | padding-left: 6px; 142 | padding-right: 12px; 143 | } 144 | 145 | a.SelectItem:focus, 146 | a.SelectItem:active { 147 | color: #000000; 148 | outline-style: none; 149 | text-decoration: none; 150 | } 151 | 152 | a.SelectItem:hover { 153 | color: #FFFFFF; 154 | background-color: #3D578C; 155 | outline-style: none; 156 | text-decoration: none; 157 | cursor: pointer; 158 | display: block; 159 | } 160 | 161 | /*---------------- Search results window */ 162 | 163 | iframe#MSearchResults { 164 | width: 60ex; 165 | height: 15em; 166 | } 167 | 168 | #MSearchResultsWindow { 169 | display: none; 170 | position: absolute; 171 | left: 0; top: 0; 172 | border: 1px solid #000; 173 | background-color: #EEF1F7; 174 | } 175 | 176 | /* ----------------------------------- */ 177 | 178 | 179 | #SRIndex { 180 | clear:both; 181 | padding-bottom: 15px; 182 | } 183 | 184 | .SREntry { 185 | font-size: 10pt; 186 | padding-left: 1ex; 187 | } 188 | 189 | .SRPage .SREntry { 190 | font-size: 8pt; 191 | padding: 1px 5px; 192 | } 193 | 194 | body.SRPage { 195 | margin: 5px 2px; 196 | } 197 | 198 | .SRChildren { 199 | padding-left: 3ex; padding-bottom: .5em 200 | } 201 | 202 | .SRPage .SRChildren { 203 | display: none; 204 | } 205 | 206 | .SRSymbol { 207 | font-weight: bold; 208 | color: #425E97; 209 | font-family: Arial, Verdana, sans-serif; 210 | text-decoration: none; 211 | outline: none; 212 | } 213 | 214 | a.SRScope { 215 | display: block; 216 | color: #425E97; 217 | font-family: Arial, Verdana, sans-serif; 218 | text-decoration: none; 219 | outline: none; 220 | } 221 | 222 | a.SRSymbol:focus, a.SRSymbol:active, 223 | a.SRScope:focus, a.SRScope:active { 224 | text-decoration: underline; 225 | } 226 | 227 | .SRPage .SRStatus { 228 | padding: 2px 5px; 229 | font-size: 8pt; 230 | font-style: italic; 231 | } 232 | 233 | .SRResult { 234 | display: none; 235 | } 236 | 237 | DIV.searchresults { 238 | margin-left: 10px; 239 | margin-right: 10px; 240 | } 241 | -------------------------------------------------------------------------------- /doc/html/search/search_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/search/search_l.png -------------------------------------------------------------------------------- /doc/html/search/search_m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/search/search_m.png -------------------------------------------------------------------------------- /doc/html/search/search_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/search/search_r.png -------------------------------------------------------------------------------- /doc/html/search/variables_62.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
Loading...
10 |
11 |
12 | bundle 13 | tnyosc::Bundle 14 |
15 |
16 |
Searching...
17 |
No Matches
18 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /doc/html/tab_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/tab_a.png -------------------------------------------------------------------------------- /doc/html/tab_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/tab_b.png -------------------------------------------------------------------------------- /doc/html/tab_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/tab_h.png -------------------------------------------------------------------------------- /doc/html/tab_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tuvwxy/tnyosc/eb0b1b30a1930a7c62bd298e2185114ba6419fc9/doc/html/tab_s.png -------------------------------------------------------------------------------- /doc/html/tabs.css: -------------------------------------------------------------------------------- 1 | .tabs, .tabs2, .tabs3 { 2 | background-image: url('tab_b.png'); 3 | width: 100%; 4 | z-index: 101; 5 | font-size: 13px; 6 | } 7 | 8 | .tabs2 { 9 | font-size: 10px; 10 | } 11 | .tabs3 { 12 | font-size: 9px; 13 | } 14 | 15 | .tablist { 16 | margin: 0; 17 | padding: 0; 18 | display: table; 19 | } 20 | 21 | .tablist li { 22 | float: left; 23 | display: table-cell; 24 | background-image: url('tab_b.png'); 25 | line-height: 36px; 26 | list-style: none; 27 | } 28 | 29 | .tablist a { 30 | display: block; 31 | padding: 0 20px; 32 | font-weight: bold; 33 | background-image:url('tab_s.png'); 34 | background-repeat:no-repeat; 35 | background-position:right; 36 | color: #283A5D; 37 | text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); 38 | text-decoration: none; 39 | outline: none; 40 | } 41 | 42 | .tabs3 .tablist a { 43 | padding: 0 10px; 44 | } 45 | 46 | .tablist a:hover { 47 | background-image: url('tab_h.png'); 48 | background-repeat:repeat-x; 49 | color: #fff; 50 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 51 | text-decoration: none; 52 | } 53 | 54 | .tablist li.current a { 55 | background-image: url('tab_a.png'); 56 | background-repeat:repeat-x; 57 | color: #fff; 58 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 59 | } 60 | -------------------------------------------------------------------------------- /doc/html/tnyosc_09_09_8h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyosc++: tnyosc++.h File Reference 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyosc++ 1
23 |
Tiny Open Sound Control header-only library
24 |
28 |
29 | 52 | 58 |
59 |
60 |
61 | Classes | 62 | Defines | 63 | Typedefs | 64 | Functions
65 |
66 |
tnyosc++.h File Reference
67 |
68 |
69 |
#include <sys/time.h>
70 | #include <arpa/inet.h>
71 | #include <cstddef>
72 | #include <string>
73 | #include <vector>
74 | #include <algorithm>
75 | #include <iostream>
76 | #include <inttypes.h>
77 |
78 |

Go to the source code of this file.

79 | 80 | 82 | 83 | 84 | 86 | 87 | 88 | 90 | 91 | 93 | 96 | 97 | 99 | 101 | 102 | 104 | 105 | 107 | 108 | 110 | 111 | 112 | 113 |

81 | Classes

class  tnyosc::Message
class  tnyosc::Bundle

85 | Defines

#define ntohll(x)
 Convert 64-bit little-endian integer to a big-endian network format.
89 | #define htonll(x)   ntohll(x)
 Convert 64-bit big-endian network format to a little-endian integer.

92 | Typedefs

94 | typedef std::vector< unsigned
95 | char > 
tnyosc::ByteArray
 A byte array type internally used in the tnyosc library.

98 | Functions

100 | int32_t tnyosc::htonf (float x)
 Convert 32-bit float to a big-endian network format.
103 | int64_t tnyosc::htond (double x)
 Convert 64-bit float (double) to a big-endian network format.
106 | double tnyosc::ntohf (int32_t x)
 Convert 32-bit big-endian network format to float.
109 | double tnyosc::ntohd (int64_t x)
 Convert 64-bit big-endian network format to double.
const unsigned char * tnyosc::get_pointer (const ByteArray &array)
uint64_t tnyosc::get_current_ntp_time ()
114 |

Detailed Description

115 |

tnyosc++.h

116 |

The main (and only) tnyosc++ file for creating Open Sound Control 1.0 and 1.1 Specification compliant messages. tnyosc++ provides simple and clean C++ API.

117 |
Author:
Toshiro Yamada
118 |

Define Documentation

119 | 120 |
121 |
122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 |
#define ntohll( x)
131 |
132 |
133 | Value:
(((int64_t)(ntohl((int32_t)((x << 32) >> 32))) << 32) | \
134 |   (uint32_t)ntohl(((int32_t)(x >> 32))))
135 | 
136 |

Convert 64-bit little-endian integer to a big-endian network format.

137 | 138 |
139 |
140 |
141 | 142 | 147 | 148 | 149 |
150 | 153 |
154 | 155 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /doc/html/tnyosc_8hpp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tnyos: tnyosc.hpp File Reference 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 |
17 |
18 | 19 | 20 | 21 | 25 | 26 | 27 |
22 |
tnyos 1
23 |
Tiny header-only library for formatting Open Sound Control messages.
24 |
28 |
29 | 52 | 58 |
59 |
60 |
61 | Classes | 62 | Defines | 63 | Typedefs | 64 | Functions
65 |
66 |
tnyosc.hpp File Reference
67 |
68 |
69 | 70 |

tnyosc main (and only) header file 71 | More...

72 |
#include <sys/time.h>
73 | #include <arpa/inet.h>
74 | #include <cstddef>
75 | #include <string>
76 | #include <vector>
77 | #include <algorithm>
78 | #include <iostream>
79 | #include <inttypes.h>
80 |
81 |

Go to the source code of this file.

82 | 83 | 85 | 86 | 87 | 89 | 90 | 91 | 93 | 94 | 96 | 99 | 100 | 102 | 104 | 105 | 107 | 108 | 110 | 111 | 113 | 114 | 115 | 116 |

84 | Classes

class  tnyosc::Message
class  tnyosc::Bundle

88 | Defines

#define ntohll(x)
 Convert 64-bit little-endian integer to a big-endian network format.
92 | #define htonll(x)   ntohll(x)
 Convert 64-bit big-endian network format to a little-endian integer.

95 | Typedefs

97 | typedef std::vector< unsigned
98 | char > 
tnyosc::ByteArray
 A byte array type internally used in the tnyosc library.

101 | Functions

103 | int32_t tnyosc::htonf (float x)
 Convert 32-bit float to a big-endian network format.
106 | int64_t tnyosc::htond (double x)
 Convert 64-bit float (double) to a big-endian network format.
109 | double tnyosc::ntohf (int32_t x)
 Convert 32-bit big-endian network format to float.
112 | double tnyosc::ntohd (int64_t x)
 Convert 64-bit big-endian network format to double.
const unsigned char * tnyosc::get_pointer (const ByteArray &array)
uint64_t tnyosc::get_current_ntp_time ()
117 |

Detailed Description

118 |

tnyosc main (and only) header file

119 |
Author:
Toshiro Yamada
120 |

tnyosc is a header-only Open Sound Control library written in C++ for creating OSC-compliant messages. tnyosc supports Open Sound Control 1.0 and 1.1 types and other nonstandard types, and bundles. Note that tnyosc does not include code to actually send or receive OSC messages.

121 |

Define Documentation

122 | 123 |
124 |
125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 |
#define ntohll( x)
134 |
135 |
136 | Value:
(((int64_t)(ntohl((int32_t)((x << 32) >> 32))) << 32) | \
137 |   (uint32_t)ntohl(((int32_t)(x >> 32))))
138 | 
139 |

Convert 64-bit little-endian integer to a big-endian network format.

140 | 141 |
142 |
143 |
144 | 145 | 150 | 151 | 152 |
153 | 156 |
157 | 158 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /doc/latex/Makefile: -------------------------------------------------------------------------------- 1 | all: refman.pdf 2 | 3 | pdf: refman.pdf 4 | 5 | refman.pdf: clean refman.tex 6 | pdflatex refman.tex 7 | makeindex refman.idx 8 | pdflatex refman.tex 9 | latex_count=5 ; \ 10 | while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\ 11 | do \ 12 | echo "Rerunning latex...." ;\ 13 | pdflatex refman.tex ;\ 14 | latex_count=`expr $$latex_count - 1` ;\ 15 | done 16 | 17 | 18 | clean: 19 | rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out refman.pdf 20 | -------------------------------------------------------------------------------- /doc/latex/annotated.tex: -------------------------------------------------------------------------------- 1 | \section{Class List} 2 | Here are the classes, structs, unions and interfaces with brief descriptions:\begin{DoxyCompactList} 3 | \item\contentsline{section}{\hyperlink{classtnyosc_1_1_bundle}{tnyosc::Bundle} }{\pageref{classtnyosc_1_1_bundle}}{} 4 | \item\contentsline{section}{\hyperlink{classtnyosc_1_1_message}{tnyosc::Message} }{\pageref{classtnyosc_1_1_message}}{} 5 | \end{DoxyCompactList} 6 | -------------------------------------------------------------------------------- /doc/latex/classtnyosc_1_1_bundle.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{classtnyosc_1_1_bundle}{ 2 | \section{tnyosc::Bundle Class Reference} 3 | \label{classtnyosc_1_1_bundle}\index{tnyosc::Bundle@{tnyosc::Bundle}} 4 | } 5 | 6 | 7 | {\ttfamily \#include $<$tnyosc.hpp$>$} 8 | 9 | \subsection*{Public Member Functions} 10 | \begin{DoxyCompactItemize} 11 | \item 12 | \hyperlink{classtnyosc_1_1_bundle_a7075e725afb3941ed1af164d4f4f656f}{Bundle} () 13 | \item 14 | void \hyperlink{classtnyosc_1_1_bundle_aecc352135263bd0c1984818d342c09b5}{set\_\-timetag} (uint64\_\-t ntp\_\-time) 15 | \item 16 | const ByteArray \& \hyperlink{classtnyosc_1_1_bundle_a115f4db940bb1a04cd9a2c60fdaa039f}{byte\_\-array} () const 17 | \item 18 | const unsigned char $\ast$ \hyperlink{classtnyosc_1_1_bundle_a1df649f2cd0748a7159ea3081dae42b2}{data} () const 19 | \item 20 | size\_\-t \hyperlink{classtnyosc_1_1_bundle_ae172d6cdb7440822f84291c8b96fb00d}{size} () const 21 | \item 22 | \hypertarget{classtnyosc_1_1_bundle_a58ad8eb671f250bc3fa524007f741254}{ 23 | void \hyperlink{classtnyosc_1_1_bundle_a58ad8eb671f250bc3fa524007f741254}{clear} ()} 24 | \label{classtnyosc_1_1_bundle_a58ad8eb671f250bc3fa524007f741254} 25 | 26 | \begin{DoxyCompactList}\small\item\em Clears the bundle. \end{DoxyCompactList}\end{DoxyCompactItemize} 27 | \begin{Indent}\paragraph*{Functions for adding Message or Bundle.} 28 | \begin{DoxyCompactItemize} 29 | \item 30 | void \hyperlink{classtnyosc_1_1_bundle_a332d2dae00a991280864834cddc9d0f0}{append} (const \hyperlink{classtnyosc_1_1_message}{Message} $\ast$message) 31 | \item 32 | void \hyperlink{classtnyosc_1_1_bundle_a205a5cc78f1abe251924181ec30411e6}{append} (const \hyperlink{classtnyosc_1_1_bundle}{Bundle} $\ast$bundle) 33 | \item 34 | \hypertarget{classtnyosc_1_1_bundle_a8c27d0978c0c033689ea1e00be1db51f}{ 35 | void {\bfseries append} (const \hyperlink{classtnyosc_1_1_message}{Message} \&message)} 36 | \label{classtnyosc_1_1_bundle_a8c27d0978c0c033689ea1e00be1db51f} 37 | 38 | \item 39 | \hypertarget{classtnyosc_1_1_bundle_af189fcf14ac84cbf21d04d5a04fc3b51}{ 40 | void {\bfseries append} (const \hyperlink{classtnyosc_1_1_bundle}{Bundle} \&bundle)} 41 | \label{classtnyosc_1_1_bundle_af189fcf14ac84cbf21d04d5a04fc3b51} 42 | 43 | \end{DoxyCompactItemize} 44 | \end{Indent} 45 | 46 | 47 | \subsection{Detailed Description} 48 | This class represents an Open Sound Control bundle message. A bundle can contain any number of \hyperlink{classtnyosc_1_1_message}{Message} and \hyperlink{classtnyosc_1_1_bundle}{Bundle}. 49 | 50 | \subsection{Constructor \& Destructor Documentation} 51 | \hypertarget{classtnyosc_1_1_bundle_a7075e725afb3941ed1af164d4f4f656f}{ 52 | \index{tnyosc::Bundle@{tnyosc::Bundle}!Bundle@{Bundle}} 53 | \index{Bundle@{Bundle}!tnyosc::Bundle@{tnyosc::Bundle}} 54 | \subsubsection[{Bundle}]{\setlength{\rightskip}{0pt plus 5cm}tnyosc::Bundle::Bundle ( 55 | \begin{DoxyParamCaption} 56 | {} 57 | \end{DoxyParamCaption} 58 | )\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 59 | \label{classtnyosc_1_1_bundle_a7075e725afb3941ed1af164d4f4f656f} 60 | Creates a OSC bundle with timestamp set to immediate. Call set\_\-timetag to set a custom timestamp. 61 | 62 | \subsection{Member Function Documentation} 63 | \hypertarget{classtnyosc_1_1_bundle_a332d2dae00a991280864834cddc9d0f0}{ 64 | \index{tnyosc::Bundle@{tnyosc::Bundle}!append@{append}} 65 | \index{append@{append}!tnyosc::Bundle@{tnyosc::Bundle}} 66 | \subsubsection[{append}]{\setlength{\rightskip}{0pt plus 5cm}void tnyosc::Bundle::append ( 67 | \begin{DoxyParamCaption} 68 | \item[{const {\bf Message} $\ast$}]{message} 69 | \end{DoxyParamCaption} 70 | )\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 71 | \label{classtnyosc_1_1_bundle_a332d2dae00a991280864834cddc9d0f0} 72 | Appends an OSC message to this bundle. The message is immediately copied into this bundle and any changes to the message after the call to this function does not affect this bundle. 73 | 74 | 75 | \begin{DoxyParams}[1]{Parameters} 76 | \mbox{\tt in} & {\em message} & A pointer to \hyperlink{classtnyosc_1_1_message}{tnyosc::Message}. \\ 77 | \hline 78 | \end{DoxyParams} 79 | \hypertarget{classtnyosc_1_1_bundle_a205a5cc78f1abe251924181ec30411e6}{ 80 | \index{tnyosc::Bundle@{tnyosc::Bundle}!append@{append}} 81 | \index{append@{append}!tnyosc::Bundle@{tnyosc::Bundle}} 82 | \subsubsection[{append}]{\setlength{\rightskip}{0pt plus 5cm}void tnyosc::Bundle::append ( 83 | \begin{DoxyParamCaption} 84 | \item[{const {\bf Bundle} $\ast$}]{bundle} 85 | \end{DoxyParamCaption} 86 | )\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 87 | \label{classtnyosc_1_1_bundle_a205a5cc78f1abe251924181ec30411e6} 88 | Appends an OSC bundle to this bundle. The bundle may include any number of messages or bundles and are immediately copied into this bundle. Any changes to the bundle \hypertarget{classtnyosc_1_1_bundle_a115f4db940bb1a04cd9a2c60fdaa039f}{ 89 | \index{tnyosc::Bundle@{tnyosc::Bundle}!byte\_\-array@{byte\_\-array}} 90 | \index{byte\_\-array@{byte\_\-array}!tnyosc::Bundle@{tnyosc::Bundle}} 91 | \subsubsection[{byte\_\-array}]{\setlength{\rightskip}{0pt plus 5cm}const ByteArray\& tnyosc::Bundle::byte\_\-array ( 92 | \begin{DoxyParamCaption} 93 | {} 94 | \end{DoxyParamCaption} 95 | ) const\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 96 | \label{classtnyosc_1_1_bundle_a115f4db940bb1a04cd9a2c60fdaa039f} 97 | Returns a complete byte array of this OSC bundle as a tnyosc::ByteArray type. 98 | 99 | \begin{DoxyReturn}{Returns} 100 | The OSC bundle as a tnyosc::ByteArray. 101 | \end{DoxyReturn} 102 | \begin{DoxySeeAlso}{See also} 103 | \hyperlink{classtnyosc_1_1_bundle_a1df649f2cd0748a7159ea3081dae42b2}{data} 104 | 105 | \hyperlink{classtnyosc_1_1_bundle_ae172d6cdb7440822f84291c8b96fb00d}{size} 106 | \end{DoxySeeAlso} 107 | \hypertarget{classtnyosc_1_1_bundle_a1df649f2cd0748a7159ea3081dae42b2}{ 108 | \index{tnyosc::Bundle@{tnyosc::Bundle}!data@{data}} 109 | \index{data@{data}!tnyosc::Bundle@{tnyosc::Bundle}} 110 | \subsubsection[{data}]{\setlength{\rightskip}{0pt plus 5cm}const unsigned char$\ast$ tnyosc::Bundle::data ( 111 | \begin{DoxyParamCaption} 112 | {} 113 | \end{DoxyParamCaption} 114 | ) const\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 115 | \label{classtnyosc_1_1_bundle_a1df649f2cd0748a7159ea3081dae42b2} 116 | Returns a pointer to the byte array of this OSC bundle. This call is convenient for actually sending this OSC bundle. 117 | 118 | \begin{DoxyReturn}{Returns} 119 | The OSC bundle as an unsigned char$\ast$. 120 | \end{DoxyReturn} 121 | \begin{DoxySeeAlso}{See also} 122 | \hyperlink{classtnyosc_1_1_bundle_a115f4db940bb1a04cd9a2c60fdaa039f}{byte\_\-array} 123 | 124 | \hyperlink{classtnyosc_1_1_bundle_ae172d6cdb7440822f84291c8b96fb00d}{size} 125 | \end{DoxySeeAlso} 126 | 127 | \begin{DoxyPre} 128 | int sockfd; // initialize UDP socket... 129 | \hyperlink{classtnyosc_1_1_bundle}{tnyosc::Bundle}* bundle; // create a OSC bundle... 130 | send\_to(sockfd, bundle->\hyperlink{classtnyosc_1_1_bundle_a1df649f2cd0748a7159ea3081dae42b2}{data()}, bundle->\hyperlink{classtnyosc_1_1_bundle_ae172d6cdb7440822f84291c8b96fb00d}{size()}, 0); 131 | \end{DoxyPre} 132 | \hypertarget{classtnyosc_1_1_bundle_aecc352135263bd0c1984818d342c09b5}{ 133 | \index{tnyosc::Bundle@{tnyosc::Bundle}!set\_\-timetag@{set\_\-timetag}} 134 | \index{set\_\-timetag@{set\_\-timetag}!tnyosc::Bundle@{tnyosc::Bundle}} 135 | \subsubsection[{set\_\-timetag}]{\setlength{\rightskip}{0pt plus 5cm}void tnyosc::Bundle::set\_\-timetag ( 136 | \begin{DoxyParamCaption} 137 | \item[{uint64\_\-t}]{ntp\_\-time} 138 | \end{DoxyParamCaption} 139 | )\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 140 | \label{classtnyosc_1_1_bundle_aecc352135263bd0c1984818d342c09b5} 141 | Sets timestamp of the bundle. 142 | 143 | 144 | \begin{DoxyParams}[1]{Parameters} 145 | \mbox{\tt in} & {\em ntp\_\-time} & NTP Timestamp \\ 146 | \hline 147 | \end{DoxyParams} 148 | \begin{DoxySeeAlso}{See also} 149 | get\_\-current\_\-ntp\_\-time 150 | \end{DoxySeeAlso} 151 | \hypertarget{classtnyosc_1_1_bundle_ae172d6cdb7440822f84291c8b96fb00d}{ 152 | \index{tnyosc::Bundle@{tnyosc::Bundle}!size@{size}} 153 | \index{size@{size}!tnyosc::Bundle@{tnyosc::Bundle}} 154 | \subsubsection[{size}]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t tnyosc::Bundle::size ( 155 | \begin{DoxyParamCaption} 156 | {} 157 | \end{DoxyParamCaption} 158 | ) const\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 159 | \label{classtnyosc_1_1_bundle_ae172d6cdb7440822f84291c8b96fb00d} 160 | Returns the size of this OSC bundle. 161 | 162 | \begin{DoxyReturn}{Returns} 163 | Size of the OSC bundle in bytes. 164 | \end{DoxyReturn} 165 | \begin{DoxySeeAlso}{See also} 166 | \hyperlink{classtnyosc_1_1_bundle_a115f4db940bb1a04cd9a2c60fdaa039f}{byte\_\-array} 167 | 168 | \hyperlink{classtnyosc_1_1_bundle_a1df649f2cd0748a7159ea3081dae42b2}{data} 169 | \end{DoxySeeAlso} 170 | 171 | 172 | The documentation for this class was generated from the following file:\begin{DoxyCompactItemize} 173 | \item 174 | \hyperlink{tnyosc_8hpp}{tnyosc.hpp}\end{DoxyCompactItemize} 175 | -------------------------------------------------------------------------------- /doc/latex/classtnyosc_1_1_message.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{classtnyosc_1_1_message}{ 2 | \section{tnyosc::Message Class Reference} 3 | \label{classtnyosc_1_1_message}\index{tnyosc::Message@{tnyosc::Message}} 4 | } 5 | 6 | 7 | {\ttfamily \#include $<$tnyosc.hpp$>$} 8 | 9 | \subsection*{Public Member Functions} 10 | \begin{DoxyCompactItemize} 11 | \item 12 | \hyperlink{classtnyosc_1_1_message_ac88e868ab5c1f59193c1d2cef1679e16}{Message} (const std::string \&address=\char`\"{}/tnyosc\char`\"{}) 13 | \item 14 | \hyperlink{classtnyosc_1_1_message_ae17d6dd92a0da1ac47996501f887ae6e}{Message} (const char $\ast$address) 15 | \item 16 | void \hyperlink{classtnyosc_1_1_message_aa7ce6c220f685e5ad0402fecdb4403d4}{set\_\-address} (const std::string \&address) 17 | \item 18 | void \hyperlink{classtnyosc_1_1_message_a38183562956c663f825b71cf2563a41a}{set\_\-address} (const char $\ast$address) 19 | \item 20 | \hypertarget{classtnyosc_1_1_message_ad2ea4fa41da0ece7d1c218b88a6ee69e}{ 21 | const std::string \& \hyperlink{classtnyosc_1_1_message_ad2ea4fa41da0ece7d1c218b88a6ee69e}{address} () const } 22 | \label{classtnyosc_1_1_message_ad2ea4fa41da0ece7d1c218b88a6ee69e} 23 | 24 | \begin{DoxyCompactList}\small\item\em Returns the OSC address of this message. \end{DoxyCompactList}\item 25 | const ByteArray \& \hyperlink{classtnyosc_1_1_message_afd10bfa0c1e18f7b0ea10072acbb6618}{byte\_\-array} () const 26 | \item 27 | const unsigned char $\ast$ \hyperlink{classtnyosc_1_1_message_aa0ccc0dcd1bde1a59b9260f78c68ec1c}{data} () const 28 | \item 29 | size\_\-t \hyperlink{classtnyosc_1_1_message_ad146e1b298d0a8ff5fcc7f8234af5806}{size} () const 30 | \item 31 | \hypertarget{classtnyosc_1_1_message_ace39585edd14ff52ec60f25101bcfc71}{ 32 | void \hyperlink{classtnyosc_1_1_message_ace39585edd14ff52ec60f25101bcfc71}{clear} ()} 33 | \label{classtnyosc_1_1_message_ace39585edd14ff52ec60f25101bcfc71} 34 | 35 | \begin{DoxyCompactList}\small\item\em Clears the message. \end{DoxyCompactList}\end{DoxyCompactItemize} 36 | \begin{Indent}\paragraph*{Functions for adding OSC 1.0 types} 37 | \begin{DoxyCompactItemize} 38 | \item 39 | \hypertarget{classtnyosc_1_1_message_ab12726122ccf535f65022ff6f88dd838}{ 40 | void {\bfseries append} (int32\_\-t v)} 41 | \label{classtnyosc_1_1_message_ab12726122ccf535f65022ff6f88dd838} 42 | 43 | \item 44 | \hypertarget{classtnyosc_1_1_message_a2a1d45d1e2877dc69fd4ec162ecad237}{ 45 | void {\bfseries append} (float v)} 46 | \label{classtnyosc_1_1_message_a2a1d45d1e2877dc69fd4ec162ecad237} 47 | 48 | \item 49 | \hypertarget{classtnyosc_1_1_message_ad66a2b9af7da82725f0a0ceb6969e18a}{ 50 | void {\bfseries append} (const std::string \&v)} 51 | \label{classtnyosc_1_1_message_ad66a2b9af7da82725f0a0ceb6969e18a} 52 | 53 | \item 54 | \hypertarget{classtnyosc_1_1_message_a74da2a0e90e0485551a678d401d0f756}{ 55 | void {\bfseries append\_\-cstring} (const char $\ast$v, size\_\-t len)} 56 | \label{classtnyosc_1_1_message_a74da2a0e90e0485551a678d401d0f756} 57 | 58 | \item 59 | \hypertarget{classtnyosc_1_1_message_a94cdec76e625fd4a8f11c250b16a3021}{ 60 | void {\bfseries append\_\-blob} (void $\ast$blob, uint32\_\-t size)} 61 | \label{classtnyosc_1_1_message_a94cdec76e625fd4a8f11c250b16a3021} 62 | 63 | \end{DoxyCompactItemize} 64 | \end{Indent} 65 | \begin{Indent}\paragraph*{Functions for adding OSC 1.1 types} 66 | \begin{DoxyCompactItemize} 67 | \item 68 | \hypertarget{classtnyosc_1_1_message_ac9a236c7448f943336fdcd3d9ebc576a}{ 69 | void {\bfseries append\_\-time} (uint64\_\-t v)} 70 | \label{classtnyosc_1_1_message_ac9a236c7448f943336fdcd3d9ebc576a} 71 | 72 | \item 73 | \hypertarget{classtnyosc_1_1_message_a8695434364583e24ca146a57f061887f}{ 74 | void {\bfseries append\_\-current\_\-time} ()} 75 | \label{classtnyosc_1_1_message_a8695434364583e24ca146a57f061887f} 76 | 77 | \item 78 | \hypertarget{classtnyosc_1_1_message_a94b1ad3271cd739a46841842edbc01bf}{ 79 | void {\bfseries append\_\-true} ()} 80 | \label{classtnyosc_1_1_message_a94b1ad3271cd739a46841842edbc01bf} 81 | 82 | \item 83 | \hypertarget{classtnyosc_1_1_message_a931f270eda78ee387ce4113a278c332e}{ 84 | void {\bfseries append\_\-false} ()} 85 | \label{classtnyosc_1_1_message_a931f270eda78ee387ce4113a278c332e} 86 | 87 | \item 88 | \hypertarget{classtnyosc_1_1_message_a1f8fce2c36c6dfd71dbe1a4be98808f5}{ 89 | void {\bfseries append\_\-null} ()} 90 | \label{classtnyosc_1_1_message_a1f8fce2c36c6dfd71dbe1a4be98808f5} 91 | 92 | \item 93 | \hypertarget{classtnyosc_1_1_message_a537913b8fe3afdd10400d6f293b05ee3}{ 94 | void {\bfseries append\_\-impulse} ()} 95 | \label{classtnyosc_1_1_message_a537913b8fe3afdd10400d6f293b05ee3} 96 | 97 | \end{DoxyCompactItemize} 98 | \end{Indent} 99 | \begin{Indent}\paragraph*{Functions for adding nonstandard types} 100 | \begin{DoxyCompactItemize} 101 | \item 102 | \hypertarget{classtnyosc_1_1_message_a344fd2f6ce98f1f1cf54550935d4f243}{ 103 | void {\bfseries append} (int64\_\-t v)} 104 | \label{classtnyosc_1_1_message_a344fd2f6ce98f1f1cf54550935d4f243} 105 | 106 | \item 107 | \hypertarget{classtnyosc_1_1_message_ad27ee1707ed53c12f68ee240922f3f38}{ 108 | void {\bfseries append} (double v)} 109 | \label{classtnyosc_1_1_message_ad27ee1707ed53c12f68ee240922f3f38} 110 | 111 | \item 112 | \hypertarget{classtnyosc_1_1_message_acc66286a734cc729c2e1e6e6fc7fe627}{ 113 | void {\bfseries append} (char v)} 114 | \label{classtnyosc_1_1_message_acc66286a734cc729c2e1e6e6fc7fe627} 115 | 116 | \item 117 | \hypertarget{classtnyosc_1_1_message_a192950fd01f9eb3d991d70b1720da61b}{ 118 | void {\bfseries append\_\-midi} (uint8\_\-t port, uint8\_\-t status, uint8\_\-t data1, uint8\_\-t data2)} 119 | \label{classtnyosc_1_1_message_a192950fd01f9eb3d991d70b1720da61b} 120 | 121 | \item 122 | \hypertarget{classtnyosc_1_1_message_aaa23ef199fcdf34016aeb98ec08a5d56}{ 123 | void {\bfseries append\_\-array} (void $\ast$array, size\_\-t size)} 124 | \label{classtnyosc_1_1_message_aaa23ef199fcdf34016aeb98ec08a5d56} 125 | 126 | \end{DoxyCompactItemize} 127 | \end{Indent} 128 | 129 | 130 | \subsection{Detailed Description} 131 | This class represents an Open Sound Control message. It supports Open Sound Control 1.0 and 1.1 specifications and extra non-\/standard arguments listed in \href{http://opensoundcontrol.org/spec-1_0.}{\tt http://opensoundcontrol.org/spec-\/1\_\-0.} 132 | 133 | \subsection{Constructor \& Destructor Documentation} 134 | \hypertarget{classtnyosc_1_1_message_ac88e868ab5c1f59193c1d2cef1679e16}{ 135 | \index{tnyosc::Message@{tnyosc::Message}!Message@{Message}} 136 | \index{Message@{Message}!tnyosc::Message@{tnyosc::Message}} 137 | \subsubsection[{Message}]{\setlength{\rightskip}{0pt plus 5cm}tnyosc::Message::Message ( 138 | \begin{DoxyParamCaption} 139 | \item[{const std::string \&}]{address = {\ttfamily \char`\"{}/tnyosc\char`\"{}}} 140 | \end{DoxyParamCaption} 141 | )\hspace{0.3cm}{\ttfamily \mbox{[}inline, explicit\mbox{]}}}} 142 | \label{classtnyosc_1_1_message_ac88e868ab5c1f59193c1d2cef1679e16} 143 | Create an OSC message. If address is not given, default OSC address is set to \char`\"{}/tnyosc\char`\"{}. \hypertarget{classtnyosc_1_1_message_ae17d6dd92a0da1ac47996501f887ae6e}{ 144 | \index{tnyosc::Message@{tnyosc::Message}!Message@{Message}} 145 | \index{Message@{Message}!tnyosc::Message@{tnyosc::Message}} 146 | \subsubsection[{Message}]{\setlength{\rightskip}{0pt plus 5cm}tnyosc::Message::Message ( 147 | \begin{DoxyParamCaption} 148 | \item[{const char $\ast$}]{address} 149 | \end{DoxyParamCaption} 150 | )\hspace{0.3cm}{\ttfamily \mbox{[}inline, explicit\mbox{]}}}} 151 | \label{classtnyosc_1_1_message_ae17d6dd92a0da1ac47996501f887ae6e} 152 | Create an OSC message. This function is called if \hyperlink{classtnyosc_1_1_message}{Message} is created with a C string. 153 | 154 | \subsection{Member Function Documentation} 155 | \hypertarget{classtnyosc_1_1_message_afd10bfa0c1e18f7b0ea10072acbb6618}{ 156 | \index{tnyosc::Message@{tnyosc::Message}!byte\_\-array@{byte\_\-array}} 157 | \index{byte\_\-array@{byte\_\-array}!tnyosc::Message@{tnyosc::Message}} 158 | \subsubsection[{byte\_\-array}]{\setlength{\rightskip}{0pt plus 5cm}const ByteArray\& tnyosc::Message::byte\_\-array ( 159 | \begin{DoxyParamCaption} 160 | {} 161 | \end{DoxyParamCaption} 162 | ) const\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 163 | \label{classtnyosc_1_1_message_afd10bfa0c1e18f7b0ea10072acbb6618} 164 | Returns a complete byte array of this OSC message as a ByteArray type. The byte array is constructed lazily and is cached until the cache is obsolete. Call to $|$data$|$ and $|$size$|$ perform the same caching. 165 | 166 | \begin{DoxyReturn}{Returns} 167 | The OSC message as a ByteArray. 168 | \end{DoxyReturn} 169 | \begin{DoxySeeAlso}{See also} 170 | \hyperlink{classtnyosc_1_1_message_aa0ccc0dcd1bde1a59b9260f78c68ec1c}{data} 171 | 172 | \hyperlink{classtnyosc_1_1_message_ad146e1b298d0a8ff5fcc7f8234af5806}{size} 173 | \end{DoxySeeAlso} 174 | \hypertarget{classtnyosc_1_1_message_aa0ccc0dcd1bde1a59b9260f78c68ec1c}{ 175 | \index{tnyosc::Message@{tnyosc::Message}!data@{data}} 176 | \index{data@{data}!tnyosc::Message@{tnyosc::Message}} 177 | \subsubsection[{data}]{\setlength{\rightskip}{0pt plus 5cm}const unsigned char$\ast$ tnyosc::Message::data ( 178 | \begin{DoxyParamCaption} 179 | {} 180 | \end{DoxyParamCaption} 181 | ) const\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 182 | \label{classtnyosc_1_1_message_aa0ccc0dcd1bde1a59b9260f78c68ec1c} 183 | Returns a complete byte array of this OSC message as a unsigned char pointer. This call is convenient for actually sending this OSC messager. 184 | 185 | \begin{DoxyReturn}{Returns} 186 | The OSC message as an unsigned char$\ast$. 187 | \end{DoxyReturn} 188 | \begin{DoxySeeAlso}{See also} 189 | \hyperlink{classtnyosc_1_1_message_afd10bfa0c1e18f7b0ea10072acbb6618}{byte\_\-array} 190 | 191 | \hyperlink{classtnyosc_1_1_message_ad146e1b298d0a8ff5fcc7f8234af5806}{size} 192 | \end{DoxySeeAlso} 193 | 194 | \begin{DoxyPre} 195 | int sockfd; // initialize a socket... 196 | \hyperlink{classtnyosc_1_1_message}{tnyosc::Message}* msg; // create a OSC message... 197 | send\_to(sockfd, msg->\hyperlink{classtnyosc_1_1_message_aa0ccc0dcd1bde1a59b9260f78c68ec1c}{data()}, msg->\hyperlink{classtnyosc_1_1_message_ad146e1b298d0a8ff5fcc7f8234af5806}{size()}, 0); 198 | \end{DoxyPre} 199 | \hypertarget{classtnyosc_1_1_message_a38183562956c663f825b71cf2563a41a}{ 200 | \index{tnyosc::Message@{tnyosc::Message}!set\_\-address@{set\_\-address}} 201 | \index{set\_\-address@{set\_\-address}!tnyosc::Message@{tnyosc::Message}} 202 | \subsubsection[{set\_\-address}]{\setlength{\rightskip}{0pt plus 5cm}void tnyosc::Message::set\_\-address ( 203 | \begin{DoxyParamCaption} 204 | \item[{const char $\ast$}]{address} 205 | \end{DoxyParamCaption} 206 | )\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 207 | \label{classtnyosc_1_1_message_a38183562956c663f825b71cf2563a41a} 208 | Sets the OSC address of this message. 209 | \begin{DoxyParams}[1]{Parameters} 210 | \mbox{\tt in} & {\em address} & The new OSC address. \\ 211 | \hline 212 | \end{DoxyParams} 213 | \hypertarget{classtnyosc_1_1_message_aa7ce6c220f685e5ad0402fecdb4403d4}{ 214 | \index{tnyosc::Message@{tnyosc::Message}!set\_\-address@{set\_\-address}} 215 | \index{set\_\-address@{set\_\-address}!tnyosc::Message@{tnyosc::Message}} 216 | \subsubsection[{set\_\-address}]{\setlength{\rightskip}{0pt plus 5cm}void tnyosc::Message::set\_\-address ( 217 | \begin{DoxyParamCaption} 218 | \item[{const std::string \&}]{address} 219 | \end{DoxyParamCaption} 220 | )\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 221 | \label{classtnyosc_1_1_message_aa7ce6c220f685e5ad0402fecdb4403d4} 222 | Sets the OSC address of this message. 223 | \begin{DoxyParams}[1]{Parameters} 224 | \mbox{\tt in} & {\em address} & The new OSC address. \\ 225 | \hline 226 | \end{DoxyParams} 227 | \hypertarget{classtnyosc_1_1_message_ad146e1b298d0a8ff5fcc7f8234af5806}{ 228 | \index{tnyosc::Message@{tnyosc::Message}!size@{size}} 229 | \index{size@{size}!tnyosc::Message@{tnyosc::Message}} 230 | \subsubsection[{size}]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t tnyosc::Message::size ( 231 | \begin{DoxyParamCaption} 232 | {} 233 | \end{DoxyParamCaption} 234 | ) const\hspace{0.3cm}{\ttfamily \mbox{[}inline\mbox{]}}}} 235 | \label{classtnyosc_1_1_message_ad146e1b298d0a8ff5fcc7f8234af5806} 236 | Returns the size of this OSC message. 237 | 238 | \begin{DoxyReturn}{Returns} 239 | Size of the OSC message in bytes. 240 | \end{DoxyReturn} 241 | \begin{DoxySeeAlso}{See also} 242 | \hyperlink{classtnyosc_1_1_message_afd10bfa0c1e18f7b0ea10072acbb6618}{byte\_\-array} 243 | 244 | \hyperlink{classtnyosc_1_1_message_aa0ccc0dcd1bde1a59b9260f78c68ec1c}{data} 245 | \end{DoxySeeAlso} 246 | 247 | 248 | The documentation for this class was generated from the following file:\begin{DoxyCompactItemize} 249 | \item 250 | \hyperlink{tnyosc_8hpp}{tnyosc.hpp}\end{DoxyCompactItemize} 251 | -------------------------------------------------------------------------------- /doc/latex/doxygen.sty: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e} 2 | \ProvidesPackage{doxygen} 3 | 4 | % Packages used by this style file 5 | \RequirePackage{alltt} 6 | \RequirePackage{array} 7 | \RequirePackage{calc} 8 | \RequirePackage{color} 9 | \RequirePackage{fancyhdr} 10 | \RequirePackage{longtable} 11 | \RequirePackage{verbatim} 12 | \RequirePackage{ifthen} 13 | \RequirePackage[table]{xcolor} 14 | 15 | % Use helvetica font instead of times roman 16 | \RequirePackage{helvet} 17 | \RequirePackage{sectsty} 18 | \RequirePackage{tocloft} 19 | \providecommand{\rmdefault}{phv} 20 | \providecommand{\bfdefault}{bc} 21 | 22 | 23 | % Setup fancy headings 24 | \pagestyle{fancyplain} 25 | \newcommand{\clearemptydoublepage}{% 26 | \newpage{\pagestyle{empty}\cleardoublepage}% 27 | } 28 | \renewcommand{\chaptermark}[1]{% 29 | \markboth{#1}{}% 30 | } 31 | \renewcommand{\sectionmark}[1]{% 32 | \markright{\thesection\ #1}% 33 | } 34 | \fancyhead[LE]{\fancyplain{}{\bfseries\thepage}} 35 | \fancyhead[CE]{\fancyplain{}{}} 36 | \fancyhead[RE]{\fancyplain{}{\bfseries\leftmark}} 37 | \fancyhead[LO]{\fancyplain{}{\bfseries\rightmark}} 38 | \fancyhead[CO]{\fancyplain{}{}} 39 | \fancyhead[RO]{\fancyplain{}{\bfseries\thepage}} 40 | \fancyfoot[LE]{\fancyplain{}{}} 41 | \fancyfoot[CE]{\fancyplain{}{}} 42 | \fancyfoot[RE]{\fancyplain{}{\bfseries\scriptsize Generated on Tue Jul 26 2011 13:02:02 for tnyos by Doxygen }} 43 | \fancyfoot[LO]{\fancyplain{}{\bfseries\scriptsize Generated on Tue Jul 26 2011 13:02:02 for tnyos by Doxygen }} 44 | \fancyfoot[CO]{\fancyplain{}{}} 45 | \fancyfoot[RO]{\fancyplain{}{}} 46 | %---------- Internal commands used in this style file ---------------- 47 | 48 | % Generic environment used by all paragraph-based environments defined 49 | % below. Note that the command \title{...} needs to be defined inside 50 | % those environments! 51 | \newenvironment{DoxyDesc}[1]{% 52 | \begin{list}{}% 53 | {% 54 | \settowidth{\labelwidth}{40pt}% 55 | \setlength{\leftmargin}{\labelwidth}% 56 | \setlength{\parsep}{0pt}% 57 | \setlength{\itemsep}{-4pt}% 58 | \renewcommand{\makelabel}{\entrylabel}% 59 | }% 60 | \item[#1]% 61 | }{% 62 | \end{list}% 63 | } 64 | 65 | %---------- Commands used by doxygen LaTeX output generator ---------- 66 | 67 | % Used by
 ... 
68 | \newenvironment{DoxyPre}{% 69 | \small% 70 | \begin{alltt}% 71 | }{% 72 | \end{alltt}% 73 | \normalsize% 74 | } 75 | 76 | % Used by @code ... @endcode 77 | \newenvironment{DoxyCode}{% 78 | \footnotesize% 79 | \verbatim% 80 | }{% 81 | \endverbatim% 82 | \normalsize% 83 | } 84 | 85 | % Used by @example, @include, @includelineno and @dontinclude 86 | \newenvironment{DoxyCodeInclude}{% 87 | \DoxyCode% 88 | }{% 89 | \endDoxyCode% 90 | } 91 | 92 | % Used by @verbatim ... @endverbatim 93 | \newenvironment{DoxyVerb}{% 94 | \footnotesize% 95 | \verbatim% 96 | }{% 97 | \endverbatim% 98 | \normalsize% 99 | } 100 | 101 | % Used by @verbinclude 102 | \newenvironment{DoxyVerbInclude}{% 103 | \DoxyVerb% 104 | }{% 105 | \endDoxyVerb% 106 | } 107 | 108 | % Used by numbered lists (using '-#' or
    ...
) 109 | \newenvironment{DoxyEnumerate}{% 110 | \enumerate% 111 | }{% 112 | \endenumerate% 113 | } 114 | 115 | % Used by bullet lists (using '-', @li, @arg, or
    ...
) 116 | \newenvironment{DoxyItemize}{% 117 | \itemize% 118 | }{% 119 | \enditemize% 120 | } 121 | 122 | % Used by description lists (using
...
) 123 | \newenvironment{DoxyDescription}{% 124 | \description% 125 | }{% 126 | \enddescription% 127 | } 128 | 129 | % Used by @image, @dotfile, and @dot ... @enddot 130 | % (only if caption is specified) 131 | \newenvironment{DoxyImage}{% 132 | \begin{figure}[H]% 133 | \begin{center}% 134 | }{% 135 | \end{center}% 136 | \end{figure}% 137 | } 138 | 139 | % Used by @image, @dotfile, @dot ... @enddot, and @msc ... @endmsc 140 | % (only if no caption is specified) 141 | \newenvironment{DoxyImageNoCaption}{% 142 | }{% 143 | } 144 | 145 | % Used by @attention 146 | \newenvironment{DoxyAttention}[1]{% 147 | \begin{DoxyDesc}{#1}% 148 | }{% 149 | \end{DoxyDesc}% 150 | } 151 | 152 | % Used by @author and @authors 153 | \newenvironment{DoxyAuthor}[1]{% 154 | \begin{DoxyDesc}{#1}% 155 | }{% 156 | \end{DoxyDesc}% 157 | } 158 | 159 | % Used by @date 160 | \newenvironment{DoxyDate}[1]{% 161 | \begin{DoxyDesc}{#1}% 162 | }{% 163 | \end{DoxyDesc}% 164 | } 165 | 166 | % Used by @invariant 167 | \newenvironment{DoxyInvariant}[1]{% 168 | \begin{DoxyDesc}{#1}% 169 | }{% 170 | \end{DoxyDesc}% 171 | } 172 | 173 | % Used by @note 174 | \newenvironment{DoxyNote}[1]{% 175 | \begin{DoxyDesc}{#1}% 176 | }{% 177 | \end{DoxyDesc}% 178 | } 179 | 180 | % Used by @post 181 | \newenvironment{DoxyPostcond}[1]{% 182 | \begin{DoxyDesc}{#1}% 183 | }{% 184 | \end{DoxyDesc}% 185 | } 186 | 187 | % Used by @pre 188 | \newenvironment{DoxyPrecond}[1]{% 189 | \begin{DoxyDesc}{#1}% 190 | }{% 191 | \end{DoxyDesc}% 192 | } 193 | 194 | % Used by @remark 195 | \newenvironment{DoxyRemark}[1]{% 196 | \begin{DoxyDesc}{#1}% 197 | }{% 198 | \end{DoxyDesc}% 199 | } 200 | 201 | % Used by @return 202 | \newenvironment{DoxyReturn}[1]{% 203 | \begin{DoxyDesc}{#1}% 204 | }{% 205 | \end{DoxyDesc}% 206 | } 207 | 208 | % Used by @since 209 | \newenvironment{DoxySince}[1]{% 210 | \begin{DoxyDesc}{#1}% 211 | }{% 212 | \end{DoxyDesc}% 213 | } 214 | 215 | % Used by @see 216 | \newenvironment{DoxySeeAlso}[1]{% 217 | \begin{DoxyDesc}{#1}% 218 | }{% 219 | \end{DoxyDesc}% 220 | } 221 | 222 | % Used by @version 223 | \newenvironment{DoxyVersion}[1]{% 224 | \begin{DoxyDesc}{#1}% 225 | }{% 226 | \end{DoxyDesc}% 227 | } 228 | 229 | % Used by @warning 230 | \newenvironment{DoxyWarning}[1]{% 231 | \begin{DoxyDesc}{#1}% 232 | }{% 233 | \end{DoxyDesc}% 234 | } 235 | 236 | % Used by @internal 237 | \newenvironment{DoxyInternal}[1]{% 238 | \paragraph*{#1}% 239 | }{% 240 | } 241 | 242 | % Used by @par and @paragraph 243 | \newenvironment{DoxyParagraph}[1]{% 244 | \begin{list}{}% 245 | {% 246 | \settowidth{\labelwidth}{40pt}% 247 | \setlength{\leftmargin}{\labelwidth}% 248 | \setlength{\parsep}{0pt}% 249 | \setlength{\itemsep}{-4pt}% 250 | \renewcommand{\makelabel}{\entrylabel}% 251 | }% 252 | \item[#1]% 253 | }{% 254 | \end{list}% 255 | } 256 | 257 | % Used by parameter lists 258 | \newenvironment{DoxyParams}[2][]{% 259 | \begin{DoxyDesc}{#2}% 260 | \begin{description}% 261 | \item[] \hspace{\fill} \vspace{-25pt}% 262 | \definecolor{tableShade}{HTML}{F8F8F8}% 263 | \rowcolors{1}{white}{tableShade}% 264 | \arrayrulecolor{gray}% 265 | \setlength{\tabcolsep}{0.01\textwidth}% 266 | \ifthenelse{\equal{#1}{}} 267 | {\begin{longtable}{|>{\raggedleft\hspace{0pt}}p{0.15\textwidth}|% 268 | p{0.87\textwidth}|}}% 269 | {\ifthenelse{\equal{#1}{1}}% 270 | {\begin{longtable}{|>{\centering}p{0.10\textwidth}|% 271 | >{\raggedleft\hspace{0pt}}p{0.15\textwidth}|% 272 | p{0.75\textwidth}|}}% 273 | {\begin{longtable}{|>{\centering}p{0.10\textwidth}|% 274 | >{\centering\hspace{0pt}}p{0.15\textwidth}|% 275 | >{\raggedleft\hspace{0pt}}p{0.15\textwidth}|% 276 | p{0.58\textwidth}|}}% 277 | }\hline% 278 | }{% 279 | \end{longtable}% 280 | \end{description}% 281 | \end{DoxyDesc}% 282 | } 283 | 284 | % is used for parameters within a detailed function description 285 | \newenvironment{DoxyParamCaption}{% 286 | \renewcommand{\item}[2][]{##1 {\em ##2}}% 287 | }{% 288 | } 289 | 290 | % Used by return value lists 291 | \newenvironment{DoxyRetVals}[1]{% 292 | \begin{DoxyDesc}{#1}% 293 | \begin{description}% 294 | \item[] \hspace{\fill} \vspace{-25pt}% 295 | \definecolor{tableShade}{HTML}{F8F8F8}% 296 | \rowcolors{1}{white}{tableShade}% 297 | \arrayrulecolor{gray}% 298 | \setlength{\tabcolsep}{0.01\textwidth}% 299 | \begin{longtable}{|>{\raggedleft\hspace{0pt}}p{0.25\textwidth}|% 300 | p{0.77\textwidth}|}% 301 | \hline% 302 | }{% 303 | \end{longtable}% 304 | \end{description}% 305 | \end{DoxyDesc}% 306 | } 307 | 308 | % Used by exception lists 309 | \newenvironment{DoxyExceptions}[1]{% 310 | \begin{DoxyDesc}{#1}% 311 | \begin{description}% 312 | \item[] \hspace{\fill} \vspace{-25pt}% 313 | \definecolor{tableShade}{HTML}{F8F8F8}% 314 | \rowcolors{1}{white}{tableShade}% 315 | \arrayrulecolor{gray}% 316 | \setlength{\tabcolsep}{0.01\textwidth}% 317 | \begin{longtable}{|>{\raggedleft\hspace{0pt}}p{0.25\textwidth}|% 318 | p{0.77\textwidth}|}% 319 | \hline% 320 | }{% 321 | \end{longtable}% 322 | \end{description}% 323 | \end{DoxyDesc}% 324 | } 325 | 326 | % Used by template parameter lists 327 | \newenvironment{DoxyTemplParams}[1]{% 328 | \begin{DoxyDesc}{#1}% 329 | \begin{description}% 330 | \item[] \hspace{\fill} \vspace{-25pt}% 331 | \definecolor{tableShade}{HTML}{F8F8F8}% 332 | \rowcolors{1}{white}{tableShade}% 333 | \arrayrulecolor{gray}% 334 | \setlength{\tabcolsep}{0.01\textwidth}% 335 | \begin{longtable}{|>{\raggedleft\hspace{0pt}}p{0.25\textwidth}|% 336 | p{0.77\textwidth}|}% 337 | \hline% 338 | }{% 339 | \end{longtable}% 340 | \end{description}% 341 | \end{DoxyDesc}% 342 | } 343 | 344 | \newcommand{\doxyref}[3]{\textbf{#1} (\textnormal{#2}\,\pageref{#3})} 345 | \newenvironment{DoxyCompactList} 346 | {\begin{list}{}{ 347 | \setlength{\leftmargin}{0.5cm} 348 | \setlength{\itemsep}{0pt} 349 | \setlength{\parsep}{0pt} 350 | \setlength{\topsep}{0pt} 351 | \renewcommand{\makelabel}{\hfill}}} 352 | {\end{list}} 353 | \newenvironment{DoxyCompactItemize} 354 | { 355 | \begin{itemize} 356 | \setlength{\itemsep}{-3pt} 357 | \setlength{\parsep}{0pt} 358 | \setlength{\topsep}{0pt} 359 | \setlength{\partopsep}{0pt} 360 | } 361 | {\end{itemize}} 362 | \newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp} 363 | \newlength{\tmplength} 364 | \newenvironment{TabularC}[1] 365 | { 366 | \setlength{\tmplength} 367 | {\linewidth/(#1)-\tabcolsep*2-\arrayrulewidth*(#1+1)/(#1)} 368 | \par\begin{tabular*}{\linewidth} 369 | {*{#1}{|>{\PBS\raggedright\hspace{0pt}}p{\the\tmplength}}|} 370 | } 371 | {\end{tabular*}\par} 372 | \newcommand{\entrylabel}[1]{ 373 | {\parbox[b]{\labelwidth-4pt}{\makebox[0pt][l]{\textbf{#1}}\vspace{1.5\baselineskip}}}} 374 | \newenvironment{Desc} 375 | {\begin{list}{} 376 | { 377 | \settowidth{\labelwidth}{40pt} 378 | \setlength{\leftmargin}{\labelwidth} 379 | \setlength{\parsep}{0pt} 380 | \setlength{\itemsep}{-4pt} 381 | \renewcommand{\makelabel}{\entrylabel} 382 | } 383 | } 384 | {\end{list}} 385 | \newenvironment{Indent} 386 | {\begin{list}{}{\setlength{\leftmargin}{0.5cm}} 387 | \item[]\ignorespaces} 388 | {\unskip\end{list}} 389 | \setlength{\parindent}{0cm} 390 | \setlength{\parskip}{0.2cm} 391 | \addtocounter{secnumdepth}{2} 392 | \usepackage[T1]{fontenc} 393 | \makeatletter 394 | \renewcommand{\paragraph}{\@startsection{paragraph}{4}{0ex}% 395 | {-1.0ex}% 396 | {1.0ex}% 397 | {\usefont{OT1}{phv}{bc}{n}\color{darkgray}}} 398 | \renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{0ex}% 399 | {-1.0ex}% 400 | {1.0ex}% 401 | {\usefont{OT1}{phv}{bc}{n}\color{darkgray}}} 402 | \makeatother 403 | \allsectionsfont{\usefont{OT1}{phv}{bc}{n}\selectfont\color{darkgray}} 404 | \stepcounter{secnumdepth} 405 | \stepcounter{tocdepth} 406 | \definecolor{comment}{rgb}{0.5,0.0,0.0} 407 | \definecolor{keyword}{rgb}{0.0,0.5,0.0} 408 | \definecolor{keywordtype}{rgb}{0.38,0.25,0.125} 409 | \definecolor{keywordflow}{rgb}{0.88,0.5,0.0} 410 | \definecolor{preprocessor}{rgb}{0.5,0.38,0.125} 411 | \definecolor{stringliteral}{rgb}{0.0,0.125,0.25} 412 | \definecolor{charliteral}{rgb}{0.0,0.5,0.5} 413 | \definecolor{vhdldigit}{rgb}{1.0,0.0,1.0} 414 | \definecolor{vhdlkeyword}{rgb}{0.43,0.0,0.43} 415 | \definecolor{vhdllogic}{rgb}{1.0,0.0,0.0} 416 | \definecolor{vhdlchar}{rgb}{0.0,0.0,0.0} 417 | -------------------------------------------------------------------------------- /doc/latex/files.tex: -------------------------------------------------------------------------------- 1 | \section{File List} 2 | Here is a list of all documented files with brief descriptions:\begin{DoxyCompactList} 3 | \item\contentsline{section}{\hyperlink{tnyosc_8hpp}{tnyosc.hpp} (Tnyosc main (and only) header file )}{\pageref{tnyosc_8hpp}}{} 4 | \end{DoxyCompactList} 5 | -------------------------------------------------------------------------------- /doc/latex/refman.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper]{book} 2 | \usepackage{makeidx} 3 | \usepackage{graphicx} 4 | \usepackage{multicol} 5 | \usepackage{float} 6 | \usepackage{listings} 7 | \usepackage{color} 8 | \usepackage{ifthen} 9 | \usepackage[table]{xcolor} 10 | \usepackage{textcomp} 11 | \usepackage{alltt} 12 | \usepackage{ifpdf} 13 | \ifpdf 14 | \usepackage[pdftex, 15 | pagebackref=true, 16 | colorlinks=true, 17 | linkcolor=blue, 18 | unicode 19 | ]{hyperref} 20 | \else 21 | \usepackage[ps2pdf, 22 | pagebackref=true, 23 | colorlinks=true, 24 | linkcolor=blue, 25 | unicode 26 | ]{hyperref} 27 | \usepackage{pspicture} 28 | \fi 29 | \usepackage[utf8]{inputenc} 30 | \usepackage{mathptmx} 31 | \usepackage[scaled=.90]{helvet} 32 | \usepackage{courier} 33 | \usepackage{sectsty} 34 | \usepackage[titles]{tocloft} 35 | \usepackage{doxygen} 36 | \lstset{language=C++,inputencoding=utf8,basicstyle=\footnotesize,breaklines=true,breakatwhitespace=true,tabsize=8,numbers=left } 37 | \makeindex 38 | \setcounter{tocdepth}{3} 39 | \renewcommand{\footrulewidth}{0.4pt} 40 | \renewcommand{\familydefault}{\sfdefault} 41 | \begin{document} 42 | \hypersetup{pageanchor=false} 43 | \begin{titlepage} 44 | \vspace*{7cm} 45 | \begin{center} 46 | {\Large tnyos \\[1ex]\large 1 }\\ 47 | \vspace*{1cm} 48 | {\large Generated by Doxygen 1.7.4}\\ 49 | \vspace*{0.5cm} 50 | {\small Tue Jul 26 2011 13:02:02}\\ 51 | \end{center} 52 | \end{titlepage} 53 | \clearemptydoublepage 54 | \pagenumbering{roman} 55 | \tableofcontents 56 | \clearemptydoublepage 57 | \pagenumbering{arabic} 58 | \hypersetup{pageanchor=true} 59 | \chapter{Class Index} 60 | \input{annotated} 61 | \chapter{File Index} 62 | \input{files} 63 | \chapter{Class Documentation} 64 | \input{classtnyosc_1_1_bundle} 65 | \input{classtnyosc_1_1_message} 66 | \chapter{File Documentation} 67 | \input{tnyosc_8hpp} 68 | \printindex 69 | \end{document} 70 | -------------------------------------------------------------------------------- /doc/latex/tnyosc_09_09_8h.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{tnyosc_09_09_8h}{ 2 | \section{tnyosc++.h File Reference} 3 | \label{tnyosc_09_09_8h}\index{tnyosc++.h@{tnyosc++.h}} 4 | } 5 | {\ttfamily \#include $<$sys/time.h$>$}\par 6 | {\ttfamily \#include $<$arpa/inet.h$>$}\par 7 | {\ttfamily \#include $<$cstddef$>$}\par 8 | {\ttfamily \#include $<$string$>$}\par 9 | {\ttfamily \#include $<$vector$>$}\par 10 | {\ttfamily \#include $<$algorithm$>$}\par 11 | {\ttfamily \#include $<$iostream$>$}\par 12 | {\ttfamily \#include $<$inttypes.h$>$}\par 13 | \subsection*{Classes} 14 | \begin{DoxyCompactItemize} 15 | \item 16 | class \hyperlink{classtnyosc_1_1_message}{tnyosc::Message} 17 | \item 18 | class \hyperlink{classtnyosc_1_1_bundle}{tnyosc::Bundle} 19 | \end{DoxyCompactItemize} 20 | \subsection*{Defines} 21 | \begin{DoxyCompactItemize} 22 | \item 23 | \#define \hyperlink{tnyosc_09_09_8h_a3cfcf123d4ead264289232f91f2c9ca5}{ntohll}(x) 24 | \begin{DoxyCompactList}\small\item\em Convert 64-\/bit little-\/endian integer to a big-\/endian network format. \end{DoxyCompactList}\item 25 | \hypertarget{tnyosc_09_09_8h_a9f4bf0773c45ad9a9753a1b784a13fbb}{ 26 | \#define \hyperlink{tnyosc_09_09_8h_a9f4bf0773c45ad9a9753a1b784a13fbb}{htonll}(x)~ntohll(x)} 27 | \label{tnyosc_09_09_8h_a9f4bf0773c45ad9a9753a1b784a13fbb} 28 | 29 | \begin{DoxyCompactList}\small\item\em Convert 64-\/bit big-\/endian network format to a little-\/endian integer. \end{DoxyCompactList}\end{DoxyCompactItemize} 30 | \subsection*{Typedefs} 31 | \begin{DoxyCompactItemize} 32 | \item 33 | \hypertarget{namespacetnyosc_a116950081bc009f915bb3373356abbe3}{ 34 | typedef std::vector$<$ unsigned char $>$ \hyperlink{namespacetnyosc_a116950081bc009f915bb3373356abbe3}{tnyosc::ByteArray}} 35 | \label{namespacetnyosc_a116950081bc009f915bb3373356abbe3} 36 | 37 | \begin{DoxyCompactList}\small\item\em A byte array type internally used in the tnyosc library. \end{DoxyCompactList}\end{DoxyCompactItemize} 38 | \subsection*{Functions} 39 | \begin{DoxyCompactItemize} 40 | \item 41 | \hypertarget{namespacetnyosc_ae97db9399ea5f368ce35eccfdd973839}{ 42 | int32\_\-t \hyperlink{namespacetnyosc_ae97db9399ea5f368ce35eccfdd973839}{tnyosc::htonf} (float x)} 43 | \label{namespacetnyosc_ae97db9399ea5f368ce35eccfdd973839} 44 | 45 | \begin{DoxyCompactList}\small\item\em Convert 32-\/bit float to a big-\/endian network format. \end{DoxyCompactList}\item 46 | \hypertarget{namespacetnyosc_a518088812da6482f64408ddf8c6aeaca}{ 47 | int64\_\-t \hyperlink{namespacetnyosc_a518088812da6482f64408ddf8c6aeaca}{tnyosc::htond} (double x)} 48 | \label{namespacetnyosc_a518088812da6482f64408ddf8c6aeaca} 49 | 50 | \begin{DoxyCompactList}\small\item\em Convert 64-\/bit float (double) to a big-\/endian network format. \end{DoxyCompactList}\item 51 | \hypertarget{namespacetnyosc_a59992cd0ce1b8c8a1347650a19eb132b}{ 52 | double \hyperlink{namespacetnyosc_a59992cd0ce1b8c8a1347650a19eb132b}{tnyosc::ntohf} (int32\_\-t x)} 53 | \label{namespacetnyosc_a59992cd0ce1b8c8a1347650a19eb132b} 54 | 55 | \begin{DoxyCompactList}\small\item\em Convert 32-\/bit big-\/endian network format to float. \end{DoxyCompactList}\item 56 | \hypertarget{namespacetnyosc_a1057ce2e8aba3879f37c9802b1df71a0}{ 57 | double \hyperlink{namespacetnyosc_a1057ce2e8aba3879f37c9802b1df71a0}{tnyosc::ntohd} (int64\_\-t x)} 58 | \label{namespacetnyosc_a1057ce2e8aba3879f37c9802b1df71a0} 59 | 60 | \begin{DoxyCompactList}\small\item\em Convert 64-\/bit big-\/endian network format to double. \end{DoxyCompactList}\item 61 | const unsigned char $\ast$ \hyperlink{namespacetnyosc_ac90f34c48a37b1200b4e989d38c30b11}{tnyosc::get\_\-pointer} (const ByteArray \&array) 62 | \item 63 | uint64\_\-t \hyperlink{namespacetnyosc_a18579b1675837c5dc683234f13ac1a90}{tnyosc::get\_\-current\_\-ntp\_\-time} () 64 | \end{DoxyCompactItemize} 65 | 66 | 67 | \subsection{Detailed Description} 68 | tnyosc++.h 69 | 70 | The main (and only) tnyosc++ file for creating Open Sound Control 1.0 and 1.1 Specification compliant messages. tnyosc++ provides simple and clean C++ API. 71 | 72 | \begin{DoxyAuthor}{Author} 73 | Toshiro Yamada 74 | \end{DoxyAuthor} 75 | 76 | 77 | \subsection{Define Documentation} 78 | \hypertarget{tnyosc_09_09_8h_a3cfcf123d4ead264289232f91f2c9ca5}{ 79 | \index{tnyosc++.h@{tnyosc++.h}!ntohll@{ntohll}} 80 | \index{ntohll@{ntohll}!tnyosc++.h@{tnyosc++.h}} 81 | \subsubsection[{ntohll}]{\setlength{\rightskip}{0pt plus 5cm}\#define ntohll( 82 | \begin{DoxyParamCaption} 83 | \item[{}]{x} 84 | \end{DoxyParamCaption} 85 | )}} 86 | \label{tnyosc_09_09_8h_a3cfcf123d4ead264289232f91f2c9ca5} 87 | {\bfseries Value:} 88 | \begin{DoxyCode} 89 | (((int64_t)(ntohl((int32_t)((x << 32) >> 32))) << 32) | \ 90 | (uint32_t)ntohl(((int32_t)(x >> 32)))) 91 | \end{DoxyCode} 92 | 93 | 94 | Convert 64-\/bit little-\/endian integer to a big-\/endian network format. 95 | 96 | -------------------------------------------------------------------------------- /doc/latex/tnyosc_8hpp.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{tnyosc_8hpp}{ 2 | \section{tnyosc.hpp File Reference} 3 | \label{tnyosc_8hpp}\index{tnyosc.hpp@{tnyosc.hpp}} 4 | } 5 | 6 | 7 | tnyosc main (and only) header file 8 | 9 | 10 | {\ttfamily \#include $<$sys/time.h$>$}\par 11 | {\ttfamily \#include $<$arpa/inet.h$>$}\par 12 | {\ttfamily \#include $<$cstddef$>$}\par 13 | {\ttfamily \#include $<$string$>$}\par 14 | {\ttfamily \#include $<$vector$>$}\par 15 | {\ttfamily \#include $<$algorithm$>$}\par 16 | {\ttfamily \#include $<$iostream$>$}\par 17 | {\ttfamily \#include $<$inttypes.h$>$}\par 18 | \subsection*{Classes} 19 | \begin{DoxyCompactItemize} 20 | \item 21 | class \hyperlink{classtnyosc_1_1_message}{tnyosc::Message} 22 | \item 23 | class \hyperlink{classtnyosc_1_1_bundle}{tnyosc::Bundle} 24 | \end{DoxyCompactItemize} 25 | \subsection*{Defines} 26 | \begin{DoxyCompactItemize} 27 | \item 28 | \#define \hyperlink{tnyosc_8hpp_a3cfcf123d4ead264289232f91f2c9ca5}{ntohll}(x) 29 | \begin{DoxyCompactList}\small\item\em Convert 64-\/bit little-\/endian integer to a big-\/endian network format. \end{DoxyCompactList}\item 30 | \hypertarget{tnyosc_8hpp_a9f4bf0773c45ad9a9753a1b784a13fbb}{ 31 | \#define \hyperlink{tnyosc_8hpp_a9f4bf0773c45ad9a9753a1b784a13fbb}{htonll}(x)~ntohll(x)} 32 | \label{tnyosc_8hpp_a9f4bf0773c45ad9a9753a1b784a13fbb} 33 | 34 | \begin{DoxyCompactList}\small\item\em Convert 64-\/bit big-\/endian network format to a little-\/endian integer. \end{DoxyCompactList}\end{DoxyCompactItemize} 35 | \subsection*{Typedefs} 36 | \begin{DoxyCompactItemize} 37 | \item 38 | \hypertarget{namespacetnyosc_a116950081bc009f915bb3373356abbe3}{ 39 | typedef std::vector$<$ unsigned char $>$ \hyperlink{namespacetnyosc_a116950081bc009f915bb3373356abbe3}{tnyosc::ByteArray}} 40 | \label{namespacetnyosc_a116950081bc009f915bb3373356abbe3} 41 | 42 | \begin{DoxyCompactList}\small\item\em A byte array type internally used in the tnyosc library. \end{DoxyCompactList}\end{DoxyCompactItemize} 43 | \subsection*{Functions} 44 | \begin{DoxyCompactItemize} 45 | \item 46 | \hypertarget{namespacetnyosc_ae97db9399ea5f368ce35eccfdd973839}{ 47 | int32\_\-t \hyperlink{namespacetnyosc_ae97db9399ea5f368ce35eccfdd973839}{tnyosc::htonf} (float x)} 48 | \label{namespacetnyosc_ae97db9399ea5f368ce35eccfdd973839} 49 | 50 | \begin{DoxyCompactList}\small\item\em Convert 32-\/bit float to a big-\/endian network format. \end{DoxyCompactList}\item 51 | \hypertarget{namespacetnyosc_a518088812da6482f64408ddf8c6aeaca}{ 52 | int64\_\-t \hyperlink{namespacetnyosc_a518088812da6482f64408ddf8c6aeaca}{tnyosc::htond} (double x)} 53 | \label{namespacetnyosc_a518088812da6482f64408ddf8c6aeaca} 54 | 55 | \begin{DoxyCompactList}\small\item\em Convert 64-\/bit float (double) to a big-\/endian network format. \end{DoxyCompactList}\item 56 | \hypertarget{namespacetnyosc_a59992cd0ce1b8c8a1347650a19eb132b}{ 57 | double \hyperlink{namespacetnyosc_a59992cd0ce1b8c8a1347650a19eb132b}{tnyosc::ntohf} (int32\_\-t x)} 58 | \label{namespacetnyosc_a59992cd0ce1b8c8a1347650a19eb132b} 59 | 60 | \begin{DoxyCompactList}\small\item\em Convert 32-\/bit big-\/endian network format to float. \end{DoxyCompactList}\item 61 | \hypertarget{namespacetnyosc_a1057ce2e8aba3879f37c9802b1df71a0}{ 62 | double \hyperlink{namespacetnyosc_a1057ce2e8aba3879f37c9802b1df71a0}{tnyosc::ntohd} (int64\_\-t x)} 63 | \label{namespacetnyosc_a1057ce2e8aba3879f37c9802b1df71a0} 64 | 65 | \begin{DoxyCompactList}\small\item\em Convert 64-\/bit big-\/endian network format to double. \end{DoxyCompactList}\item 66 | const unsigned char $\ast$ \hyperlink{namespacetnyosc_ac90f34c48a37b1200b4e989d38c30b11}{tnyosc::get\_\-pointer} (const ByteArray \&array) 67 | \item 68 | uint64\_\-t \hyperlink{namespacetnyosc_a18579b1675837c5dc683234f13ac1a90}{tnyosc::get\_\-current\_\-ntp\_\-time} () 69 | \end{DoxyCompactItemize} 70 | 71 | 72 | \subsection{Detailed Description} 73 | tnyosc main (and only) header file \begin{DoxyAuthor}{Author} 74 | Toshiro Yamada 75 | \end{DoxyAuthor} 76 | tnyosc is a header-\/only Open Sound Control library written in C++ for creating OSC-\/compliant messages. tnyosc supports Open Sound Control 1.0 and 1.1 types and other nonstandard types, and bundles. Note that tnyosc does not include code to actually send or receive OSC messages. 77 | 78 | \subsection{Define Documentation} 79 | \hypertarget{tnyosc_8hpp_a3cfcf123d4ead264289232f91f2c9ca5}{ 80 | \index{tnyosc.hpp@{tnyosc.hpp}!ntohll@{ntohll}} 81 | \index{ntohll@{ntohll}!tnyosc.hpp@{tnyosc.hpp}} 82 | \subsubsection[{ntohll}]{\setlength{\rightskip}{0pt plus 5cm}\#define ntohll( 83 | \begin{DoxyParamCaption} 84 | \item[{}]{x} 85 | \end{DoxyParamCaption} 86 | )}} 87 | \label{tnyosc_8hpp_a3cfcf123d4ead264289232f91f2c9ca5} 88 | {\bfseries Value:} 89 | \begin{DoxyCode} 90 | (((int64_t)(ntohl((int32_t)((x << 32) >> 32))) << 32) | \ 91 | (uint32_t)ntohl(((int32_t)(x >> 32)))) 92 | \end{DoxyCode} 93 | 94 | 95 | Convert 64-\/bit little-\/endian integer to a big-\/endian network format. 96 | 97 | -------------------------------------------------------------------------------- /include/tnyosc-dispatch.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 Toshiro Yamada 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions 6 | // are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 3. The name of the author may not be used to endorse or promote products 14 | // derived from this software without specific prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 17 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | /// @file tnyosc-dispatch.hpp 28 | /// @brief tnyosc dispatch header file 29 | /// @author Toshiro Yamada 30 | #ifndef __TNY_OSC_DISPATCH__ 31 | #define __TNY_OSC_DISPATCH__ 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | 40 | namespace tnyosc { 41 | 42 | struct Argument { 43 | char type; // OSC type tag 44 | size_t size; // size in byte 45 | union { 46 | int32_t i; // int32 47 | float f; // float32 48 | char* s; // OSC-string 49 | void* b; // OSC-blob 50 | int64_t h; // int64 51 | double d; // float64 52 | uint64_t t; // OSC-timetag 53 | char* S; // Alternate OSC-string, such as "symbols" 54 | char c; // ASCII character 55 | uint32_t r; // 32-bit RGBA color 56 | struct { 57 | uint8_t port; 58 | uint8_t status; 59 | uint8_t data1; 60 | uint8_t data2; 61 | } m; // MIDI data 62 | } data; 63 | 64 | Argument(); 65 | Argument(const Argument& a) ; 66 | virtual ~Argument(); 67 | Argument& operator=(const Argument& a); 68 | }; 69 | 70 | typedef void (*osc_method)(const std::string& address, 71 | const std::vector& argv, void* user_data); 72 | 73 | // structure to hold method handles 74 | struct MethodTemplate { 75 | std::string address; // OSC-Address 76 | std::string types; // OSC-types as a string 77 | void* user_data; // user data 78 | osc_method method; // OSC-Methods to call 79 | }; 80 | 81 | struct ParsedMessage { 82 | struct timeval timetag; 83 | std::string address; 84 | std::string types; 85 | std::vector argv; 86 | }; 87 | 88 | // structure to hold callback function for a given OSC packet 89 | struct Callback { 90 | struct timeval timetag; // OSC-timetag to determine when to call the method 91 | std::string address; 92 | std::vector argv; 93 | void* user_data; // user data 94 | osc_method method; // matched method to call 95 | }; 96 | 97 | typedef std::tr1::shared_ptr CallbackRef; 98 | // use to sort list according to their timetag 99 | 100 | class Dispatcher { 101 | public: 102 | Dispatcher(); 103 | ~Dispatcher(); 104 | 105 | /// Add a method template that may respond to an incoming Open Sound Control 106 | /// message. Use match_methods to deserialize a raw OSC message and match 107 | /// with the added methods. 108 | void add_method(const char* address, const char* types, 109 | osc_method method, void* user_data); 110 | 111 | /// Deserializes a raw Open Sound Control message (as coming from a network) 112 | /// and returns a list of CallbackRef that matches with the registered method 113 | /// tempaltes. 114 | std::list match_methods(const char* data, size_t size); 115 | 116 | /// decode_data is called inside match_methods to extract the OSC data from 117 | /// a raw data. 118 | static bool decode_data(const char* data, size_t size, 119 | std::list& messages, struct timeval timetag=kZeroTimetag); 120 | 121 | private: 122 | static const struct timeval kZeroTimetag; 123 | static bool decode_osc(const char* data, size_t size, 124 | std::list& messages, struct timeval timetag); 125 | static bool pattern_match(const std::string& lhs, const std::string& rhs); 126 | 127 | std::list methods_; 128 | }; 129 | 130 | } // namespace tnyosc 131 | 132 | #endif // __TNY_OSC_DISPATCH__ 133 | 134 | -------------------------------------------------------------------------------- /src/tnyosc-dispatch.cc: -------------------------------------------------------------------------------- 1 | #include "tnyosc-dispatch.hpp" 2 | #include "tnyosc.hpp" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace tnyosc; 12 | 13 | void print_bytes(const char* bytes, size_t size) 14 | { 15 | size_t i; 16 | for (i = 0; i < size; ++i) { 17 | printf("%02x ", bytes[i]); 18 | if (i % 16 == 15) { 19 | printf("\n"); 20 | } else if (i % 4 == 3) { 21 | printf(" "); 22 | } 23 | } 24 | if (i % 16 != 0) { 25 | printf("\n"); 26 | } 27 | printf("\n"); 28 | } 29 | 30 | bool compare_callback_timetag(const CallbackRef first, const CallbackRef second) 31 | { 32 | if (first->timetag.tv_sec == second->timetag.tv_sec) { 33 | return first->timetag.tv_usec <= second->timetag.tv_usec; 34 | } else { 35 | return first->timetag.tv_sec < second->timetag.tv_sec; 36 | } 37 | } 38 | 39 | Argument::Argument() 40 | { 41 | type = 0; 42 | size = 0; 43 | memset(&data, 0, sizeof(data)); 44 | } 45 | 46 | Argument::Argument(const Argument& a) 47 | { 48 | type = a.type; 49 | size = a.size; 50 | switch(type) { 51 | case 's': 52 | case 'S': 53 | data.s = strndup(a.data.s, a.size); 54 | break; 55 | case'b': 56 | data.b = malloc(sizeof(size)); 57 | memcpy(data.b, a.data.b, size); 58 | break; 59 | default: 60 | data = a.data; 61 | break; 62 | } 63 | } 64 | 65 | Argument::~Argument() 66 | { 67 | switch(type) { 68 | case 's': 69 | case 'S': 70 | case'b': 71 | free(data.s); 72 | } 73 | } 74 | 75 | Argument& Argument::operator=(const Argument& a) 76 | { 77 | if (this == &a) return *this; 78 | switch (type) { 79 | case 's': 80 | case 'S': 81 | case 'b': 82 | free(data.s); 83 | } 84 | 85 | type = a.type; 86 | size = a.size; 87 | switch(type) { 88 | case 's': 89 | case 'S': 90 | data.s = strndup(a.data.s, a.size); 91 | break; 92 | case'b': 93 | data.b = malloc(sizeof(size)); 94 | memcpy(data.b, a.data.b, size); 95 | break; 96 | default: 97 | data = a.data; 98 | } 99 | return *this; 100 | } 101 | 102 | Dispatcher::Dispatcher() 103 | : methods_(0) 104 | { 105 | } 106 | 107 | Dispatcher::~Dispatcher() 108 | { 109 | } 110 | 111 | void Dispatcher::add_method(const char* address, const char* types, 112 | osc_method method, void* user_data) 113 | { 114 | MethodTemplate m; 115 | m.address = address == NULL ? "" : address; 116 | m.types = types == NULL ? "" : types; 117 | m.user_data = user_data; 118 | m.method = method; 119 | methods_.push_back(m); 120 | } 121 | 122 | std::list Dispatcher::match_methods(const char* data, size_t size) 123 | { 124 | std::list parsed_messages; 125 | std::list callback_list; 126 | if (!decode_data(data, size, parsed_messages)) return callback_list; 127 | #if TNYOSC_DEBUG 128 | std::cerr << __FUNCTION__ << ": decode success" << std::endl; 129 | #endif // TNYOSC_DEBUG 130 | assert(parsed_messages.size() > 0); 131 | 132 | // iterate through all the messages and find matches with registered methods 133 | std::list::iterator msg_iter = parsed_messages.begin(); 134 | for (; msg_iter != parsed_messages.end(); ++msg_iter) { 135 | #if TNYOSC_DEBUG 136 | std::cerr << __FUNCTION__ << ": matching " << msg_iter->address << "\n"; 137 | #endif // TNYOSC_DEBUG 138 | std::list::const_iterator method_iter = methods_.begin(); 139 | for (; method_iter != methods_.end(); ++method_iter) { 140 | if (pattern_match(msg_iter->address, method_iter->address)) { 141 | #if TNYOSC_DEBUG 142 | std::cerr << " matched " << method_iter->address << "\n"; 143 | #endif // TNYOSC_DEBUG 144 | // if a method specifies a type, make sure it matches 145 | if (method_iter->types.empty() || 146 | !msg_iter->types.compare(method_iter->types)) { 147 | CallbackRef callback = CallbackRef(new Callback()); 148 | callback->timetag = msg_iter->timetag; 149 | callback->address = msg_iter->address; 150 | callback->argv = msg_iter->argv; 151 | callback->user_data = method_iter->user_data; 152 | callback->method = method_iter->method; 153 | callback_list.push_back(callback); 154 | } 155 | } 156 | } 157 | } 158 | 159 | callback_list.sort(compare_callback_timetag); 160 | 161 | return callback_list; 162 | } 163 | 164 | struct timeval ntp_to_unixtime(uint32_t sec, uint32_t frac) 165 | { 166 | // time between 1-1-1900 and 1-1-1950 167 | static const uint64_t epoch = 2208988800UL; 168 | 169 | struct timeval tv; 170 | if (sec == 0 && frac == 1) { 171 | memset(&tv, 0, sizeof(tv)); 172 | } else { 173 | tv.tv_sec = sec - epoch; 174 | tv.tv_usec = (suseconds_t)((double)frac * 0.0002328306437080); 175 | } 176 | 177 | return tv; 178 | } 179 | 180 | const struct timeval Dispatcher::kZeroTimetag = {0, 0}; 181 | 182 | bool Dispatcher::decode_data(const char* data, size_t size, 183 | std::list& messages, struct timeval timetag) 184 | { 185 | if (!memcmp(data, "#bundle\0", 8)) { 186 | // found a bundle 187 | #if TNYOSC_DEBUG 188 | std::cerr << __FUNCTION__ << ": bundle" << std::endl; 189 | #endif // TNYOSC_DEBUG 190 | data += 8; size -= 8; 191 | 192 | uint32_t sec, frac; 193 | memcpy(&sec, data, 4); data += 4; size -= 4; 194 | memcpy(&frac, data, 4); data += 4; size -= 4; 195 | sec = ntohl(sec); 196 | frac = ntohl(frac); 197 | 198 | struct timeval new_timetag = ntp_to_unixtime(sec, frac); 199 | 200 | while (size != 0) { 201 | uint32_t seg_size; 202 | memcpy(&seg_size, data, 4); data += 4; size -= 4; 203 | seg_size = ntohl(seg_size); 204 | if (seg_size > size) return false; 205 | if (!decode_data(data, seg_size, messages, new_timetag)) return false; 206 | data += seg_size; size -= seg_size; 207 | } 208 | } else { 209 | #if TNYOSC_DEBUG 210 | std::cerr << __FUNCTION__ << ": osc" << std::endl; 211 | #endif // TNYOSC_DEBUG 212 | if (!decode_osc(data, size, messages, timetag)) return false; 213 | } 214 | 215 | return true; 216 | } 217 | 218 | bool Dispatcher::decode_osc(const char* data, size_t size, 219 | std::list& messages, struct timeval timetag) 220 | { 221 | const char* head; 222 | const char* tail; 223 | unsigned int i = 0; 224 | size_t remain = size; 225 | 226 | ParsedMessage m; 227 | m.timetag = timetag; 228 | 229 | // extract address 230 | head = tail = data; 231 | while (tail[i] != '\0' && ++i < remain); 232 | if (i == remain) return false; 233 | m.address.resize(i); 234 | std::copy(head, head+i, m.address.begin()); 235 | head += i + (4 - i % 4); 236 | remain = size - (head - data); 237 | #if TNYOSC_DEBUG 238 | std::cerr << __FUNCTION__ << ": address = " << m.address << std::endl; 239 | #endif // TNYOSC_DEBUG 240 | 241 | // extract types 242 | i = 0; 243 | tail = head; 244 | if (head[i++] != ',') return false; 245 | while (tail[i] != '\0' && ++i < remain); 246 | if (i == remain) return false; 247 | m.types.resize(i-1); 248 | std::copy(head+1, head+i, m.types.begin()); 249 | head += i + (4 - i % 4); 250 | remain = size - (head - data); 251 | #if TNYOSC_DEBUG 252 | std::cerr << __FUNCTION__ << ": types = " << m.types << std::endl; 253 | #endif // TNYOSC_DEBUG 254 | 255 | // extract data 256 | uint32_t int32; 257 | uint64_t int64; 258 | m.argv.resize(m.types.size()); 259 | for (unsigned int j = 0; j < m.types.size(); j++) { 260 | m.argv[j].type = m.types[j]; 261 | switch (m.types[j]) { 262 | case 'i': 263 | case 'f': 264 | case 'r': 265 | memcpy(&int32, head, 4); 266 | int32 = htonl(int32); 267 | memcpy(&m.argv[j].data.i, &int32, 4); 268 | m.argv[j].size = 4; 269 | head += 4; 270 | remain -= 4; 271 | break; 272 | case 'b': 273 | memcpy(&int32, head, 4); 274 | head += 4; 275 | remain -= 4; 276 | int32 = htonl(int32); 277 | if (int32 > remain) return false; 278 | m.argv[j].data.b = malloc(int32); 279 | memcpy(m.argv[j].data.b, head, int32); 280 | m.argv[j].size = int32; 281 | head += int32; 282 | remain -= int32; 283 | break; 284 | case 's': 285 | case 'S': 286 | tail = head; 287 | i = 0; 288 | while (tail[i] != '\0' && ++i < remain); 289 | m.argv[j].data.s = strndup((char*)head, i); 290 | m.argv[j].size = i; 291 | i += 4 - i % 4; 292 | head += i; 293 | remain -= i; 294 | break; 295 | case 'h': 296 | case 'd': 297 | case 't': 298 | memcpy(&int64, head, 8); 299 | int64 = htonll(int64); 300 | memcpy(&m.argv[j].data.i, &int64, 8); 301 | m.argv[j].size = 8; 302 | head += 8; 303 | remain -= 8; 304 | break; 305 | case 'c': 306 | memcpy(&int32, head, 4); 307 | m.argv[j].data.c = (char)htonl(int32); 308 | m.argv[j].size = 1; 309 | head += 4; 310 | remain -= 8; 311 | break; 312 | case 'm': 313 | memcpy(&m.argv[j].data.m, head, 4); 314 | m.argv[j].size = 4; 315 | head += 4; 316 | remain -= 4; 317 | break; 318 | } 319 | } 320 | 321 | messages.push_back(m); 322 | #if TNYOSC_DEBUG 323 | std::cerr << __FUNCTION__ << ": success" << std::endl; 324 | #endif // TNYOSC_DEBUG 325 | return true; 326 | } 327 | 328 | // pattern_match compares two strings and returns true or false depending on if 329 | // they match according to OSC's pattern matching guideline 330 | // 331 | // OSC Pattern Matching Guideline: 332 | // 333 | // 1. '?' in the OSC Address Pattern matches any single character. 334 | // 2. '*' in the OSC Address Pattern matches any sequence of zero or more 335 | // characters. 336 | // 3. A string of characters in square brackets (e.g., "[string]") in the 337 | // OSC Address Pattern matches any character in the string. Inside square 338 | // brackets, the minus sign (-) and exclamation point (!) have special 339 | // meanings: 340 | // o two characters separated by a minus sign indicate the range of 341 | // characters between the given two in ASCII collating sequence. (A 342 | // minus sign at the end of the string has no special meaning.) 343 | // o An exclamation point at the beginning of a bracketed string 344 | // negates the sense of the list, meaning that the list matches any 345 | // character not in the list. (An exclamation point anywhere besides 346 | // the first character after the open bracket has no special meaning.) 347 | // 4. A comma-separated list of strings enclosed in curly braces 348 | // (e.g., "{foo,bar}") in the OSC Address Pattern matches any of the 349 | // strings in the list. 350 | // 5. Any other character in an OSC Address Pattern can match only the same 351 | // character. 352 | // 353 | // @param lhs incoming OSC address pattern to match it with rhs's pattern 354 | // @param rhs method address pattern that may contain special characters 355 | bool Dispatcher::pattern_match(const std::string& lhs, const std::string& rhs) 356 | { 357 | bool negate = false; 358 | bool mismatched = false; 359 | std::string::const_iterator seq_tmp; 360 | std::string::const_iterator seq = lhs.begin(); 361 | std::string::const_iterator seq_end = lhs.end(); 362 | std::string::const_iterator pattern = rhs.begin(); 363 | std::string::const_iterator pattern_end = rhs.end(); 364 | while (seq != seq_end && pattern != pattern_end) { 365 | switch (*pattern) { 366 | case '?': 367 | break; 368 | case '*': 369 | // if * is the last pattern, return true 370 | if (++pattern == pattern_end) return true; 371 | while (*seq != *pattern && seq != seq_end) ++seq; 372 | // if seq reaches to the end without matching pattern 373 | if (seq == seq_end) return false; 374 | break; 375 | case '[': 376 | negate = false; 377 | mismatched = false; 378 | if (*(++pattern) == '!') { 379 | negate = true; 380 | ++pattern; 381 | } 382 | if (*(pattern+1) == '-') { 383 | // range matching 384 | char c_start = *pattern; ++pattern; 385 | //assert(*pattern == '-'); 386 | char c_end = *(++pattern); ++pattern; 387 | //assert(*pattern == ']'); 388 | // swap c_start and c_end if c_start is larger 389 | if (c_start > c_end) { 390 | char tmp = c_start; 391 | c_end = c_start; 392 | c_start = tmp; 393 | } 394 | mismatched = (c_start <= *seq && *seq <= c_end) ? negate : !negate; 395 | if (mismatched) return false; 396 | } else { 397 | // literal matching 398 | while (*pattern != ']') { 399 | if (*seq == *pattern) { 400 | mismatched = negate; 401 | break; 402 | } 403 | ++pattern; 404 | } 405 | if (mismatched) return false; 406 | while (*pattern != ']') ++pattern; 407 | } 408 | break; 409 | case '{': 410 | seq_tmp = seq; 411 | mismatched = true; 412 | while (*(++pattern) != '}') { 413 | // this assumes that there's no sequence like "{,a}" where ',' is 414 | // follows immediately after '{', which is illegal. 415 | if (*pattern == ',') { 416 | mismatched = false; 417 | break; 418 | } else if (*seq != *pattern) { 419 | // fast forward to the next ',' or '}' 420 | while (*(++pattern) != ',' && *pattern != '}'); 421 | if (*pattern == '}') return false; 422 | // redo seq matching 423 | seq = seq_tmp; 424 | mismatched = true; 425 | } else { 426 | // matched 427 | ++seq; 428 | mismatched = false; 429 | } 430 | } 431 | if (mismatched) return false; 432 | while (*pattern != '}') ++pattern; 433 | --seq; 434 | break; 435 | default: // non-special character 436 | if (*seq != *pattern) return false; 437 | break; 438 | } 439 | ++seq; ++pattern; 440 | } 441 | if (seq == seq_end && pattern == pattern_end) return true; 442 | else return false; 443 | } 444 | 445 | -------------------------------------------------------------------------------- /tests/pattern_match_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | bool pattern_match(const std::string& lhs, const std::string& rhs) 6 | { 7 | std::cout << std::endl; 8 | std::cout << "pattern_match(" << lhs << ", " << rhs << ")\n"; 9 | 10 | bool negate = false; 11 | bool mismatched = false; 12 | std::string::const_iterator seq = lhs.begin(); 13 | std::string::const_iterator seq_end = lhs.end(); 14 | std::string::const_iterator pattern = rhs.begin(); 15 | std::string::const_iterator pattern_end = rhs.end(); 16 | while (seq != seq_end && pattern != pattern_end) { 17 | std::cout << "seq = " << *seq << ", pattern = " << *pattern << "\n"; 18 | std::string::const_iterator seq_tmp; 19 | switch (*pattern) { 20 | case '?': 21 | break; 22 | case '*': 23 | // if * is the last pattern, return true 24 | if (++pattern == pattern_end) return true; 25 | while (*seq != *pattern && seq != seq_end) ++seq; 26 | // if seq reaches to the end without matching pattern 27 | if (seq == seq_end) return false; 28 | break; 29 | case '[': 30 | negate = false; 31 | mismatched = false; 32 | if (*(++pattern) == '!') { 33 | negate = true; 34 | ++pattern; 35 | } 36 | if (*(pattern+1) == '-') { 37 | // range matching 38 | char c_start = *pattern; ++pattern; 39 | //assert(*pattern == '-'); 40 | char c_end = *(++pattern); ++pattern; 41 | //assert(*pattern == ']'); 42 | // swap c_start and c_end if c_start is larger 43 | if (c_start > c_end) { 44 | char tmp = c_start; 45 | c_end = c_start; 46 | c_start = tmp; 47 | } 48 | mismatched = (c_start <= *seq && *seq <= c_end) ? negate : !negate; 49 | if (mismatched) return false; 50 | } else { 51 | // literal matching 52 | while (*pattern != ']') { 53 | if (*seq == *pattern) { 54 | mismatched = negate; 55 | break; 56 | } 57 | ++pattern; 58 | } 59 | if (mismatched) return false; 60 | while (*pattern != ']') ++pattern; 61 | } 62 | break; 63 | case '{': 64 | seq_tmp = seq; 65 | mismatched = true; 66 | while (*(++pattern) != '}') { 67 | // this assumes that there's no sequence like "{,a}" where ',' is 68 | // follows immediately after '{', which is illegal. 69 | if (*pattern == ',') { 70 | mismatched = false; 71 | break; 72 | } else if (*seq != *pattern) { 73 | // fast forward to the next ',' or '}' 74 | while (*(++pattern) != ',' && *pattern != '}'); 75 | if (*pattern == '}') return false; 76 | // redo seq matching 77 | seq = seq_tmp; 78 | mismatched = true; 79 | } else { 80 | // matched 81 | ++seq; 82 | mismatched = false; 83 | } 84 | } 85 | if (mismatched) return false; 86 | while (*pattern != '}') ++pattern; 87 | --seq; 88 | break; 89 | default: // non-special character 90 | if (*seq != *pattern) return false; 91 | break; 92 | } 93 | ++seq; ++pattern; 94 | } 95 | if (seq == seq_end && pattern == pattern_end) return true; 96 | else return false; 97 | } 98 | 99 | int main() 100 | { 101 | std::string seq = "/abc/d"; 102 | std::string pattern; 103 | 104 | // test no special character pattern 105 | pattern = "/abc/d"; 106 | assert(pattern_match(seq, pattern) == true); 107 | pattern = "/ab/d"; 108 | assert(pattern_match(seq, pattern) == false); 109 | pattern = "/abc/de"; 110 | assert(pattern_match(seq, pattern) == false); 111 | 112 | // test ? 113 | pattern = "/abc/?"; 114 | assert(pattern_match(seq, pattern) == true); 115 | pattern = "/?bc/?"; 116 | assert(pattern_match(seq, pattern) == true); 117 | pattern = "/?/d"; 118 | assert(pattern_match(seq, pattern) == false); 119 | 120 | // test * 121 | pattern = "/*/d"; 122 | assert(pattern_match(seq, pattern) == true); 123 | pattern = "/*/?"; 124 | assert(pattern_match(seq, pattern) == true); 125 | pattern = "/*/*"; 126 | assert(pattern_match(seq, pattern) == true); 127 | pattern = "/a*c/d"; 128 | assert(pattern_match(seq, pattern) == true); 129 | 130 | // test [] 131 | pattern = "/[abc]bc/d"; 132 | assert(pattern_match(seq, pattern) == true); 133 | pattern = "/[!abc]bc/d"; 134 | assert(pattern_match(seq, pattern) == false); 135 | pattern = "/abc/[d]"; 136 | assert(pattern_match(seq, pattern) == true); 137 | pattern = "/abc/[!abc]"; 138 | assert(pattern_match(seq, pattern) == true); 139 | pattern = "/abc/[!a-c]"; 140 | assert(pattern_match(seq, pattern) == true); 141 | pattern = "/a[a-c]c/d"; 142 | assert(pattern_match(seq, pattern) == true); 143 | pattern = "/[1-9]bc/d"; 144 | assert(pattern_match(seq, pattern) == false); 145 | 146 | // test {} 147 | pattern = "/{bed,abc,foo}/d"; 148 | assert(pattern_match(seq, pattern) == true); 149 | pattern = "/{abc,foo}/d"; 150 | assert(pattern_match(seq, pattern) == true); 151 | pattern = "/{abcd,foo}/d"; 152 | assert(pattern_match(seq, pattern) == false); 153 | pattern = "/abc/{a,b,d}"; 154 | assert(pattern_match(seq, pattern) == true); 155 | pattern = "/abc/{a,b,c}"; 156 | assert(pattern_match(seq, pattern) == false); 157 | pattern = "/a{blah,bc}/d"; 158 | assert(pattern_match(seq, pattern) == true); 159 | } 160 | 161 | -------------------------------------------------------------------------------- /tests/tnyosc-dispatch_test.cc: -------------------------------------------------------------------------------- 1 | #include "tnyosc-dispatch.hpp" 2 | #include "tnyosc.hpp" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | const std::string TEST1_ADDRESS = "/test1"; 10 | 11 | void test_method1(const std::string& address, 12 | const std::vector& argv, 13 | void* user_data) 14 | { 15 | CHECK(address.compare(TEST1_ADDRESS) == 0); 16 | CHECK(argv.size() == 2); 17 | CHECK(argv[0].data.i == 1000); 18 | CHECK(strcmp(argv[1].data.s, "test") == 0); 19 | CHECK(user_data == NULL); 20 | } 21 | 22 | TEST(CallMethodTestMessage) 23 | { 24 | using namespace tnyosc; 25 | Message msg("/test1"); 26 | msg.append(1000); 27 | msg.append("test"); 28 | Bundle bundle; 29 | bundle.append(msg); 30 | bundle.append(msg); 31 | 32 | Dispatcher dispatcher; 33 | dispatcher.add_method(TEST1_ADDRESS.c_str(), NULL, &test_method1, NULL); 34 | dispatcher.add_method("/test[1-9]", NULL, &test_method1, NULL); 35 | dispatcher.add_method("/test?", NULL, &test_method1, NULL); 36 | dispatcher.add_method("/*1", NULL, &test_method1, NULL); 37 | dispatcher.add_method("/test{1,2,3,4}", NULL, &test_method1, NULL); 38 | dispatcher.add_method("/test{2,3,4}", NULL, &test_method1, NULL); 39 | 40 | std::list callback_list = 41 | dispatcher.match_methods(bundle.data(), bundle.size()); 42 | 43 | std::cerr << "callback_list.size() = " << callback_list.size() << std::endl; 44 | CHECK(callback_list.size() == 10); 45 | 46 | std::list::iterator it = callback_list.begin(); 47 | for (; it != callback_list.end(); ++it) { 48 | (*it)->method((*it)->address, (*it)->argv, (*it)->user_data); 49 | } 50 | } 51 | 52 | int main() 53 | { 54 | return UnitTest::RunAllTests(); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /tests/tnyosc_net_test.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "tnyosc.hpp" 5 | 6 | using boost::asio::ip::udp; 7 | using boost::asio::ip::tcp; 8 | 9 | tnyosc::Message::Ptr create_osc_message() 10 | { 11 | // create a OSC messsage with address "/test". if no argument is given to 12 | // the constructor, default is "/tnyosc". 13 | tnyosc::Message::Ptr msg(new tnyosc::Message("/test")); 14 | 15 | // append a OSC-string 16 | msg->append("hello tnyosc"); 17 | 18 | // append some ints and floats 19 | for (int i = 0; i < 5; i++) { 20 | // int32 21 | msg->append(i); 22 | // float32 23 | msg->append(i*2.0f); 24 | } 25 | 26 | return msg; 27 | } 28 | 29 | int main(int argc, const char* argv[]) 30 | { 31 | if (argc != 3) { 32 | std::cout << argv[0] << " HOST PORT\n"; 33 | return -1; 34 | } 35 | 36 | try { 37 | // boost::asio library for sending UDP packets 38 | boost::asio::io_service io_service; 39 | 40 | tcp::resolver resolver(io_service); 41 | tcp::resolver::query query(tcp::v4(), argv[1], argv[2]); 42 | tcp::resolver::iterator iterator = resolver.resolve(query); 43 | 44 | tcp::socket socket(io_service, tcp::endpoint(tcp::v4(), 0)); 45 | socket.connect(*iterator); 46 | 47 | // create a OSC message 48 | tnyosc::Message::Ptr msg = create_osc_message(); 49 | 50 | // create a OSC bundle 51 | tnyosc::Bundle::Ptr bundle(new tnyosc::Bundle()); 52 | 53 | // add the OSC message to the bundle 54 | bundle->append(msg); 55 | 56 | // you can also add a bundle to itself. this works because the data is 57 | // copied when the function is called. 58 | bundle->append(bundle); 59 | 60 | // send the message over UDP 61 | int32_t send_size = htonl(bundle->size()); 62 | boost::asio::write(socket, boost::asio::buffer(&send_size, 4)); 63 | boost::asio::write(socket, boost::asio::buffer(bundle->data(), bundle->size())); 64 | } catch (std::exception& e) { 65 | std::cerr << "Excetion: " << e.what() << std::endl; 66 | return 1; 67 | } 68 | 69 | return 0; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /tests/tnyosc_test.cc: -------------------------------------------------------------------------------- 1 | #include "tnyosc.hpp" 2 | #include 3 | #include 4 | 5 | void print_bytes(const char* bytes, size_t size) 6 | { 7 | size_t i; 8 | for (i = 0; i < size; ++i) { 9 | printf("%02x ", bytes[i]); 10 | if (i % 16 == 15) { 11 | printf("\n"); 12 | } else if (i % 4 == 3) { 13 | printf(" "); 14 | } 15 | } 16 | if (i % 16 != 0) { 17 | printf("\n"); 18 | } 19 | printf("\n"); 20 | } 21 | 22 | void test_message_data_types() 23 | { 24 | std::string test_string = "tnyosc"; 25 | char test_cstring[] = "test"; 26 | int array[] = {1, 2, 3, 4, 5}; 27 | 28 | tnyosc::Message msg; 29 | // OSC 1.0 types 30 | msg.append(1); 31 | msg.append(3.0f); 32 | msg.append(test_string); 33 | msg.append_cstring(test_cstring, strlen(test_cstring)); 34 | msg.append_blob(test_cstring, strlen(test_cstring)); 35 | // OSC 1.1 types 36 | msg.append_current_time(); 37 | msg.append_true(); 38 | msg.append_false(); 39 | msg.append_null(); 40 | msg.append_impulse(); 41 | // nonstandard types 42 | msg.append((long long)2); 43 | msg.append((double)4.0); 44 | msg.append('!'); 45 | msg.append_midi(1, 0, 0, 255); 46 | msg.append_array((void*)array, sizeof(array)); 47 | print_bytes(msg.data(), msg.size()); 48 | } 49 | 50 | void test_message_set_address() 51 | { 52 | char addr1[] = "test"; 53 | std::string addr2 = "new_string"; 54 | 55 | tnyosc::Message msg(addr1); 56 | assert(msg.address().compare(addr1) == 0); 57 | 58 | msg.set_address(addr2); 59 | assert(msg.address().compare(addr2) == 0); 60 | } 61 | 62 | void test_message_large_data() 63 | { 64 | tnyosc::Message msg; 65 | for (int i = 0; i < 1000; i++) { 66 | msg.append(i); 67 | } 68 | print_bytes(msg.data(), msg.size()); 69 | } 70 | 71 | void test_message_ptr() 72 | { 73 | tnyosc::Message* msg = new tnyosc::Message("/msg/ptr"); 74 | msg->append_cstring("pointer", strlen("pointer")); 75 | print_bytes(msg->data(), msg->size()); 76 | delete msg; 77 | } 78 | 79 | #ifdef TNYOSC_WITH_BOOST 80 | void test_message_boost_ptr() 81 | { 82 | tnyosc::Message::Ptr msg(new tnyosc::Message("/boost/test")); 83 | for (int i = 0; i < 10; i++) { 84 | msg->append(i); 85 | } 86 | print_bytes(msg->data(), msg->size()); 87 | } 88 | 89 | void test_bundle_boost_ptr() 90 | { 91 | tnyosc::Bundle::Ptr bundle(new tnyosc::Bundle()); 92 | bundle->append(tnyosc::Message()); 93 | print_bytes(bundle->data(), bundle->size()); 94 | } 95 | #endif 96 | 97 | int main(int argc, const char* argv[]) 98 | { 99 | test_message_data_types(); 100 | test_message_ptr(); 101 | //test_message_large_data(); 102 | #ifdef TNYOSC_WITH_BOOST 103 | test_message_boost_ptr(); 104 | test_bundle_boost_ptr(); 105 | #endif 106 | 107 | } 108 | 109 | --------------------------------------------------------------------------------