[3206] | 1 | //units.h: |
---|
| 2 | |
---|
| 3 | /* |
---|
[5823] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2013 |
---|
[3206] | 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 |
---|
[5210] | 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) |
---|
[3206] | 40 | |
---|
| 41 | |
---|
| 42 | /* Time: */ |
---|
[3209] | 43 | #ifndef _SEC |
---|
[3206] | 44 | #if defined(_UNITS_T_BASE_MSEC) |
---|
[5210] | 45 | #define _SEC_TYPE int_least32_t |
---|
| 46 | #define _SEC (_SEC_TYPE)1000 |
---|
[3206] | 47 | #elif defined(_UNITS_T_BASE_USEC) |
---|
[5210] | 48 | #define _SEC_TYPE int_least32_t |
---|
| 49 | #define _SEC (_SEC_TYPE)1000000 |
---|
[3206] | 50 | //#elif defined(_UNITS_T_BASE_SEC) |
---|
| 51 | #else |
---|
| 52 | #define _SEC 1 |
---|
[5210] | 53 | #define _SEC_TYPE int |
---|
[3206] | 54 | #endif |
---|
[3209] | 55 | #endif |
---|
[3206] | 56 | |
---|
[5210] | 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) |
---|
[3206] | 63 | |
---|
| 64 | #define _MSEC (_SEC*_MILI) |
---|
| 65 | #define _USEC (_SEC*_MICRO) |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | /* distance */ |
---|
[3209] | 69 | #ifndef _METER |
---|
| 70 | #if defined(_UNITS_D_BASE_MMETER) |
---|
[5210] | 71 | #define _METER_TYPE int |
---|
[3209] | 72 | #define _METER 1000 |
---|
| 73 | #elif defined(_UNITS_D_BASE_UMETER) |
---|
[5210] | 74 | #define _METER_TYPE int_least32_t |
---|
| 75 | #define _METER (_METER_TYPE)1000000 |
---|
[3209] | 76 | //#elif defined(_UNITS_D_BASE_METER) |
---|
| 77 | #else |
---|
[5210] | 78 | #define _METER_TYPE int |
---|
[3206] | 79 | #define _METER 1 |
---|
[3209] | 80 | #endif |
---|
| 81 | #endif |
---|
| 82 | |
---|
[5210] | 83 | #ifndef _METER_TYPE |
---|
| 84 | #define _METER_TYPE int_least32_t |
---|
| 85 | #endif |
---|
| 86 | |
---|
| 87 | #define _AE ((int_least64_t)149597870691LL *_METER) |
---|
[3209] | 88 | #define _LJ (9460730472580800LL *_METER) |
---|
| 89 | #define _PC (30856804413117847LL*_METER) /* TODO: FIXME: get a more corret value */ |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | /* speed */ |
---|
[3210] | 93 | #define _MPS ((double)_METER/_SEC) |
---|
[3209] | 94 | #define _KMPH (_KILO*_METER/_HOUR) |
---|
[3210] | 95 | #define _SPEED_OF_SOUND_AIR (343. *_MPS) |
---|
| 96 | #define _SPEED_OF_SOUND_WATER (1407.*_MPS) |
---|
[3209] | 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 | |
---|
[3206] | 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 |
---|