CSL  5.2
lo_osc_types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004 Steve Harris
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 2.1
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * $Id$
15  */
16 
17 #ifndef LO_OSC_TYPES_H
18 #define LO_OSC_TYPES_H
19 
20 /**
21  * \file lo_osc_types.h A liblo header defining OSC-related types and
22  * constants.
23  */
24 
25 #ifdef _MSC_VER
26 #define int32_t __int32
27 #define int64_t __int64
28 #define uint32_t unsigned __int32
29 #define uint64_t unsigned __int64
30 #define uint8_t unsigned __int8
31 #else
32 #include <stdint.h>
33 #endif
34 
35 /**
36  * \addtogroup liblo
37  * @{
38  */
39 
40 /**
41  * \brief A structure to store OSC TimeTag values.
42  */
43 typedef struct {
44  /** The number of seconds since Jan 1st 1900 in the UTC timezone. */
45  uint32_t sec;
46  /** The fractions of a second offset from above, expressed as 1/2^32nds
47  * of a second */
48  uint32_t frac;
49 } lo_timetag;
50 
51 /**
52  * \brief An enumeration of the OSC types liblo can send and receive.
53  *
54  * The value of the enumeration is the typechar used to tag messages and to
55  * specify arguments with lo_send().
56  */
57 typedef enum {
58 /* basic OSC types */
59  /** 32 bit signed integer. */
60  LO_INT32 = 'i',
61  /** 32 bit IEEE-754 float. */
62  LO_FLOAT = 'f',
63  /** Standard C, NULL terminated string. */
64  LO_STRING = 's',
65  /** OSC binary blob type. Accessed using the lo_blob_*() functions. */
66  LO_BLOB = 'b',
67 
68 /* extended OSC types */
69  /** 64 bit signed integer. */
70  LO_INT64 = 'h',
71  /** OSC TimeTag type, represented by the lo_timetag structure. */
72  LO_TIMETAG = 't',
73  /** 64 bit IEEE-754 double. */
74  LO_DOUBLE = 'd',
75  /** Standard C, NULL terminated, string. Used in systems which
76  * distinguish strings and symbols. */
77  LO_SYMBOL = 'S',
78  /** Standard C, 8 bit, char variable. */
79  LO_CHAR = 'c',
80  /** A 4 byte MIDI packet. */
81  LO_MIDI = 'm',
82  /** Sybol representing the value True. */
83  LO_TRUE = 'T',
84  /** Sybol representing the value False. */
85  LO_FALSE = 'F',
86  /** Sybol representing the value Nil. */
87  LO_NIL = 'N',
88  /** Sybol representing the value Infinitum. */
90 } lo_type;
91 
92 
93 /**
94  * \brief Union used to read values from incoming messages.
95  *
96  * Types can generally be read using argv[n]->t where n is the argument number
97  * and t is the type character, with the exception of strings and symbols which
98  * must be read with &argv[n]->t.
99  */
100 typedef union {
101  /** 32 bit signed integer. */
102  int32_t i;
103  /** 32 bit signed integer. */
104  int32_t i32;
105  /** 64 bit signed integer. */
106  int64_t h;
107  /** 64 bit signed integer. */
108  int64_t i64;
109  /** 32 bit IEEE-754 float. */
110  float f;
111  /** 32 bit IEEE-754 float. */
112  float f32;
113  /** 64 bit IEEE-754 double. */
114  double d;
115  /** 64 bit IEEE-754 double. */
116  double f64;
117  /** Standard C, NULL terminated string. */
118  char s;
119  /** Standard C, NULL terminated, string. Used in systems which
120  * distinguish strings and symbols. */
121  char S;
122  /** Standard C, 8 bit, char. */
123  unsigned char c;
124  /** A 4 byte MIDI packet. */
125  uint8_t m[4];
126  /** OSC TimeTag value. */
128 } lo_arg;
129 
130 /** \brief A timetag constant representing "now". */
131 /* Note: No struct literals in MSVC */
132 #ifdef _MSC_VER
133 lo_timetag lo_get_tt_immediate();
134 #define LO_TT_IMMEDIATE lo_get_tt_immediate()
135 #else
136 #define LO_TT_IMMEDIATE ((lo_timetag){0U,1U})
137 #endif
138 
139 /** @} */
140 
141 #endif