[3206] | 1 | //units.h: |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010 |
---|
| 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 |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[3206] | 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 (_KILO*_KILO) |
---|
| 38 | #define _GIGA (_KILO*_MEGA) |
---|
| 39 | #define _TERA (_KILO*_GIGA) |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | /* Time: */ |
---|
[3209] | 43 | #ifndef _SEC |
---|
[3206] | 44 | #if defined(_UNITS_T_BASE_MSEC) |
---|
| 45 | #define _SEC 1000 |
---|
| 46 | #elif defined(_UNITS_T_BASE_USEC) |
---|
| 47 | #define _SEC 1000000 |
---|
| 48 | //#elif defined(_UNITS_T_BASE_SEC) |
---|
| 49 | #else |
---|
| 50 | #define _SEC 1 |
---|
| 51 | #endif |
---|
[3209] | 52 | #endif |
---|
[3206] | 53 | |
---|
| 54 | #define _MIN (60*_SEC) |
---|
| 55 | #define _HOUR (60*_MIN) |
---|
| 56 | |
---|
| 57 | #define _MSEC (_SEC*_MILI) |
---|
| 58 | #define _USEC (_SEC*_MICRO) |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | /* distance */ |
---|
[3209] | 62 | #ifndef _METER |
---|
| 63 | #if defined(_UNITS_D_BASE_MMETER) |
---|
| 64 | #define _METER 1000 |
---|
| 65 | #elif defined(_UNITS_D_BASE_UMETER) |
---|
| 66 | #define _METER 1000000 |
---|
| 67 | //#elif defined(_UNITS_D_BASE_METER) |
---|
| 68 | #else |
---|
[3206] | 69 | #define _METER 1 |
---|
[3209] | 70 | #endif |
---|
| 71 | #endif |
---|
| 72 | |
---|
| 73 | #define _AE (149597870691LL *_METER) |
---|
| 74 | #define _LJ (9460730472580800LL *_METER) |
---|
| 75 | #define _PC (30856804413117847LL*_METER) /* TODO: FIXME: get a more corret value */ |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | /* speed */ |
---|
[3210] | 79 | #define _MPS ((double)_METER/_SEC) |
---|
[3209] | 80 | #define _KMPH (_KILO*_METER/_HOUR) |
---|
[3210] | 81 | #define _SPEED_OF_SOUND_AIR (343. *_MPS) |
---|
| 82 | #define _SPEED_OF_SOUND_WATER (1407.*_MPS) |
---|
[3209] | 83 | #define _SPEED_OF_SOUND _SPEED_OF_SOUND_AIR |
---|
| 84 | #define _SPEED_OF_LIGHT_VACUUM (299792458LL*_MPS) |
---|
| 85 | #define _SPEED_OF_LIGHT _SPEED_OF_LIGHT_VACUUM |
---|
| 86 | |
---|
[3206] | 87 | |
---|
| 88 | /* Bits -> Bytes: */ |
---|
| 89 | #define _BIT2BYTE(x) (((int)((x)/8)) + ((x) % 8 ? 1 : 0)) |
---|
| 90 | #define _BYTE2BIT(x) ((x)*8) |
---|
| 91 | |
---|
| 92 | #define _8BIT _BIT2BYTE(8) |
---|
| 93 | #define _16BIT _BIT2BYTE(16) |
---|
| 94 | #define _24BIT _BIT2BYTE(24) |
---|
| 95 | #define _32BIT _BIT2BYTE(32) |
---|
| 96 | #define _64BIT _BIT2BYTE(64) |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | #endif |
---|
| 100 | |
---|
| 101 | //ll |
---|