Mercurial > hg > sv-dependency-builds
changeset 114:241db1b1eff2
added includes as well
author | Matthias Mauch <matthiasmauch@gmail.com> |
---|---|
date | Thu, 09 Jan 2014 13:23:08 +0000 |
parents | 61395f486647 |
children | 1609fb751561 |
files | osx/include/fftw3.h osx/include/lo/lo.h osx/include/lo/lo_endian.h osx/include/lo/lo_errors.h osx/include/lo/lo_lowlevel.h osx/include/lo/lo_macros.h osx/include/lo/lo_osc_types.h osx/include/lo/lo_throw.h osx/include/lo/lo_types.h osx/include/rubberband/RubberBandStretcher.h osx/include/rubberband/rubberband-c.h |
diffstat | 11 files changed, 3013 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/fftw3.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,409 @@ +/* + * Copyright (c) 2003, 2007-11 Matteo Frigo + * Copyright (c) 2003, 2007-11 Massachusetts Institute of Technology + * + * The following statement of license applies *only* to this header file, + * and *not* to the other files distributed with FFTW or derived therefrom: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 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. + * + * 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. + */ + +/***************************** NOTE TO USERS ********************************* + * + * THIS IS A HEADER FILE, NOT A MANUAL + * + * If you want to know how to use FFTW, please read the manual, + * online at http://www.fftw.org/doc/ and also included with FFTW. + * For a quick start, see the manual's tutorial section. + * + * (Reading header files to learn how to use a library is a habit + * stemming from code lacking a proper manual. Arguably, it's a + * *bad* habit in most cases, because header files can contain + * interfaces that are not part of the public, stable API.) + * + ****************************************************************************/ + +#ifndef FFTW3_H +#define FFTW3_H + +#include <stdio.h> + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* If <complex.h> is included, use the C99 complex type. Otherwise + define a type bit-compatible with C99 complex */ +#if !defined(FFTW_NO_Complex) && defined(_Complex_I) && defined(complex) && defined(I) +# define FFTW_DEFINE_COMPLEX(R, C) typedef R _Complex C +#else +# define FFTW_DEFINE_COMPLEX(R, C) typedef R C[2] +#endif + +#define FFTW_CONCAT(prefix, name) prefix ## name +#define FFTW_MANGLE_DOUBLE(name) FFTW_CONCAT(fftw_, name) +#define FFTW_MANGLE_FLOAT(name) FFTW_CONCAT(fftwf_, name) +#define FFTW_MANGLE_LONG_DOUBLE(name) FFTW_CONCAT(fftwl_, name) +#define FFTW_MANGLE_QUAD(name) FFTW_CONCAT(fftwq_, name) + +/* IMPORTANT: for Windows compilers, you should add a line + #define FFTW_DLL + here and in kernel/ifftw.h if you are compiling/using FFTW as a + DLL, in order to do the proper importing/exporting, or + alternatively compile with -DFFTW_DLL or the equivalent + command-line flag. This is not necessary under MinGW/Cygwin, where + libtool does the imports/exports automatically. */ +#if defined(FFTW_DLL) && (defined(_WIN32) || defined(__WIN32__)) + /* annoying Windows syntax for shared-library declarations */ +# if defined(COMPILING_FFTW) /* defined in api.h when compiling FFTW */ +# define FFTW_EXTERN extern __declspec(dllexport) +# else /* user is calling FFTW; import symbol */ +# define FFTW_EXTERN extern __declspec(dllimport) +# endif +#else +# define FFTW_EXTERN extern +#endif + +enum fftw_r2r_kind_do_not_use_me { + FFTW_R2HC=0, FFTW_HC2R=1, FFTW_DHT=2, + FFTW_REDFT00=3, FFTW_REDFT01=4, FFTW_REDFT10=5, FFTW_REDFT11=6, + FFTW_RODFT00=7, FFTW_RODFT01=8, FFTW_RODFT10=9, FFTW_RODFT11=10 +}; + +struct fftw_iodim_do_not_use_me { + int n; /* dimension size */ + int is; /* input stride */ + int os; /* output stride */ +}; + +#include <stddef.h> /* for ptrdiff_t */ +struct fftw_iodim64_do_not_use_me { + ptrdiff_t n; /* dimension size */ + ptrdiff_t is; /* input stride */ + ptrdiff_t os; /* output stride */ +}; + +typedef void (*fftw_write_char_func_do_not_use_me)(char c, void *); +typedef int (*fftw_read_char_func_do_not_use_me)(void *); + +/* + huge second-order macro that defines prototypes for all API + functions. We expand this macro for each supported precision + + X: name-mangling macro + R: real data type + C: complex data type +*/ + +#define FFTW_DEFINE_API(X, R, C) \ + \ +FFTW_DEFINE_COMPLEX(R, C); \ + \ +typedef struct X(plan_s) *X(plan); \ + \ +typedef struct fftw_iodim_do_not_use_me X(iodim); \ +typedef struct fftw_iodim64_do_not_use_me X(iodim64); \ + \ +typedef enum fftw_r2r_kind_do_not_use_me X(r2r_kind); \ + \ +typedef fftw_write_char_func_do_not_use_me X(write_char_func); \ +typedef fftw_read_char_func_do_not_use_me X(read_char_func); \ + \ +FFTW_EXTERN void X(execute)(const X(plan) p); \ + \ +FFTW_EXTERN X(plan) X(plan_dft)(int rank, const int *n, \ + C *in, C *out, int sign, unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_dft_1d)(int n, C *in, C *out, int sign, \ + unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_dft_2d)(int n0, int n1, \ + C *in, C *out, int sign, unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_dft_3d)(int n0, int n1, int n2, \ + C *in, C *out, int sign, unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_many_dft)(int rank, const int *n, \ + int howmany, \ + C *in, const int *inembed, \ + int istride, int idist, \ + C *out, const int *onembed, \ + int ostride, int odist, \ + int sign, unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_guru_dft)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + C *in, C *out, \ + int sign, unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_guru_split_dft)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + R *ri, R *ii, R *ro, R *io, \ + unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_guru64_dft)(int rank, \ + const X(iodim64) *dims, \ + int howmany_rank, \ + const X(iodim64) *howmany_dims, \ + C *in, C *out, \ + int sign, unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_guru64_split_dft)(int rank, \ + const X(iodim64) *dims, \ + int howmany_rank, \ + const X(iodim64) *howmany_dims, \ + R *ri, R *ii, R *ro, R *io, \ + unsigned flags); \ + \ +FFTW_EXTERN void X(execute_dft)(const X(plan) p, C *in, C *out); \ +FFTW_EXTERN void X(execute_split_dft)(const X(plan) p, R *ri, R *ii, \ + R *ro, R *io); \ + \ +FFTW_EXTERN X(plan) X(plan_many_dft_r2c)(int rank, const int *n, \ + int howmany, \ + R *in, const int *inembed, \ + int istride, int idist, \ + C *out, const int *onembed, \ + int ostride, int odist, \ + unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_dft_r2c)(int rank, const int *n, \ + R *in, C *out, unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_dft_r2c_1d)(int n,R *in,C *out,unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_dft_r2c_2d)(int n0, int n1, \ + R *in, C *out, unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_dft_r2c_3d)(int n0, int n1, \ + int n2, \ + R *in, C *out, unsigned flags); \ + \ + \ +FFTW_EXTERN X(plan) X(plan_many_dft_c2r)(int rank, const int *n, \ + int howmany, \ + C *in, const int *inembed, \ + int istride, int idist, \ + R *out, const int *onembed, \ + int ostride, int odist, \ + unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_dft_c2r)(int rank, const int *n, \ + C *in, R *out, unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_dft_c2r_1d)(int n,C *in,R *out,unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_dft_c2r_2d)(int n0, int n1, \ + C *in, R *out, unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_dft_c2r_3d)(int n0, int n1, \ + int n2, \ + C *in, R *out, unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_guru_dft_r2c)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + R *in, C *out, \ + unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_guru_dft_c2r)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + C *in, R *out, \ + unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_guru_split_dft_r2c)( \ + int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + R *in, R *ro, R *io, \ + unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_guru_split_dft_c2r)( \ + int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + R *ri, R *ii, R *out, \ + unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_guru64_dft_r2c)(int rank, \ + const X(iodim64) *dims, \ + int howmany_rank, \ + const X(iodim64) *howmany_dims, \ + R *in, C *out, \ + unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_guru64_dft_c2r)(int rank, \ + const X(iodim64) *dims, \ + int howmany_rank, \ + const X(iodim64) *howmany_dims, \ + C *in, R *out, \ + unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_guru64_split_dft_r2c)( \ + int rank, const X(iodim64) *dims, \ + int howmany_rank, \ + const X(iodim64) *howmany_dims, \ + R *in, R *ro, R *io, \ + unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_guru64_split_dft_c2r)( \ + int rank, const X(iodim64) *dims, \ + int howmany_rank, \ + const X(iodim64) *howmany_dims, \ + R *ri, R *ii, R *out, \ + unsigned flags); \ + \ +FFTW_EXTERN void X(execute_dft_r2c)(const X(plan) p, R *in, C *out); \ +FFTW_EXTERN void X(execute_dft_c2r)(const X(plan) p, C *in, R *out); \ + \ +FFTW_EXTERN void X(execute_split_dft_r2c)(const X(plan) p, \ + R *in, R *ro, R *io); \ +FFTW_EXTERN void X(execute_split_dft_c2r)(const X(plan) p, \ + R *ri, R *ii, R *out); \ + \ +FFTW_EXTERN X(plan) X(plan_many_r2r)(int rank, const int *n, \ + int howmany, \ + R *in, const int *inembed, \ + int istride, int idist, \ + R *out, const int *onembed, \ + int ostride, int odist, \ + const X(r2r_kind) *kind, unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_r2r)(int rank, const int *n, R *in, R *out, \ + const X(r2r_kind) *kind, unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_r2r_1d)(int n, R *in, R *out, \ + X(r2r_kind) kind, unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_r2r_2d)(int n0, int n1, R *in, R *out, \ + X(r2r_kind) kind0, X(r2r_kind) kind1, \ + unsigned flags); \ +FFTW_EXTERN X(plan) X(plan_r2r_3d)(int n0, int n1, int n2, \ + R *in, R *out, X(r2r_kind) kind0, \ + X(r2r_kind) kind1, X(r2r_kind) kind2, \ + unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_guru_r2r)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + R *in, R *out, \ + const X(r2r_kind) *kind, unsigned flags); \ + \ +FFTW_EXTERN X(plan) X(plan_guru64_r2r)(int rank, const X(iodim64) *dims, \ + int howmany_rank, \ + const X(iodim64) *howmany_dims, \ + R *in, R *out, \ + const X(r2r_kind) *kind, unsigned flags); \ + \ +FFTW_EXTERN void X(execute_r2r)(const X(plan) p, R *in, R *out); \ + \ +FFTW_EXTERN void X(destroy_plan)(X(plan) p); \ +FFTW_EXTERN void X(forget_wisdom)(void); \ +FFTW_EXTERN void X(cleanup)(void); \ + \ +FFTW_EXTERN void X(set_timelimit)(double t); \ + \ +FFTW_EXTERN void X(plan_with_nthreads)(int nthreads); \ +FFTW_EXTERN int X(init_threads)(void); \ +FFTW_EXTERN void X(cleanup_threads)(void); \ + \ +FFTW_EXTERN int X(export_wisdom_to_filename)(const char *filename); \ +FFTW_EXTERN void X(export_wisdom_to_file)(FILE *output_file); \ +FFTW_EXTERN char *X(export_wisdom_to_string)(void); \ +FFTW_EXTERN void X(export_wisdom)(X(write_char_func) write_char, \ + void *data); \ +FFTW_EXTERN int X(import_system_wisdom)(void); \ +FFTW_EXTERN int X(import_wisdom_from_filename)(const char *filename); \ +FFTW_EXTERN int X(import_wisdom_from_file)(FILE *input_file); \ +FFTW_EXTERN int X(import_wisdom_from_string)(const char *input_string); \ +FFTW_EXTERN int X(import_wisdom)(X(read_char_func) read_char, void *data); \ + \ +FFTW_EXTERN void X(fprint_plan)(const X(plan) p, FILE *output_file); \ +FFTW_EXTERN void X(print_plan)(const X(plan) p); \ + \ +FFTW_EXTERN void *X(malloc)(size_t n); \ +FFTW_EXTERN R *X(alloc_real)(size_t n); \ +FFTW_EXTERN C *X(alloc_complex)(size_t n); \ +FFTW_EXTERN void X(free)(void *p); \ + \ +FFTW_EXTERN void X(flops)(const X(plan) p, \ + double *add, double *mul, double *fmas); \ +FFTW_EXTERN double X(estimate_cost)(const X(plan) p); \ +FFTW_EXTERN double X(cost)(const X(plan) p); \ + \ +FFTW_EXTERN const char X(version)[]; \ +FFTW_EXTERN const char X(cc)[]; \ +FFTW_EXTERN const char X(codelet_optim)[]; + + +/* end of FFTW_DEFINE_API macro */ + +FFTW_DEFINE_API(FFTW_MANGLE_DOUBLE, double, fftw_complex) +FFTW_DEFINE_API(FFTW_MANGLE_FLOAT, float, fftwf_complex) +FFTW_DEFINE_API(FFTW_MANGLE_LONG_DOUBLE, long double, fftwl_complex) + +/* __float128 (quad precision) is a gcc extension on i386, x86_64, and ia64 + for gcc >= 4.6 (compiled in FFTW with --enable-quad-precision) */ +#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) \ + && (defined(__i386__) || defined(__x86_64__) || defined(__ia64__)) +# if !defined(FFTW_NO_Complex) && defined(_Complex_I) && defined(complex) && defined(I) +/* note: __float128 is a typedef, which is not supported with the _Complex + keyword in gcc, so instead we use this ugly __attribute__ version. + However, we can't simply pass the __attribute__ version to + FFTW_DEFINE_API because the __attribute__ confuses gcc in pointer + types. Hence redefining FFTW_DEFINE_COMPLEX. Ugh. */ +# undef FFTW_DEFINE_COMPLEX +# define FFTW_DEFINE_COMPLEX(R, C) typedef _Complex float __attribute__((mode(TC))) C +# endif +FFTW_DEFINE_API(FFTW_MANGLE_QUAD, __float128, fftwq_complex) +#endif + +#define FFTW_FORWARD (-1) +#define FFTW_BACKWARD (+1) + +#define FFTW_NO_TIMELIMIT (-1.0) + +/* documented flags */ +#define FFTW_MEASURE (0U) +#define FFTW_DESTROY_INPUT (1U << 0) +#define FFTW_UNALIGNED (1U << 1) +#define FFTW_CONSERVE_MEMORY (1U << 2) +#define FFTW_EXHAUSTIVE (1U << 3) /* NO_EXHAUSTIVE is default */ +#define FFTW_PRESERVE_INPUT (1U << 4) /* cancels FFTW_DESTROY_INPUT */ +#define FFTW_PATIENT (1U << 5) /* IMPATIENT is default */ +#define FFTW_ESTIMATE (1U << 6) + +/* undocumented beyond-guru flags */ +#define FFTW_ESTIMATE_PATIENT (1U << 7) +#define FFTW_BELIEVE_PCOST (1U << 8) +#define FFTW_NO_DFT_R2HC (1U << 9) +#define FFTW_NO_NONTHREADED (1U << 10) +#define FFTW_NO_BUFFERING (1U << 11) +#define FFTW_NO_INDIRECT_OP (1U << 12) +#define FFTW_ALLOW_LARGE_GENERIC (1U << 13) /* NO_LARGE_GENERIC is default */ +#define FFTW_NO_RANK_SPLITS (1U << 14) +#define FFTW_NO_VRANK_SPLITS (1U << 15) +#define FFTW_NO_VRECURSE (1U << 16) +#define FFTW_NO_SIMD (1U << 17) +#define FFTW_NO_SLOW (1U << 18) +#define FFTW_NO_FIXED_RADIX_LARGE_N (1U << 19) +#define FFTW_ALLOW_PRUNING (1U << 20) +#define FFTW_WISDOM_ONLY (1U << 21) + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* FFTW3_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/lo/lo.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,353 @@ +/* + * Copyright (C) 2004 Steve Harris + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * $Id$ + */ + +#ifndef LO_H +#define LO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file lo.h The liblo main headerfile and high-level API functions. + */ + +#include "lo/lo_endian.h" +#include "lo/lo_types.h" +#include "lo/lo_osc_types.h" +#include "lo/lo_errors.h" +#include "lo/lo_lowlevel.h" + +/** + * \defgroup liblo High-level OSC API + * + * Defines the high-level API functions necessary to implement OSC support. + * Should be adequate for most applications, but if you require lower level + * control you can use the functions defined in lo_lowlevel.h + * @{ + */ + +/** + * \brief Declare an OSC destination, given IP address and port number. + * Same as lo_address_new_with_proto(), but using UDP. + * + * \param host An IP address or number, or NULL for the local machine. + * \param port a decimal port number or service name. + * + * The lo_address object may be used as the target of OSC messages. + * + * Note: if you wish to receive replies from the target of this address, you + * must first create a lo_server_thread or lo_server object which will receive + * the replies. The last lo_server(_thread) object creted will be the receiver. + */ +lo_address lo_address_new(const char *host, const char *port); + +/** + * \brief Declare an OSC destination, given IP address and port number, + * specifying protocol. + * + * \param proto The protocol to use, must be one of LO_UDP, LO_TCP or LO_UNIX. + * \param host An IP address or number, or NULL for the local machine. + * \param port a decimal port number or service name. + * + * The lo_address object may be used as the target of OSC messages. + * + * Note: if you wish to receive replies from the target of this address, you + * must first create a lo_server_thread or lo_server object which will receive + * the replies. The last lo_server(_thread) object creted will be the receiver. + */ +lo_address lo_address_new_with_proto(int proto, const char *host, const char *port); + +/** + * \brief Create a lo_address object from an OSC URL. + * + * example: \c "osc.udp://localhost:4444/my/path/" + */ +lo_address lo_address_new_from_url(const char *url); + +/** + * \brief Free the memory used by the lo_address object + */ +void lo_address_free(lo_address t); + +/** + * \brief Set the Time-to-Live value for a given target address. + * + * This is required for sending multicast UDP messages. A value of 1 + * (the usual case) keeps the message within the subnet, while 255 + * means a global, unrestricted scope. + * + * \param t An OSC address. + * \param ttl An integer specifying the scope of a multicast UDP message. + */ +void lo_address_set_ttl(lo_address t, int ttl); + +/** + * \brief Get the Time-to-Live value for a given target address. + * + * \param t An OSC address. + * \return An integer specifying the scope of a multicast UDP message. + */ +int lo_address_get_ttl(lo_address t); + +/** + * \brief Send a OSC formatted message to the address specified. + * + * \param targ The target OSC address + * \param path The OSC path the message will be delivered to + * \param type The types of the data items in the message, types are defined in + * lo_osc_types.h + * \param ... The data values to be transmitted. The types of the arguments + * passed here must agree with the types specified in the type parameter. + * + * example: + * \code + * lo_send(t, "/foo/bar", "ff", 0.1f, 23.0f); + * \endcode + * + * \return -1 on failure. + */ +int lo_send(lo_address targ, const char *path, const char *type, ...); + +/** + * \brief Send a OSC formatted message to the address specified, + * from the same socket as the specificied server. + * + * \param targ The target OSC address + * \param from The server to send message from (can be NULL to use new socket) + * \param ts The OSC timetag timestamp at which the message will be processed + * (can be LO_TT_IMMEDIATE if you don't want to attach a timetag) + * \param path The OSC path the message will be delivered to + * \param type The types of the data items in the message, types are defined in + * lo_osc_types.h + * \param ... The data values to be transmitted. The types of the arguments + * passed here must agree with the types specified in the type parameter. + * + * example: + * \code + * serv = lo_server_new(NULL, err); + * lo_server_add_method(serv, "/reply", "ss", reply_handler, NULL); + * lo_send_from(t, serv, LO_TT_IMMEDIATE, "/foo/bar", "ff", 0.1f, 23.0f); + * \endcode + * + * \return on success, the number of bytes sent, or -1 on failure. + */ +int lo_send_from(lo_address targ, lo_server from, lo_timetag ts, + const char *path, const char *type, ...); + +/** + * \brief Send a OSC formatted message to the address specified, scheduled to + * be dispatch at some time in the future. + * + * \param targ The target OSC address + * \param ts The OSC timetag timestamp at which the message will be processed + * \param path The OSC path the message will be delivered to + * \param type The types of the data items in the message, types are defined in + * lo_osc_types.h + * \param ... The data values to be transmitted. The types of the arguments + * passed here must agree with the types specified in the type parameter. + * + * example: + * \code + * lo_timetag now;<br> + * lo_timetag_now(&now);<br> + * lo_send_timestamped(t, now, "/foo/bar", "ff", 0.1f, 23.0f); + * \endcode + * + * \return on success, the number of bytes sent, or -1 on failure. + */ +int lo_send_timestamped(lo_address targ, lo_timetag ts, const char *path, + const char *type, ...); + +/** + * \brief Return the error number from the last failed lo_send() or + * lo_address_new() call + */ +int lo_address_errno(lo_address a); + +/** + * \brief Return the error string from the last failed lo_send() or + * lo_address_new() call + */ +const char *lo_address_errstr(lo_address a); + +/** + * \brief Create a new server thread to handle incoming OSC + * messages. + * + * Server threads take care of the message reception and dispatch by + * transparently creating a system thread to handle incoming messages. + * Use this if you do not want to handle the threading yourself. + * + * \param port If NULL is passed then an unused port will be chosen by the + * system, its number may be retrieved with lo_server_thread_get_port() + * so it can be passed to clients. Otherwise a decimal port number, service + * name or UNIX domain socket path may be passed. + * \param err_h A function that will be called in the event of an error being + * raised. The function prototype is defined in lo_types.h + */ +lo_server_thread lo_server_thread_new(const char *port, lo_err_handler err_h); + +/** + * \brief Create a new server thread to handle incoming OSC + * messages, and join a UDP multicast group. + * + * Server threads take care of the message reception and dispatch by + * transparently creating a system thread to handle incoming messages. + * Use this if you do not want to handle the threading yourself. + * + * \param group The multicast group to join. See documentation on IP + * multicast for the acceptable address range; e.g., http://tldp.org/HOWTO/Multicast-HOWTO-2.html + * \param port If NULL is passed then an unused port will be chosen by the + * system, its number may be retrieved with lo_server_thread_get_port() + * so it can be passed to clients. Otherwise a decimal port number, service + * name or UNIX domain socket path may be passed. + * \param err_h A function that will be called in the event of an error being + * raised. The function prototype is defined in lo_types.h + */ +lo_server_thread lo_server_thread_new_multicast(const char *group, const char *port, + lo_err_handler err_h); + +/** + * \brief Create a new server thread to handle incoming OSC + * messages, specifying protocol. + * + * Server threads take care of the message reception and dispatch by + * transparently creating a system thread to handle incoming messages. + * Use this if you do not want to handle the threading yourself. + * + * \param port If NULL is passed then an unused port will be chosen by the + * system, its number may be retrieved with lo_server_thread_get_port() + * so it can be passed to clients. Otherwise a decimal port number, service + * name or UNIX domain socket path may be passed. + * \param proto The protocol to use, should be one of LO_UDP, LO_TCP or LO_UNIX. + * \param err_h A function that will be called in the event of an error being + * raised. The function prototype is defined in lo_types.h + */ +lo_server_thread lo_server_thread_new_with_proto(const char *port, int proto, + lo_err_handler err_h); + +/** + * \brief Free memory taken by a server thread + * + * Frees the memory, and, if currently running will stop the associated thread. + */ +void lo_server_thread_free(lo_server_thread st); + +/** + * \brief Add an OSC method to the specifed server thread. + * + * \param st The server thread the method is to be added to. + * \param path The OSC path to register the method to. If NULL is passed the + * method will match all paths. + * \param typespec The typespec the method accepts. Incoming messages with + * similar typespecs (e.g. ones with numerical types in the same position) will + * be coerced to the typespec given here. + * \param h The method handler callback function that will be called it a + * matching message is received + * \param user_data A value that will be passed to the callback function, h, + * when its invoked matching from this method. + */ +lo_method lo_server_thread_add_method(lo_server_thread st, const char *path, + const char *typespec, lo_method_handler h, + void *user_data); +/** + * \brief Delete an OSC method from the specifed server thread. + * + * \param st The server thread the method is to be removed from. + * \param path The OSC path of the method to delete. If NULL is passed the + * method will match the generic handler. + * \param typespec The typespec the method accepts. + */ +void lo_server_thread_del_method(lo_server_thread st, const char *path, + const char *typespec); + +/** + * \brief Start the server thread + * + * \param st the server thread to start. + * \return Less than 0 on failure, 0 on success. + */ +int lo_server_thread_start(lo_server_thread st); + +/** + * \brief Stop the server thread + * + * \param st the server thread to start. + * \return Less than 0 on failure, 0 on success. + */ +int lo_server_thread_stop(lo_server_thread st); + +/** + * \brief Return the port number that the server thread has bound to. + */ +int lo_server_thread_get_port(lo_server_thread st); + +/** + * \brief Return a URL describing the address of the server thread. + * + * Return value must be free()'d to reclaim memory. + */ +char *lo_server_thread_get_url(lo_server_thread st); + +/** + * \brief Return the lo_server for a lo_server_thread + * + * This function is useful for passing a thread's lo_server + * to lo_send_from(). + */ +lo_server lo_server_thread_get_server(lo_server_thread st); + +/** \brief Return true if there are scheduled events (eg. from bundles) waiting + * to be dispatched by the thread */ +int lo_server_thread_events_pending(lo_server_thread st); + +/** + * \brief Create a new OSC blob type. + * + * \param size The amount of space to allocate in the blob structure. + * \param data The data that will be used to initialise the blob, should be + * size bytes long. + */ +lo_blob lo_blob_new(int32_t size, const void *data); + +/** + * \brief Free the memory taken by a blob + */ +void lo_blob_free(lo_blob b); + +/** + * \brief Return the amount of valid data in a lo_blob object. + * + * If you want to know the storage size, use lo_arg_size(). + */ +uint32_t lo_blob_datasize(lo_blob b); + +/** + * \brief Return a pointer to the start of the blob data to allow contents to + * be changed. + */ +void *lo_blob_dataptr(lo_blob b); + +/** @} */ + +#include "lo/lo_macros.h" + +#ifdef __cplusplus +} +#endif + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/lo/lo_endian.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2004 Steve Harris + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * $Id$ + */ + +#ifndef LO_ENDIAN_H +#define LO_ENDIAN_H + +#include <sys/types.h> +#include <stdint.h> + +#ifdef WIN32 +#include <winsock2.h> +#include <ws2tcpip.h> +#else +#include <netinet/in.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define lo_swap16(x) htons(x) + +#define lo_swap32(x) htonl(x) + +/* These macros come from the Linux kernel */ + +#ifndef lo_swap16 +#define lo_swap16(x) \ +({ \ + uint16_t __x = (x); \ + ((uint16_t)( \ + (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \ + (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \ +}) +#warning USING UNOPTIMISED ENDIAN STUFF +#endif + +#ifndef lo_swap32 +#define lo_swap32(x) \ +({ \ + uint32_t __x = (x); \ + ((uint32_t)( \ + (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ + (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ +}) +#endif + +#if 0 +#ifndef lo_swap64 +#define lo_swap64(x) \ +({ \ + uint64_t __x = (x); \ + ((uint64_t)( \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \ +}) +#endif +#else + +typedef union { + uint64_t all; + struct { + uint32_t a; + uint32_t b; + } part; +} lo_split64; + +static inline uint64_t lo_swap64(uint64_t x) +{ + lo_split64 in, out; + + in.all = x; + out.part.a = lo_swap32(in.part.b); + out.part.b = lo_swap32(in.part.a); + + return out.all; +} +#endif + +/* Host to OSC and OSC to Host conversion macros */ + +#if 0 +#define lo_htoo16(x) (x) +#define lo_htoo32(x) (x) +#define lo_htoo64(x) (x) +#define lo_otoh16(x) (x) +#define lo_otoh32(x) (x) +#define lo_otoh64(x) (x) +#else +#define lo_htoo16 lo_swap16 +#define lo_htoo32 lo_swap32 +#define lo_htoo64 lo_swap64 +#define lo_otoh16 lo_swap16 +#define lo_otoh32 lo_swap32 +#define lo_otoh64 lo_swap64 +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +/* vi:set ts=8 sts=4 sw=4: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/lo/lo_errors.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2004 Steve Harris + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * $Id$ + */ + +#ifndef LO_ERRORS_H +#define LO_ERRORS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define LO_ENOPATH 9901 +#define LO_ENOTYPE 9902 +#define LO_UNKNOWNPROTO 9903 +#define LO_NOPORT 9904 +#define LO_TOOBIG 9905 +#define LO_INT_ERR 9906 +#define LO_EALLOC 9907 +#define LO_EINVALIDPATH 9908 +#define LO_EINVALIDTYPE 9909 +#define LO_EBADTYPE 9910 +#define LO_ESIZE 9911 +#define LO_EINVALIDARG 9912 +#define LO_ETERM 9913 +#define LO_EPAD 9914 +#define LO_EINVALIDBUND 9915 +#define LO_EINVALIDTIME 9916 + +#ifdef __cplusplus +} +#endif + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/lo/lo_lowlevel.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,860 @@ +/* + * Copyright (C) 2004 Steve Harris + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * $Id$ + */ + +#ifndef LO_LOWLEVEL_H +#define LO_LOWLEVEL_H + +#include "lo/lo_osc_types.h" + +/** + * \file lo_lowlevel.h The liblo headerfile defining the low-level API + * functions. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdarg.h> +#ifdef _MSC_VER +#define ssize_t SSIZE_T +#define uint32_t unsigned __int32 +#else +#include <stdint.h> +#endif + +#include "lo/lo_types.h" +#include "lo/lo_errors.h" + +/** + * \defgroup liblolowlevel Low-level OSC API + * + * Use these functions if you require more precise control over OSC message + * contruction or handling that what is provided in the high-level functions + * described in liblo. + * @{ + */ + +/** + * \brief Type used to represent numerical values in conversions between OSC + * types. + */ +typedef long double lo_hires; + + + + +/** + * \brief Send a lo_message object to target targ + * + * This is slightly more efficient than lo_send() if you want to send a lot of + * similar messages. The messages are constructed with the lo_message_new() and + * \ref lo_message_add_int32 "lo_message_add*()" functions. + */ +int lo_send_message(lo_address targ, const char *path, lo_message msg); + +/** + * \brief Send a lo_message object to target targ from address of serv + * + * This is slightly more efficient than lo_send() if you want to send a lot of + * similar messages. The messages are constructed with the lo_message_new() and + * \ref lo_message_add_int32 "lo_message_add*()" functions. + * + * \param targ The address to send the message to + * \param serv The server socket to send the message from + * (can be NULL to use new socket) + * \param path The path to send the message to + * \param msg The bundle itself + */ +int lo_send_message_from(lo_address targ, lo_server serv, + const char *path, lo_message msg); + +/** + * \brief Send a lo_bundle object to address targ + * + * Bundles are constructed with the + * lo_bundle_new() and lo_bundle_add_message() functions. + */ +int lo_send_bundle(lo_address targ, lo_bundle b); + +/** + * \brief Send a lo_bundle object to address targ from address of serv + * + * Bundles are constructed with the + * lo_bundle_new() and lo_bundle_add_message() functions. + * + * \param targ The address to send the bundle to + * \param serv The server socket to send the bundle from + * (can be NULL to use new socket) + * \param b The bundle itself + */ +int lo_send_bundle_from(lo_address targ, lo_server serv, lo_bundle b); + +/** + * \brief Create a new lo_message object + */ +lo_message lo_message_new(); + +/** + * \brief Free memory allocated by lo_message_new() and any subsequent + * \ref lo_message_add_int32 lo_message_add*() calls. + */ +void lo_message_free(lo_message m); + +/** + * \brief Append a number of arguments to a message. + * + * The data will be added in OSC byteorder (bigendian). + * + * \param m The message to be extended. + * \param types The types of the data items in the message, types are defined in + * lo_types_common.h + * \param ... The data values to be transmitted. The types of the arguments + * passed here must agree with the types specified in the type parameter. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add(lo_message m, const char *types, ...); + +/** \internal \brief the real message_add function (don't call directly) */ +int lo_message_add_internal(lo_message m, const char *file, const int line, + const char *types, ...); + +/** + * \brief Append a varargs list to a message. + * + * The data will be added in OSC byteorder (bigendian). + * IMPORTANT: args list must be terminated with LO_ARGS_END, or this call will + * fail. This is used to do simple error checking on the sizes of parameters + * passed. + * + * \param m The message to be extended. + * \param types The types of the data items in the message, types are defined in + * lo_types_common.h + * \param ap The va_list created by a C function declared with an + * ellipsis (...) argument, and pre-initialised with + * "va_start(ap)". The types of the arguments passed here must agree + * with the types specified in the type parameter. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_varargs(lo_message m, const char *types, va_list ap); + +/** \internal \brief the real message_add_varargs function (don't call directly) */ +int lo_message_add_varargs_internal(lo_message m, const char *types, va_list ap, + const char *file, const int line); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * + * The data will be added in OSC byteorder (bigendian). + * + * \param m The message to be extended. + * \param a The data item. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_int32(lo_message m, int32_t a); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_float(lo_message m, float a); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_string(lo_message m, const char *a); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_blob(lo_message m, lo_blob a); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_int64(lo_message m, int64_t a); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_timetag(lo_message m, lo_timetag a); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_double(lo_message m, double a); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_symbol(lo_message m, const char *a); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_char(lo_message m, char a); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_midi(lo_message m, uint8_t a[4]); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_true(lo_message m); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_false(lo_message m); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_nil(lo_message m); + +/** + * \brief Append a data item and typechar of the specified type to a message. + * See lo_message_add_int32() for details. + * + * \return Less than 0 on failure, 0 on success. + */ +int lo_message_add_infinitum(lo_message m); + +/** + * \brief Returns the source (lo_address) of an incoming message. + * + * Returns NULL if the message is outgoing. Do not free the returned address. + */ +lo_address lo_message_get_source(lo_message m); + +/** + * \brief Returns the timestamp (lo_timetag *) of a bundled incoming message. + * + * Returns LO_TT_IMMEDIATE if the message is outgoing, or did not arrive + * contained in a bundle. Do not free the returned timetag. + */ +lo_timetag lo_message_get_timestamp(lo_message m); + +/** + * \brief Return the message type tag string. + * + * The result is valid until further data is added with lo_message_add*(). + */ +char *lo_message_get_types(lo_message m); + +/** + * \brief Return the message argument count. + * + * The result is valid until further data is added with lo_message_add*(). + */ +int lo_message_get_argc(lo_message m); + +/** + * \brief Return the message arguments. Do not free the returned data. + * + * The result is valid until further data is added with lo_message_add*(). + */ +lo_arg **lo_message_get_argv(lo_message m); + +/** + * \brief Return the length of a message in bytes. + * + * \param m The message to be sized + * \param path The path the message will be sent to + */ +size_t lo_message_length(lo_message m, const char *path); + +/** + * \brief Serialise the lo_message object to an area of memory and return a + * pointer to the serialised form. Opposite of lo_message_deserialise(). + * + * \param m The message to be serialised + * \param path The path the message will be sent to + * \param to The address to serialise to, memory will be allocated if to is + * NULL. + * \param size If this pointer is non-NULL the size of the memory area + * will be written here + * + * The returned form is suitable to be sent over a low level OSC transport, + * having the correct endianess and bit-packed structure. + */ +void *lo_message_serialise(lo_message m, const char *path, void *to, + size_t *size); + +/** + * \brief Deserialise a raw OSC message and return a new lo_message object. + * Opposite of lo_message_serialise(). + * + * \param data Pointer to the raw OSC message data in network transmission form + * (network byte order where appropriate). + * \param size The size of data in bytes + * \param result If this pointer is non-NULL, the result or error code will + * be written here. + * + * Returns a new lo_message, or NULL if deserialisation fails. + * Use lo_message_free() to free the resulting object. + */ +lo_message lo_message_deserialise(void *data, size_t size, int *result); + +/** + * \brief Dispatch a raw block of memory containing an OSC message. + * + * This is useful when a raw block of memory is available that is + * structured as OSC, and you wish to use liblo to dispatch the + * message to a handler function as if it had been received over the + * network. + * + * \param s The lo_server to use for dispatching. + * \param data Pointer to the raw OSC message data in network transmission form + * (network byte order where appropriate). + * \param size The size of data in bytes + * + * Returns the number of bytes used if successful, or less than 0 otherwise. + */ +int lo_server_dispatch_data(lo_server s, void *data, size_t size); + +/** + * \brief Return the hostname of a lo_address object + * + * Returned value must not be modified or free'd. Value will be a dotted quad, + * colon'd IPV6 address, or resolvable name. + */ +const char *lo_address_get_hostname(lo_address a); + +/** + * \brief Return the port/service name of a lo_address object + * + * Returned value must not be modified or free'd. Value will be a service name + * or ASCII representation of the port number. + */ +const char *lo_address_get_port(lo_address a); + +/** + * \brief Return the protocol of a lo_address object + * + * Returned value will be one of LO_UDP, LO_TCP or LO_UNIX. + */ +int lo_address_get_protocol(lo_address a); + +/** + * \brief Return a URL representing an OSC address + * + * Returned value must be free'd. + */ +char *lo_address_get_url(lo_address a); + +/** + * \brief Set the Time-to-Live value for a given target address. + * + * This is required for sending multicast UDP messages. A value of 1 + * (the usual case) keeps the message within the subnet, while 255 + * means a global, unrestricted scope. + * + * \param t An OSC address. + * \param ttl An integer specifying the scope of a multicast UDP message. + */ +void lo_address_set_ttl(lo_address t, int ttl); + +/** + * \brief Get the Time-to-Live value for a given target address. + * + * \param t An OSC address. + * \return An integer specifying the scope of a multicast UDP message. + */ +int lo_address_get_ttl(lo_address t); + +/** + * \brief Create a new bundle object. + * + * OSC Bundles encapsulate one or more OSC messages and may include a timestamp + * indicating when the bundle should be dispatched. + * + * \param tt The timestamp when the bundle should be handled by the receiver. + * Pass LO_TT_IMMEDIATE if you want the receiving server to dispatch + * the bundle as soon as it receives it. + */ +lo_bundle lo_bundle_new(lo_timetag tt); + +/** + * \brief Adds an OSC message to an existing bundle. + * + * The message passed is appended to the list of messages in the bundle to be + * dispatched to 'path'. + * + * \return 0 if successful, less than 0 otherwise. + */ +int lo_bundle_add_message(lo_bundle b, const char *path, lo_message m); + +/** + * \brief Return the length of a bundle in bytes. + * + * Includes the marker and typetage length. + * + * \param b The bundle to be sized + */ +size_t lo_bundle_length(lo_bundle b); + +/** + * \brief Serialise the bundle object to an area of memory and return a + * pointer to the serialised form. + * + * \param b The bundle to be serialised + * \param to The address to serialise to, memory will be allocated if to is + * NULL. + * \param size If this pointer is non-NULL the size of the memory area + * will be written here + * + * The returned form is suitable to be sent over a low level OSC transport, + * having the correct endianess and bit-packed structure. + */ +void *lo_bundle_serialise(lo_bundle b, void *to, size_t *size); + +/** + * \brief Frees the memory taken by a bundle object. + * + * \param b The bundle to be freed. +*/ +void lo_bundle_free(lo_bundle b); + +/** + * \brief Frees the memory taken by a bundle object and messages in the bundle. + * + * \param b The bundle, which may contain messages, to be freed. +*/ +void lo_bundle_free_messages(lo_bundle b); + +/** + * \brief Return true if the type specified has a numerical value, such as + * LO_INT32, LO_FLOAT etc. + * + * \param a The type to be tested. + */ +int lo_is_numerical_type(lo_type a); + +/** + * \brief Return true if the type specified has a textual value, such as + * LO_STRING or LO_SYMBOL. + * + * \param a The type to be tested. + */ +int lo_is_string_type(lo_type a); + +/** + * \brief Attempt to convert one OSC type to another. + * + * Numerical types (eg LO_INT32, LO_FLOAT etc.) may be converted to other + * numerical types and string types (LO_STRING and LO_SYMBOL) may be converted + * to the other type. This is done automatically if a received message matches + * the path, but not the exact types, and is coercible (ie. all numerical + * types in numerical positions). + * + * On failure no translation occurs and false is returned. + * + * \param type_to The type of the destination variable. + * \param to A pointer to the destination variable. + * \param type_from The type of the source variable. + * \param from A pointer to the source variable. + */ +int lo_coerce(lo_type type_to, lo_arg *to, lo_type type_from, lo_arg *from); + +/** + * \brief Return the numerical value of the given argument with the + * maximum native system precision. + */ +lo_hires lo_hires_val(lo_type type, lo_arg *p); + +/** + * \brief Create a new server instance. + * + * Using lo_server_recv(), lo_servers block until they receive OSC + * messages. If you want non-blocking behaviour see + * lo_server_recv_noblock() or the \ref lo_server_thread_new + * "lo_server_thread_*" functions. + * + * \param port If NULL is passed then an unused UDP port will be chosen by the + * system, its number may be retrieved with lo_server_thread_get_port() + * so it can be passed to clients. Otherwise a decimal port number, service + * name or UNIX domain socket path may be passed. + * \param err_h An error callback function that will be called if there is an + * error in messge reception or server creation. Pass NULL if you do not want + * error handling. + */ +lo_server lo_server_new(const char *port, lo_err_handler err_h); + +/** + * \brief Create a new server instance, specifying protocol. + * + * Using lo_server_recv(), lo_servers block until they receive OSC + * messages. If you want non-blocking behaviour see + * lo_server_recv_noblock() or the \ref lo_server_thread_new + * "lo_server_thread_*" functions. + * + * \param port If using UDP then NULL may be passed to find an unused port. + * Otherwise a decimal port number orservice name or may be passed. + * If using UNIX domain sockets then a socket path should be passed here. + * \param proto The protocol to use, should be one of LO_UDP, LO_TCP or LO_UNIX. + * \param err_h An error callback function that will be called if there is an + * error in messge reception or server creation. Pass NULL if you do not want + * error handling. + */ +lo_server lo_server_new_with_proto(const char *port, int proto, + lo_err_handler err_h); + +/** + * \brief Create a new server instance, and join a UDP multicast group. + * + * \param group The multicast group to join. See documentation on IP + * multicast for the acceptable address range; e.g., http://tldp.org/HOWTO/Multicast-HOWTO-2.html + * \param port If using UDP then NULL may be passed to find an unused port. + * Otherwise a decimal port number or service name or may be passed. + * If using UNIX domain sockets then a socket path should be passed here. + * \param err_h An error callback function that will be called if there is an + * error in messge reception or server creation. Pass NULL if you do not want + * error handling. + */ +lo_server lo_server_new_multicast(const char *group, const char *port, + lo_err_handler err_h); + +/** + * \brief Free up memory used by the lo_server object + */ +void lo_server_free(lo_server s); + +/** + * \brief Wait for an OSC message to be received + * + * \param s The server to wait for connections on. + * \param timeout A timeout in milliseconds to wait for the incoming packet. + * a value of 0 will return immediately. + * + * The return value is 1 if there is a message waiting or 0 if + * there is no message. If there is a message waiting you can now + * call lo_server_recv() to receive that message. + */ +int lo_server_wait(lo_server s, int timeout); + +/** + * \brief Look for an OSC message waiting to be received + * + * \param s The server to wait for connections on. + * \param timeout A timeout in milliseconds to wait for the incoming packet. + * a value of 0 will return immediately. + * + * The return value is the number of bytes in the received message or 0 if + * there is no message. The message will be dispatched to a matching method + * if one is found. + */ +int lo_server_recv_noblock(lo_server s, int timeout); + +/** + * \brief Block, waiting for an OSC message to be received + * + * The return value is the number of bytes in the received message. The message + * will be dispatched to a matching method if one is found. + */ +int lo_server_recv(lo_server s); + +/** + * \brief Add an OSC method to the specifed server. + * + * \param s The server the method is to be added to. + * \param path The OSC path to register the method to. If NULL is passed the + * method will match all paths. + * \param typespec The typespec the method accepts. Incoming messages with + * similar typespecs (e.g. ones with numerical types in the same position) will + * be coerced to the typespec given here. + * \param h The method handler callback function that will be called if a + * matching message is received + * \param user_data A value that will be passed to the callback function, h, + * when its invoked matching from this method. + */ +lo_method lo_server_add_method(lo_server s, const char *path, + const char *typespec, lo_method_handler h, + void *user_data); + +/** + * \brief Delete an OSC method from the specifed server. + * + * \param s The server the method is to be removed from. + * \param path The OSC path of the method to delete. If NULL is passed the + * method will match the generic handler. + * \param typespec The typespec the method accepts. + */ +void lo_server_del_method(lo_server s, const char *path, + const char *typespec); + +/** + * \brief Return the file descriptor of the server socket. + * + * If the server protocol supports exposing the server's underlying + * receive mechanism for monitoring with select() or poll(), this function + * returns the file descriptor needed, otherwise, it returns -1. + * + * WARNING: when using this function beware that not all OSC packets that are + * received are dispatched immediately. lo_server_events_pending() and + * lo_server_next_event_delay() can be used to tell if there are pending + * events and how long before you should attempt to receive them. + */ +int lo_server_get_socket_fd(lo_server s); + +/** + * \brief Return the port number that the server has bound to. + * + * Useful when NULL is passed for the port number and you wish to know how to + * address the server. + */ +int lo_server_get_port(lo_server s); + +/** + * \brief Return the protocol that the server is using. + * + * Returned value will be one of LO_UDP, LO_TCP or LO_UNIX. + */ +int lo_server_get_protocol(lo_server s); + +/** + * \brief Return an OSC URL that can be used to contact the server. + * + * The return value should be free()'d when it is no longer needed. + */ +char *lo_server_get_url(lo_server s); + +/** + * \brief Return true if there are scheduled events (eg. from bundles) + * waiting to be dispatched by the server + */ +int lo_server_events_pending(lo_server s); + +/** + * \brief Return the time in seconds until the next scheduled event. + * + * If the delay is greater than 100 seconds then it will return 100.0. + */ +double lo_server_next_event_delay(lo_server s); + +/** + * \brief Return the protocol portion of an OSC URL, eg. udp, tcp. + * + * This library uses OSC URLs of the form: osc.prot://hostname:port/path if the + * prot part is missing, UDP is assumed. + * + * The return value should be free()'d when it is no longer needed. + */ +char *lo_url_get_protocol(const char *url); + +/** + * \brief Return the protocol ID of an OSC URL. + * + * This library uses OSC URLs of the form: osc.prot://hostname:port/path if the + * prot part is missing, UDP is assumed. + * Returned value will be one of LO_UDP, LO_TCP, LO_UNIX or -1. + * + * \return An integer specifying the protocol. Return -1 when the protocol is + * not supported by liblo. + * + */ +int lo_url_get_protocol_id(const char *url); + +/** + * \brief Return the hostname portion of an OSC URL. + * + * The return value should be free()'d when it is no longer needed. + */ +char *lo_url_get_hostname(const char *url); + +/** + * \brief Return the port portion of an OSC URL. + * + * The return value should be free()'d when it is no longer needed. + */ +char *lo_url_get_port(const char *url); + +/** + * \brief Return the path portion of an OSC URL. + * + * The return value should be free()'d when it is no longer needed. + */ +char *lo_url_get_path(const char *url); + +/* utility functions */ + +/** + * \brief A function to calculate the amount of OSC message space required by a + * C char *. + * + * Returns the storage size in bytes, which will always be a multiple of four. + */ +int lo_strsize(const char *s); + +/** + * \brief A function to calculate the amount of OSC message space required by a + * lo_blob object. + * + * Returns the storage size in bytes, which will always be a multiple of four. + */ +uint32_t lo_blobsize(lo_blob b); + +/** + * \brief Test a string against an OSC pattern glob + * + * \param str The string to test + * \param p The pattern to test against + */ +int lo_pattern_match(const char *str, const char *p); + +/** \internal \brief the real send function (don't call directly) */ +int lo_send_internal(lo_address t, const char *file, const int line, + const char *path, const char *types, ...); +/** \internal \brief the real send_timestamped function (don't call directly) */ +int lo_send_timestamped_internal(lo_address t, const char *file, const int line, + lo_timetag ts, const char *path, const char *types, ...); +/** \internal \brief the real lo_send_from() function (don't call directly) */ +int lo_send_from_internal(lo_address targ, lo_server from, const char *file, + const int line, const lo_timetag ts, + const char *path, const char *types, ...); + + +/** \brief Find the time difference between two timetags + * + * Returns a - b in seconds. + */ +double lo_timetag_diff(lo_timetag a, lo_timetag b); + +/** \brief Return a timetag for the current time + * + * On exit the timetag pointed to by t is filled with the OSC + * representation of this instant in time. + */ +void lo_timetag_now(lo_timetag *t); + +/** + * \brief Return the storage size, in bytes, of the given argument. + */ +size_t lo_arg_size(lo_type type, void *data); + +/** + * \brief Given a raw OSC message, return the message path. + * + * \param data A pointer to the raw OSC message data. + * \param size The size of data in bytes (total buffer bytes). + * + * Returns the message path or NULL if an error occurs. + * Do not free() the returned pointer. + */ +char *lo_get_path(void *data, ssize_t size); + +/** + * \brief Convert the specified argument to host byte order where necessary. + * + * \param type The OSC type of the data item (eg. LO_FLOAT). + * \param data A pointer to the data item to be converted. It is changed + * in-place. + */ +void lo_arg_host_endian(lo_type type, void *data); + +/** + * \brief Convert the specified argument to network byte order where necessary. + * + * \param type The OSC type of the data item (eg. LO_FLOAT). + * \param data A pointer to the data item to be converted. It is changed + * in-place. + */ +void lo_arg_network_endian(lo_type type, void *data); + +/** @} */ + +/* prettyprinters */ + +/** + * \defgroup pp Prettyprinting functions + * + * These functions all print an ASCII representation of their argument to + * stdout. Useful for debugging. + * @{ + */ + +/** \brief Pretty-print a lo_bundle object. */ +void lo_bundle_pp(lo_bundle b); + +/** \brief Pretty-print a lo_message object. */ +void lo_message_pp(lo_message m); + +/** \brief Pretty-print a set of typed arguments. + * \param type A type string in the form provided to lo_send(). + * \param data An OSC data pointer, like that provided in the + * lo_method_handler. + */ +void lo_arg_pp(lo_type type, void *data); + +/** \brief Pretty-print a lo_server object. */ +void lo_server_pp(lo_server s); + +/** \brief Pretty-print a lo_method object. */ +void lo_method_pp(lo_method m); + +/** \brief Pretty-print a lo_method object, but prepend a given prefix + * to all field names. */ +void lo_method_pp_prefix(lo_method m, const char *p); + +/** \brief Pretty-print a lo_server_thread object. */ +void lo_server_thread_pp(lo_server_thread st); +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/lo/lo_macros.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2004 Steve Harris + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * $Id$ + */ + +#ifndef LO_MACROS_H +#define LO_MACROS_H + +/* macros that have to be defined after function signatures */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* \brief Maximum length of UDP messages in bytes + */ +#define LO_MAX_MSG_SIZE 32768 + +/* \brief A set of macros to represent different communications transports + */ +#define LO_DEFAULT 0x0 +#define LO_UDP 0x1 +#define LO_UNIX 0x2 +#define LO_TCP 0x4 + +/* an internal value, ignored in transmission but check against LO_MARKER in the + * argument list. Used to do primitive bounds checking */ +#define LO_MARKER_A 0xdeadbeef +#define LO_MARKER_B 0xf00baa23 +#define LO_ARGS_END LO_MARKER_A, LO_MARKER_B + +#define lo_message_add_varargs(msg, types, list) \ + lo_message_add_varargs_internal(msg, types, list, __FILE__, __LINE__) + +#ifdef __GNUC__ + +#define lo_message_add(msg, types...) \ + lo_message_add_internal(msg, __FILE__, __LINE__, types, \ + LO_MARKER_A, LO_MARKER_B) + +#define lo_send(targ, path, types...) \ + lo_send_internal(targ, __FILE__, __LINE__, path, types, \ + LO_MARKER_A, LO_MARKER_B) + +#define lo_send_timestamped(targ, ts, path, types...) \ + lo_send_timestamped_internal(targ, __FILE__, __LINE__, ts, path, \ + types, LO_MARKER_A, LO_MARKER_B) + +#define lo_send_from(targ, from, ts, path, types...) \ + lo_send_from_internal(targ, from, __FILE__, __LINE__, ts, path, \ + types, LO_MARKER_A, LO_MARKER_B) + +#else + +/* In non-GCC compilers, there is no support for variable-argument + * macros, so provide "internal" vararg functions directly instead. */ + +int lo_message_add(lo_message msg, const char *types, ...); +int lo_send(lo_address targ, const char *path, const char *types, ...); +int lo_send_timestamped(lo_address targ, lo_timetag ts, const char *path, const char *types, ...); +int lo_send_from(lo_address targ, lo_server from, lo_timetag ts, const char *path, const char *types, ...); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/lo/lo_osc_types.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2004 Steve Harris + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * $Id$ + */ + +#ifndef LO_OSC_TYPES_H +#define LO_OSC_TYPES_H + +/** + * \file lo_osc_types.h A liblo header defining OSC-related types and + * constants. + */ + +#ifdef _MSC_VER +#define int32_t __int32 +#define int64_t __int64 +#define uint32_t unsigned __int32 +#define uint64_t unsigned __int64 +#define uint8_t unsigned __int8 +#else +#include <stdint.h> +#endif + +/** + * \addtogroup liblo + * @{ + */ + +/** + * \brief A structure to store OSC TimeTag values. + */ +typedef struct { + /** The number of seconds since Jan 1st 1900 in the UTC timezone. */ + uint32_t sec; + /** The fractions of a second offset from above, expressed as 1/2^32nds + * of a second */ + uint32_t frac; +} lo_timetag; + +/** + * \brief An enumeration of the OSC types liblo can send and receive. + * + * The value of the enumeration is the typechar used to tag messages and to + * specify arguments with lo_send(). + */ +typedef enum { +/* basic OSC types */ + /** 32 bit signed integer. */ + LO_INT32 = 'i', + /** 32 bit IEEE-754 float. */ + LO_FLOAT = 'f', + /** Standard C, NULL terminated string. */ + LO_STRING = 's', + /** OSC binary blob type. Accessed using the lo_blob_*() functions. */ + LO_BLOB = 'b', + +/* extended OSC types */ + /** 64 bit signed integer. */ + LO_INT64 = 'h', + /** OSC TimeTag type, represented by the lo_timetag structure. */ + LO_TIMETAG = 't', + /** 64 bit IEEE-754 double. */ + LO_DOUBLE = 'd', + /** Standard C, NULL terminated, string. Used in systems which + * distinguish strings and symbols. */ + LO_SYMBOL = 'S', + /** Standard C, 8 bit, char variable. */ + LO_CHAR = 'c', + /** A 4 byte MIDI packet. */ + LO_MIDI = 'm', + /** Sybol representing the value True. */ + LO_TRUE = 'T', + /** Sybol representing the value False. */ + LO_FALSE = 'F', + /** Sybol representing the value Nil. */ + LO_NIL = 'N', + /** Sybol representing the value Infinitum. */ + LO_INFINITUM = 'I' +} lo_type; + + +/** + * \brief Union used to read values from incoming messages. + * + * Types can generally be read using argv[n]->t where n is the argument number + * and t is the type character, with the exception of strings and symbols which + * must be read with &argv[n]->t. + */ +typedef union { + /** 32 bit signed integer. */ + int32_t i; + /** 32 bit signed integer. */ + int32_t i32; + /** 64 bit signed integer. */ + int64_t h; + /** 64 bit signed integer. */ + int64_t i64; + /** 32 bit IEEE-754 float. */ + float f; + /** 32 bit IEEE-754 float. */ + float f32; + /** 64 bit IEEE-754 double. */ + double d; + /** 64 bit IEEE-754 double. */ + double f64; + /** Standard C, NULL terminated string. */ + char s; + /** Standard C, NULL terminated, string. Used in systems which + * distinguish strings and symbols. */ + char S; + /** Standard C, 8 bit, char. */ + unsigned char c; + /** A 4 byte MIDI packet. */ + uint8_t m[4]; + /** OSC TimeTag value. */ + lo_timetag t; +} lo_arg; + +/** \brief A timetag constant representing "now". */ +/* Note: No struct literals in MSVC */ +#ifdef _MSC_VER +lo_timetag lo_get_tt_immediate(); +#define LO_TT_IMMEDIATE lo_get_tt_immediate() +#else +#define LO_TT_IMMEDIATE ((lo_timetag){0U,1U}) +#endif + +/** @} */ + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/lo/lo_throw.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2004 Steve Harris + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * $Id$ + */ + +#ifndef LO_THROW_H +#define LO_THROW_H + +#ifdef __cplusplus +extern "C" { +#endif + +void lo_throw(lo_server s, int errnum, const char *message, const char *path); + +#ifdef __cplusplus +} +#endif + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/lo/lo_types.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2004 Steve Harris + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * $Id$ + */ + +#ifndef LO_TYPES_H +#define LO_TYPES_H + +/** + * \file lo_types.h The liblo headerfile defining types used by this API. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef WIN32 +#include <winsock2.h> +#include <ws2tcpip.h> +#else +#include <netdb.h> +#endif + +#include <pthread.h> + +#include "lo/lo_osc_types.h" + +/** + * \brief A reference to an OSC service. + * + * Created by calls to lo_address_new() or lo_address_new_from_url(). + */ +typedef void *lo_address; + +/** + * \brief A object to store an opaque binary data object. + * + * Can be passed over OSC using the 'b' type. Created by calls to lo_blob_new(). + */ +typedef void *lo_blob; + +/** + * \brief A low-level object used to represent messages passed over OSC. + * + * Created by calls to lo_message_new(), arguments can be added with calls to + * lo_message_add_*(). + */ +typedef void *lo_message; + +/** + * \brief A low-level object used to represent bundles of messages passed over + * OSC. + * + * Created by calls to lo_bundle_new(), messages can be added with calls to + * lo_bundle_add_message(). + */ +typedef void *lo_bundle; + +/** + * \brief An object representing an method on a server. + * + * Returned by calls to lo_server_thread_add_method() and + * lo_server_add_method(). + */ +typedef void *lo_method; + +/** + * \brief An object representing an instance of an OSC server. + * + * Created by calls to lo_server_new(). If you with the library to take care of + * the threading as well you can just use server threads instead. + */ +typedef void *lo_server; + +/** + * \brief An object representing a thread containing an OSC server. + * + * Created by calls to lo_server_thread_new(). + */ +typedef void *lo_server_thread; + +/** + * \brief A callback function to receive notifcation of an error in a server or + * server thread. + * + * On callback the paramters will be set to the following values: + * + * \param num An error number that can be used to identify this condition. + * \param msg An error message describing the condidtion. + * \param where A string describing the place the error occured - typically + * either a function call or method path. + */ +typedef void (*lo_err_handler)(int num, const char *msg, const char *where); + +/** + * \brief A callback function to receive notifcation of matching message + * arriving in the server or server thread. + * + * The return value tells the method dispatcher whether this handler + * has dealt with the message correctly: a return value of 0 indicates + * that it has been handled, and it should not attempt to pass it on + * to any other handlers, non-0 means that it has not been handled and + * the dispatcher will attempt to find more handlers that match the + * path and types of the incoming message. + * + * On callback the paramters will be set to the following values: + * + * \param path That path that the incoming message was sent to + * \param types If you specided types in your method creation call then this + * will match those and the incoming types will have been coerced to match, + * otherwise it will be the types of the arguments of the incoming message. + * \param argv An array of lo_arg types containing the values, e.g. if the + * first argument of the incoming message is of type 'f' then the vlaue will be + * found in argv[0]->f. + * \param argc The number of argumets received. + * \param msg A structure containing the original raw message as received. No + * type coercion will have occured and the data will be in OSC byte order + * (bigendian). + * \param user_data This contains the user_data value passed in the call to + * lo_server_thread_add_method. + */ +typedef int (*lo_method_handler)(const char *path, const char *types, + lo_arg **argv, int argc, lo_message msg, + void *user_data); + +#ifdef __cplusplus +} +#endif + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/rubberband/RubberBandStretcher.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,687 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Rubber Band Library + An audio time-stretching and pitch-shifting library. + Copyright 2007-2012 Particular Programs Ltd. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. + + Alternatively, if you have a valid commercial licence for the + Rubber Band Library obtained by agreement with the copyright + holders, you may redistribute and/or modify it under the terms + described in that licence. + + If you wish to distribute code using the Rubber Band Library + under terms other than those of the GNU General Public License, + you must obtain a valid commercial licence before doing so. +*/ + +#ifndef _RUBBERBANDSTRETCHER_H_ +#define _RUBBERBANDSTRETCHER_H_ + +#define RUBBERBAND_VERSION "1.8.1" +#define RUBBERBAND_API_MAJOR_VERSION 2 +#define RUBBERBAND_API_MINOR_VERSION 5 + +#include <vector> +#include <map> +#include <cstddef> + +/** + * @mainpage RubberBand + * + * The Rubber Band API is contained in the single class + * RubberBand::RubberBandStretcher. + * + * Threading notes for real-time applications: + * + * Multiple instances of RubberBandStretcher may be created and used + * in separate threads concurrently. However, for any single instance + * of RubberBandStretcher, you may not call process() more than once + * concurrently, and you may not change the time or pitch ratio while + * a process() call is being executed (if the stretcher was created in + * "real-time mode"; in "offline mode" you can't change the ratios + * during use anyway). + * + * So you can run process() in its own thread if you like, but if you + * want to change ratios dynamically from a different thread, you will + * need some form of mutex in your code. Changing the time or pitch + * ratio is real-time safe except in extreme circumstances, so for + * most applications that may change these dynamically it probably + * makes most sense to do so from the same thread as calls process(), + * even if that is a real-time thread. + */ + +namespace RubberBand +{ + +class RubberBandStretcher +{ +public: + /** + * Processing options for the timestretcher. The preferred + * options should normally be set in the constructor, as a bitwise + * OR of the option flags. The default value (DefaultOptions) is + * intended to give good results in most situations. + * + * 1. Flags prefixed \c OptionProcess determine how the timestretcher + * will be invoked. These options may not be changed after + * construction. + * + * \li \c OptionProcessOffline - Run the stretcher in offline + * mode. In this mode the input data needs to be provided + * twice, once to study(), which calculates a stretch profile + * for the audio, and once to process(), which stretches it. + * + * \li \c OptionProcessRealTime - Run the stretcher in real-time + * mode. In this mode only process() should be called, and the + * stretcher adjusts dynamically in response to the input audio. + * + * The Process setting is likely to depend on your architecture: + * non-real-time operation on seekable files: Offline; real-time + * or streaming operation: RealTime. + * + * 2. Flags prefixed \c OptionStretch control the profile used for + * variable timestretching. Rubber Band always adjusts the + * stretch profile to minimise stretching of busy broadband + * transient sounds, but the degree to which it does so is + * adjustable. These options may not be changed after + * construction. + * + * \li \c OptionStretchElastic - Only meaningful in offline + * mode, and the default in that mode. The audio will be + * stretched at a variable rate, aimed at preserving the quality + * of transient sounds as much as possible. The timings of low + * activity regions between transients may be less exact than + * when the precise flag is set. + * + * \li \c OptionStretchPrecise - Although still using a variable + * stretch rate, the audio will be stretched so as to maintain + * as close as possible to a linear stretch ratio throughout. + * Timing may be better than when using \c OptionStretchElastic, at + * slight cost to the sound quality of transients. This setting + * is always used when running in real-time mode. + * + * 3. Flags prefixed \c OptionTransients control the component + * frequency phase-reset mechanism that may be used at transient + * points to provide clarity and realism to percussion and other + * significant transient sounds. These options may be changed + * after construction when running in real-time mode, but not when + * running in offline mode. + * + * \li \c OptionTransientsCrisp - Reset component phases at the + * peak of each transient (the start of a significant note or + * percussive event). This, the default setting, usually + * results in a clear-sounding output; but it is not always + * consistent, and may cause interruptions in stable sounds + * present at the same time as transient events. The + * OptionDetector flags (below) can be used to tune this to some + * extent. + * + * \li \c OptionTransientsMixed - Reset component phases at the + * peak of each transient, outside a frequency range typical of + * musical fundamental frequencies. The results may be more + * regular for mixed stable and percussive notes than + * \c OptionTransientsCrisp, but with a "phasier" sound. The + * balance may sound very good for certain types of music and + * fairly bad for others. + * + * \li \c OptionTransientsSmooth - Do not reset component phases + * at any point. The results will be smoother and more regular + * but may be less clear than with either of the other + * transients flags. + * + * 4. Flags prefixed \c OptionDetector control the type of + * transient detector used. These options may be changed + * after construction when running in real-time mode, but not when + * running in offline mode. + * + * \li \c OptionDetectorCompound - Use a general-purpose + * transient detector which is likely to be good for most + * situations. This is the default. + * + * \li \c OptionDetectorPercussive - Detect percussive + * transients. Note that this was the default and only option + * in Rubber Band versions prior to 1.5. + * + * \li \c OptionDetectorSoft - Use an onset detector with less + * of a bias toward percussive transients. This may give better + * results with certain material (e.g. relatively monophonic + * piano music). + * + * 5. Flags prefixed \c OptionPhase control the adjustment of + * component frequency phases from one analysis window to the next + * during non-transient segments. These options may be changed at + * any time. + * + * \li \c OptionPhaseLaminar - Adjust phases when stretching in + * such a way as to try to retain the continuity of phase + * relationships between adjacent frequency bins whose phases + * are behaving in similar ways. This, the default setting, + * should give good results in most situations. + * + * \li \c OptionPhaseIndependent - Adjust the phase in each + * frequency bin independently from its neighbours. This + * usually results in a slightly softer, phasier sound. + * + * 6. Flags prefixed \c OptionThreading control the threading + * model of the stretcher. These options may not be changed after + * construction. + * + * \li \c OptionThreadingAuto - Permit the stretcher to + * determine its own threading model. Usually this means using + * one processing thread per audio channel in offline mode if + * the stretcher is able to determine that more than one CPU is + * available, and one thread only in realtime mode. This is the + * defafult. + * + * \li \c OptionThreadingNever - Never use more than one thread. + * + * \li \c OptionThreadingAlways - Use multiple threads in any + * situation where \c OptionThreadingAuto would do so, except omit + * the check for multiple CPUs and instead assume it to be true. + * + * 7. Flags prefixed \c OptionWindow control the window size for + * FFT processing. The window size actually used will depend on + * many factors, but it can be influenced. These options may not + * be changed after construction. + * + * \li \c OptionWindowStandard - Use the default window size. + * The actual size will vary depending on other parameters. + * This option is expected to produce better results than the + * other window options in most situations. + * + * \li \c OptionWindowShort - Use a shorter window. This may + * result in crisper sound for audio that depends strongly on + * its timing qualities. + * + * \li \c OptionWindowLong - Use a longer window. This is + * likely to result in a smoother sound at the expense of + * clarity and timing. + * + * 8. Flags prefixed \c OptionSmoothing control the use of + * window-presum FFT and time-domain smoothing. These options may + * not be changed after construction. + * + * \li \c OptionSmoothingOff - Do not use time-domain smoothing. + * This is the default. + * + * \li \c OptionSmoothingOn - Use time-domain smoothing. This + * will result in a softer sound with some audible artifacts + * around sharp transients, but it may be appropriate for longer + * stretches of some instruments and can mix well with + * OptionWindowShort. + * + * 9. Flags prefixed \c OptionFormant control the handling of + * formant shape (spectral envelope) when pitch-shifting. These + * options may be changed at any time. + * + * \li \c OptionFormantShifted - Apply no special formant + * processing. The spectral envelope will be pitch shifted as + * normal. This is the default. + * + * \li \c OptionFormantPreserved - Preserve the spectral + * envelope of the unshifted signal. This permits shifting the + * note frequency without so substantially affecting the + * perceived pitch profile of the voice or instrument. + * + * 10. Flags prefixed \c OptionPitch control the method used for + * pitch shifting. These options may be changed at any time. + * They are only effective in realtime mode; in offline mode, the + * pitch-shift method is fixed. + * + * \li \c OptionPitchHighSpeed - Use a method with a CPU cost + * that is relatively moderate and predictable. This may + * sound less clear than OptionPitchHighQuality, especially + * for large pitch shifts. This is the default. + + * \li \c OptionPitchHighQuality - Use the highest quality + * method for pitch shifting. This method has a CPU cost + * approximately proportional to the required frequency shift. + + * \li \c OptionPitchHighConsistency - Use the method that gives + * greatest consistency when used to create small variations in + * pitch around the 1.0-ratio level. Unlike the previous two + * options, this avoids discontinuities when moving across the + * 1.0 pitch scale in real-time; it also consumes more CPU than + * the others in the case where the pitch scale is exactly 1.0. + * + * 11. Flags prefixed \c OptionChannels control the method used for + * processing two-channel audio. These options may not be changed + * after construction. + * + * \li \c OptionChannelsApart - Each channel is processed + * individually, though timing is synchronised and phases are + * synchronised at transients (depending on the OptionTransients + * setting). This gives the highest quality for the individual + * channels but a relative lack of stereo focus and unrealistic + * increase in "width". This is the default. + * + * \li \c OptionChannelsTogether - The first two channels (where + * two or more are present) are considered to be a stereo pair + * and are processed in mid-side format; mid and side are + * processed individually, with timing synchronised and phases + * synchronised at transients (depending on the OptionTransients + * setting). This usually leads to better focus in the centre + * but a loss of stereo space and width. Any channels beyond + * the first two are processed individually. + */ + + enum Option { + + OptionProcessOffline = 0x00000000, + OptionProcessRealTime = 0x00000001, + + OptionStretchElastic = 0x00000000, + OptionStretchPrecise = 0x00000010, + + OptionTransientsCrisp = 0x00000000, + OptionTransientsMixed = 0x00000100, + OptionTransientsSmooth = 0x00000200, + + OptionDetectorCompound = 0x00000000, + OptionDetectorPercussive = 0x00000400, + OptionDetectorSoft = 0x00000800, + + OptionPhaseLaminar = 0x00000000, + OptionPhaseIndependent = 0x00002000, + + OptionThreadingAuto = 0x00000000, + OptionThreadingNever = 0x00010000, + OptionThreadingAlways = 0x00020000, + + OptionWindowStandard = 0x00000000, + OptionWindowShort = 0x00100000, + OptionWindowLong = 0x00200000, + + OptionSmoothingOff = 0x00000000, + OptionSmoothingOn = 0x00800000, + + OptionFormantShifted = 0x00000000, + OptionFormantPreserved = 0x01000000, + + OptionPitchHighSpeed = 0x00000000, + OptionPitchHighQuality = 0x02000000, + OptionPitchHighConsistency = 0x04000000, + + OptionChannelsApart = 0x00000000, + OptionChannelsTogether = 0x10000000, + + // n.b. Options is int, so we must stop before 0x80000000 + }; + + typedef int Options; + + enum PresetOption { + DefaultOptions = 0x00000000, + PercussiveOptions = 0x00102000 + }; + + /** + * Construct a time and pitch stretcher object to run at the given + * sample rate, with the given number of channels. Processing + * options and the time and pitch scaling ratios may be provided. + * The time and pitch ratios may be changed after construction, + * but most of the options may not. See the option documentation + * above for more details. + */ + RubberBandStretcher(size_t sampleRate, + size_t channels, + Options options = DefaultOptions, + double initialTimeRatio = 1.0, + double initialPitchScale = 1.0); + ~RubberBandStretcher(); + + /** + * Reset the stretcher's internal buffers. The stretcher should + * subsequently behave as if it had just been constructed + * (although retaining the current time and pitch ratio). + */ + void reset(); + + /** + * Set the time ratio for the stretcher. This is the ratio of + * stretched to unstretched duration -- not tempo. For example, a + * ratio of 2.0 would make the audio twice as long (i.e. halve the + * tempo); 0.5 would make it half as long (i.e. double the tempo); + * 1.0 would leave the duration unaffected. + * + * If the stretcher was constructed in Offline mode, the time + * ratio is fixed throughout operation; this function may be + * called any number of times between construction (or a call to + * reset()) and the first call to study() or process(), but may + * not be called after study() or process() has been called. + * + * If the stretcher was constructed in RealTime mode, the time + * ratio may be varied during operation; this function may be + * called at any time, so long as it is not called concurrently + * with process(). You should either call this function from the + * same thread as process(), or provide your own mutex or similar + * mechanism to ensure that setTimeRatio and process() cannot be + * run at once (there is no internal mutex for this purpose). + */ + void setTimeRatio(double ratio); + + /** + * Set the pitch scaling ratio for the stretcher. This is the + * ratio of target frequency to source frequency. For example, a + * ratio of 2.0 would shift up by one octave; 0.5 down by one + * octave; or 1.0 leave the pitch unaffected. + * + * To put this in musical terms, a pitch scaling ratio + * corresponding to a shift of S equal-tempered semitones (where S + * is positive for an upwards shift and negative for downwards) is + * pow(2.0, S / 12.0). + * + * If the stretcher was constructed in Offline mode, the pitch + * scaling ratio is fixed throughout operation; this function may + * be called any number of times between construction (or a call + * to reset()) and the first call to study() or process(), but may + * not be called after study() or process() has been called. + * + * If the stretcher was constructed in RealTime mode, the pitch + * scaling ratio may be varied during operation; this function may + * be called at any time, so long as it is not called concurrently + * with process(). You should either call this function from the + * same thread as process(), or provide your own mutex or similar + * mechanism to ensure that setPitchScale and process() cannot be + * run at once (there is no internal mutex for this purpose). + */ + void setPitchScale(double scale); + + /** + * Return the last time ratio value that was set (either on + * construction or with setTimeRatio()). + */ + double getTimeRatio() const; + + /** + * Return the last pitch scaling ratio value that was set (either + * on construction or with setPitchScale()). + */ + double getPitchScale() const; + + /** + * Return the processing latency of the stretcher. This is the + * number of audio samples that one would have to discard at the + * start of the output in order to ensure that the resulting audio + * aligned with the input audio at the start. In Offline mode, + * latency is automatically adjusted for and the result is zero. + * In RealTime mode, the latency may depend on the time and pitch + * ratio and other options. + */ + size_t getLatency() const; + + /** + * Change an OptionTransients configuration setting. This may be + * called at any time in RealTime mode. It may not be called in + * Offline mode (for which the transients option is fixed on + * construction). + */ + void setTransientsOption(Options options); + + /** + * Change an OptionDetector configuration setting. This may be + * called at any time in RealTime mode. It may not be called in + * Offline mode (for which the detector option is fixed on + * construction). + */ + void setDetectorOption(Options options); + + /** + * Change an OptionPhase configuration setting. This may be + * called at any time in any mode. + * + * Note that if running multi-threaded in Offline mode, the change + * may not take effect immediately if processing is already under + * way when this function is called. + */ + void setPhaseOption(Options options); + + /** + * Change an OptionFormant configuration setting. This may be + * called at any time in any mode. + * + * Note that if running multi-threaded in Offline mode, the change + * may not take effect immediately if processing is already under + * way when this function is called. + */ + void setFormantOption(Options options); + + /** + * Change an OptionPitch configuration setting. This may be + * called at any time in RealTime mode. It may not be called in + * Offline mode (for which the transients option is fixed on + * construction). + */ + void setPitchOption(Options options); + + /** + * Tell the stretcher exactly how many input samples it will + * receive. This is only useful in Offline mode, when it allows + * the stretcher to ensure that the number of output samples is + * exactly correct. In RealTime mode no such guarantee is + * possible and this value is ignored. + */ + void setExpectedInputDuration(size_t samples); + + /** + * Tell the stretcher the maximum number of sample frames that you + * will ever be passing in to a single process() call. If you + * don't call this, the stretcher will assume that you are calling + * getSamplesRequired() at each cycle and are never passing more + * samples than are suggested by that function. + * + * If your application has some external constraint that means you + * prefer a fixed block size, then your normal mode of operation + * would be to provide that block size to this function; to loop + * calling process() with that size of block; after each call to + * process(), test whether output has been generated by calling + * available(); and, if so, call retrieve() to obtain it. See + * getSamplesRequired() for a more suitable operating mode for + * applications without such external constraints. + * + * This function may not be called after the first call to study() + * or process(). + * + * Note that this value is only relevant to process(), not to + * study() (to which you may pass any number of samples at a time, + * and from which there is no output). + */ + void setMaxProcessSize(size_t samples); + + /** + * Ask the stretcher how many audio sample frames should be + * provided as input in order to ensure that some more output + * becomes available. + * + * If your application has no particular constraint on processing + * block size and you are able to provide any block size as input + * for each cycle, then your normal mode of operation would be to + * loop querying this function; providing that number of samples + * to process(); and reading the output using available() and + * retrieve(). See setMaxProcessSize() for a more suitable + * operating mode for applications that do have external block + * size constraints. + * + * Note that this value is only relevant to process(), not to + * study() (to which you may pass any number of samples at a time, + * and from which there is no output). + */ + size_t getSamplesRequired() const; + + /** + * Provide a set of mappings from "before" to "after" sample + * numbers so as to enforce a particular stretch profile. The + * argument is a map from audio sample frame number in the source + * material, to the corresponding sample frame number in the + * stretched output. The mapping should be for key frames only, + * with a "reasonable" gap between mapped samples. + * + * This function cannot be used in RealTime mode. + * + * This function may not be called after the first call to + * process(). It should be called after the time and pitch ratios + * have been set; the results of changing the time and pitch + * ratios after calling this function are undefined. Calling + * reset() will clear this mapping. + * + * The key frame map only affects points within the material; it + * does not determine the overall stretch ratio (that is, the + * ratio between the output material's duration and the source + * material's duration). You need to provide this ratio + * separately to setTimeRatio(), otherwise the results may be + * truncated or extended in unexpected ways regardless of the + * extent of the frame numbers found in the key frame map. + */ + void setKeyFrameMap(const std::map<size_t, size_t> &); + + /** + * Provide a block of "samples" sample frames for the stretcher to + * study and calculate a stretch profile from. + * + * This is only meaningful in Offline mode, and is required if + * running in that mode. You should pass the entire input through + * study() before any process() calls are made, as a sequence of + * blocks in individual study() calls, or as a single large block. + * + * "input" should point to de-interleaved audio data with one + * float array per channel. "samples" supplies the number of + * audio sample frames available in "input". If "samples" is + * zero, "input" may be NULL. + * + * Set "final" to true if this is the last block of data that will + * be provided to study() before the first process() call. + */ + void study(const float *const *input, size_t samples, bool final); + + /** + * Provide a block of "samples" sample frames for processing. + * See also getSamplesRequired() and setMaxProcessSize(). + * + * Set "final" to true if this is the last block of input data. + */ + void process(const float *const *input, size_t samples, bool final); + + /** + * Ask the stretcher how many audio sample frames of output data + * are available for reading (via retrieve()). + * + * This function returns 0 if no frames are available: this + * usually means more input data needs to be provided, but if the + * stretcher is running in threaded mode it may just mean that not + * enough data has yet been processed. Call getSamplesRequired() + * to discover whether more input is needed. + * + * This function returns -1 if all data has been fully processed + * and all output read, and the stretch process is now finished. + */ + int available() const; + + /** + * Obtain some processed output data from the stretcher. Up to + * "samples" samples will be stored in the output arrays (one per + * channel for de-interleaved audio data) pointed to by "output". + * The return value is the actual number of sample frames + * retrieved. + */ + size_t retrieve(float *const *output, size_t samples) const; + + /** + * Return the value of internal frequency cutoff value n. + * + * This function is not for general use. + */ + float getFrequencyCutoff(int n) const; + + /** + * Set the value of internal frequency cutoff n to f Hz. + * + * This function is not for general use. + */ + void setFrequencyCutoff(int n, float f); + + /** + * Retrieve the value of the internal input block increment value. + * + * This function is provided for diagnostic purposes only. + */ + size_t getInputIncrement() const; + + /** + * In offline mode, retrieve the sequence of internal block + * increments for output, for the entire audio data, provided the + * stretch profile has been calculated. In realtime mode, + * retrieve any output increments that have accumulated since the + * last call to getOutputIncrements, to a limit of 16. + * + * This function is provided for diagnostic purposes only. + */ + std::vector<int> getOutputIncrements() const; + + /** + * In offline mode, retrieve the sequence of internal phase reset + * detection function values, for the entire audio data, provided + * the stretch profile has been calculated. In realtime mode, + * retrieve any phase reset points that have accumulated since the + * last call to getPhaseResetCurve, to a limit of 16. + * + * This function is provided for diagnostic purposes only. + */ + std::vector<float> getPhaseResetCurve() const; + + /** + * In offline mode, retrieve the sequence of internal frames for + * which exact timing has been sought, for the entire audio data, + * provided the stretch profile has been calculated. In realtime + * mode, return an empty sequence. + * + * This function is provided for diagnostic purposes only. + */ + std::vector<int> getExactTimePoints() const; + + /** + * Return the number of channels this stretcher was constructed + * with. + */ + size_t getChannelCount() const; + + /** + * Force the stretcher to calculate a stretch profile. Normally + * this happens automatically for the first process() call in + * offline mode. + * + * This function is provided for diagnostic purposes only. + */ + void calculateStretch(); + + /** + * Set the level of debug output. The value may be from 0 (errors + * only) to 3 (very verbose, with audible ticks in the output at + * phase reset points). The default is whatever has been set + * using setDefaultDebugLevel, or 0 if that function has not been + * called. + */ + void setDebugLevel(int level); + + /** + * Set the default level of debug output for subsequently + * constructed stretchers. + * + * @see setDebugLevel + */ + static void setDefaultDebugLevel(int level); + +protected: + class Impl; + Impl *m_d; +}; + +} + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osx/include/rubberband/rubberband-c.h Thu Jan 09 13:23:08 2014 +0000 @@ -0,0 +1,142 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Rubber Band Library + An audio time-stretching and pitch-shifting library. + Copyright 2007-2012 Particular Programs Ltd. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. + + Alternatively, if you have a valid commercial licence for the + Rubber Band Library obtained by agreement with the copyright + holders, you may redistribute and/or modify it under the terms + described in that licence. + + If you wish to distribute code using the Rubber Band Library + under terms other than those of the GNU General Public License, + you must obtain a valid commercial licence before doing so. +*/ + +#ifndef _RUBBERBAND_C_API_H_ +#define _RUBBERBAND_C_API_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define RUBBERBAND_VERSION "1.8.1" +#define RUBBERBAND_API_MAJOR_VERSION 2 +#define RUBBERBAND_API_MINOR_VERSION 5 + +/** + * This is a C-linkage interface to the Rubber Band time stretcher. + * + * This is a wrapper interface: the primary interface is in C++ and is + * defined and documented in RubberBandStretcher.h. The library + * itself is implemented in C++, and requires C++ standard library + * support even when using the C-linkage API. + * + * Please see RubberBandStretcher.h for documentation. + * + * If you are writing to the C++ API, do not include this header. + */ + +enum RubberBandOption { + + RubberBandOptionProcessOffline = 0x00000000, + RubberBandOptionProcessRealTime = 0x00000001, + + RubberBandOptionStretchElastic = 0x00000000, + RubberBandOptionStretchPrecise = 0x00000010, + + RubberBandOptionTransientsCrisp = 0x00000000, + RubberBandOptionTransientsMixed = 0x00000100, + RubberBandOptionTransientsSmooth = 0x00000200, + + RubberBandOptionDetectorCompound = 0x00000000, + RubberBandOptionDetectorPercussive = 0x00000400, + RubberBandOptionDetectorSoft = 0x00000800, + + RubberBandOptionPhaseLaminar = 0x00000000, + RubberBandOptionPhaseIndependent = 0x00002000, + + RubberBandOptionThreadingAuto = 0x00000000, + RubberBandOptionThreadingNever = 0x00010000, + RubberBandOptionThreadingAlways = 0x00020000, + + RubberBandOptionWindowStandard = 0x00000000, + RubberBandOptionWindowShort = 0x00100000, + RubberBandOptionWindowLong = 0x00200000, + + RubberBandOptionSmoothingOff = 0x00000000, + RubberBandOptionSmoothingOn = 0x00800000, + + RubberBandOptionFormantShifted = 0x00000000, + RubberBandOptionFormantPreserved = 0x01000000, + + RubberBandOptionPitchHighQuality = 0x00000000, + RubberBandOptionPitchHighSpeed = 0x02000000, + RubberBandOptionPitchHighConsistency = 0x04000000, + + RubberBandOptionChannelsApart = 0x00000000, + RubberBandOptionChannelsTogether = 0x10000000, +}; + +typedef int RubberBandOptions; + +struct RubberBandState_; +typedef struct RubberBandState_ *RubberBandState; + +extern RubberBandState rubberband_new(unsigned int sampleRate, + unsigned int channels, + RubberBandOptions options, + double initialTimeRatio, + double initialPitchScale); + +extern void rubberband_delete(RubberBandState); + +extern void rubberband_reset(RubberBandState); + +extern void rubberband_set_time_ratio(RubberBandState, double ratio); +extern void rubberband_set_pitch_scale(RubberBandState, double scale); + +extern double rubberband_get_time_ratio(const RubberBandState); +extern double rubberband_get_pitch_scale(const RubberBandState); + +extern unsigned int rubberband_get_latency(const RubberBandState); + +extern void rubberband_set_transients_option(RubberBandState, RubberBandOptions options); +extern void rubberband_set_detector_option(RubberBandState, RubberBandOptions options); +extern void rubberband_set_phase_option(RubberBandState, RubberBandOptions options); +extern void rubberband_set_formant_option(RubberBandState, RubberBandOptions options); +extern void rubberband_set_pitch_option(RubberBandState, RubberBandOptions options); + +extern void rubberband_set_expected_input_duration(RubberBandState, unsigned int samples); + +extern unsigned int rubberband_get_samples_required(const RubberBandState); + +extern void rubberband_set_max_process_size(RubberBandState, unsigned int samples); +extern void rubberband_set_key_frame_map(RubberBandState, unsigned int keyframecount, unsigned int *from, unsigned int *to); + +extern void rubberband_study(RubberBandState, const float *const *input, unsigned int samples, int final); +extern void rubberband_process(RubberBandState, const float *const *input, unsigned int samples, int final); + +extern int rubberband_available(const RubberBandState); +extern unsigned int rubberband_retrieve(const RubberBandState, float *const *output, unsigned int samples); + +extern unsigned int rubberband_get_channel_count(const RubberBandState); + +extern void rubberband_calculate_stretch(RubberBandState); + +extern void rubberband_set_debug_level(RubberBandState, int level); +extern void rubberband_set_default_debug_level(int level); + +#ifdef __cplusplus +} +#endif + +#endif