source: roaraudio/include/roaraudio/units.h @ 5210:8eb738dee9d4

Last change on this file since 5210:8eb738dee9d4 was 5210:8eb738dee9d4, checked in by phi, 12 years ago

Updated ports to minimal, win32 and avr (pr2)

File size: 3.0 KB
Line 
1//units.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2011
5 *
6 *  This file is part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU Lesser General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  RoarAudio is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU Lesser General Public License for more details.
18 *
19 *  You should have received a copy of the GNU Lesser General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 *  NOTE: Even though this file is LGPLed it (may) include GPLed files
25 *  so the license of this file is/may therefore downgraded to GPL.
26 *  See HACKING for details.
27 */
28
29#ifndef _ROARAUDIO_UNITS_H_
30#define _ROARAUDIO_UNITS_H_
31
32/* suffix: */
33#define _MICRO  (1/1000000)
34#define _MILI   (1/1000)
35#define _ONE    1
36#define _KILO   1000
37#define _MEGA   ((int_least32_t)_KILO*(int_least32_t)_KILO)
38#define _GIGA   ((int_least32_t)_KILO*_MEGA)
39#define _TERA   ((int_least32_t)_KILO*_GIGA)
40
41
42/* Time: */
43#ifndef _SEC
44#if defined(_UNITS_T_BASE_MSEC)
45#define _SEC_TYPE int_least32_t
46#define _SEC  (_SEC_TYPE)1000
47#elif defined(_UNITS_T_BASE_USEC)
48#define _SEC_TYPE int_least32_t
49#define _SEC  (_SEC_TYPE)1000000
50//#elif defined(_UNITS_T_BASE_SEC)
51#else
52#define _SEC  1
53#define _SEC_TYPE int
54#endif
55#endif
56
57#ifndef _SEC_TYPE
58#define _SEC_TYPE int_least32_t
59#endif
60
61#define _MIN  ((_SEC_TYPE)60*_SEC)
62#define _HOUR ((_SEC_TYPE)60*_MIN)
63
64#define _MSEC (_SEC*_MILI)
65#define _USEC (_SEC*_MICRO)
66
67
68/* distance */
69#ifndef _METER
70#if defined(_UNITS_D_BASE_MMETER)
71#define _METER_TYPE int
72#define _METER 1000
73#elif defined(_UNITS_D_BASE_UMETER)
74#define _METER_TYPE int_least32_t
75#define _METER (_METER_TYPE)1000000
76//#elif defined(_UNITS_D_BASE_METER)
77#else
78#define _METER_TYPE int
79#define _METER 1
80#endif
81#endif
82
83#ifndef _METER_TYPE
84#define _METER_TYPE int_least32_t
85#endif
86
87#define _AE    ((int_least64_t)149597870691LL     *_METER)
88#define _LJ    (9460730472580800LL *_METER)
89#define _PC    (30856804413117847LL*_METER) /* TODO: FIXME: get a more corret value */
90
91
92/* speed */
93#define _MPS                   ((double)_METER/_SEC)
94#define _KMPH                  (_KILO*_METER/_HOUR)
95#define _SPEED_OF_SOUND_AIR    (343. *_MPS)
96#define _SPEED_OF_SOUND_WATER  (1407.*_MPS)
97#define _SPEED_OF_SOUND        _SPEED_OF_SOUND_AIR
98#define _SPEED_OF_LIGHT_VACUUM (299792458LL*_MPS)
99#define _SPEED_OF_LIGHT        _SPEED_OF_LIGHT_VACUUM
100
101
102/* Bits -> Bytes: */
103#define _BIT2BYTE(x) (((int)((x)/8)) + ((x) % 8 ? 1 : 0))
104#define _BYTE2BIT(x) ((x)*8)
105
106#define _8BIT  _BIT2BYTE(8)
107#define _16BIT _BIT2BYTE(16)
108#define _24BIT _BIT2BYTE(24)
109#define _32BIT _BIT2BYTE(32)
110#define _64BIT _BIT2BYTE(64)
111
112
113#endif
114
115//ll
Note: See TracBrowser for help on using the repository browser.