Mercurial > hg > beaglert
comparison projects/heavy/envelopeTrigger/Utils_windows.h @ 162:c3e8226a5651 heavy-updated
- added additional flags to C rules (-DNDEBUG, -mfpu=neon)
- sample-accurate envelope triggering pd/heavy example
author | chnrx <chris.heinrichs@gmail.com> |
---|---|
date | Thu, 12 Nov 2015 14:59:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
161:07735c9d95c8 | 162:c3e8226a5651 |
---|---|
1 /** | |
2 * Copyright (c) 2014, 2015, Enzien Audio Ltd. | |
3 * | |
4 * Permission to use, copy, modify, and/or distribute this software for any | |
5 * purpose with or without fee is hereby granted, provided that the above | |
6 * copyright notice and this permission notice appear in all copies. | |
7 * | |
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | |
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
14 * PERFORMANCE OF THIS SOFTWARE. | |
15 */ | |
16 | |
17 #ifndef _HEAVY_UTILS_WINDOWS_H_ | |
18 #define _HEAVY_UTILS_WINDOWS_H_ | |
19 | |
20 #include "Utils.h" | |
21 | |
22 #if HV_WIN | |
23 #define _USE_MATH_DEFINES | |
24 #if HV_SIMD_AVX || HV_SIMD_SSE | |
25 #if HV_MSVC | |
26 #include <intrin.h> | |
27 #else | |
28 #include <immintrin.h> | |
29 #endif | |
30 #elif HV_SIMD_NEON | |
31 #include <arm_neon.h> | |
32 #endif | |
33 #include <malloc.h> | |
34 #include <assert.h> | |
35 #include <math.h> | |
36 #include <stdarg.h> | |
37 #include <stdint.h> | |
38 #include <stdio.h> | |
39 #include <stdlib.h> | |
40 #include <string.h> | |
41 #include <stdbool.h> | |
42 | |
43 #define HV_EXPORT __declspec(dllexport) | |
44 | |
45 // MSVC Specific | |
46 #if HV_MSVC | |
47 #define inline __inline | |
48 #define HV_FORCE_INLINE __forceinline | |
49 #else | |
50 #define HV_FORCE_INLINE inline __attribute__((always_inline)) | |
51 #define hv_snprintf(a, b, c, ...) snprintf(a, b, c, __VA_ARGS__) | |
52 #endif // HV_MSVC | |
53 | |
54 // Memory management | |
55 #define hv_alloca(_n) _alloca(_n) | |
56 #if !defined(HV_SIMD_AVX) || !defined(HV_SIMD_SSE) | |
57 #define hv_malloc(_n) _aligned_malloc(_n, 32) | |
58 #define hv_free(x) _aligned_free(x) | |
59 #else | |
60 #define hv_malloc(_n) malloc(_n) | |
61 #define hv_free(_n) free(_n) | |
62 #endif | |
63 #define hv_realloc(a, b) realloc(a, b) | |
64 #define hv_memcpy(a, b, c) memcpy(a, b, c) | |
65 #define hv_memset(a, b) memset(a, 0, b) | |
66 | |
67 // Strings | |
68 #define hv_strncat(a, b, c) strncat(a, b, c) | |
69 #define hv_strcmp(a, b) strcmp(a, b) | |
70 #define hv_strncmp(a, b, c) strncmp(a, b, c) | |
71 #define hv_strncpy(a, b, c) strncpy(a, b, c) | |
72 #define hv_strlen(a) strlen(a) | |
73 | |
74 // Math | |
75 #define hv_max_f(a, b) fmaxf(a, b) | |
76 #define hv_min_f(a, b) fminf(a, b) | |
77 #define hv_max_d(a, b) fmax(a, b) | |
78 #define hv_min_d(a, b) fmin(a, b) | |
79 #define hv_sin_f(a) sinf(a) | |
80 #define hv_sinh_f(a) sinhf(a) | |
81 #define hv_cos_f(a) cosf(a) | |
82 #define hv_cosh_f(a) coshf(a) | |
83 #define hv_tan_f(a) tanf(a) | |
84 #define hv_tanh_f(a) tanhf(a) | |
85 #define hv_asin_f(a) asinf(a) | |
86 #define hv_asinh_f(a) asinhf(a) | |
87 #define hv_acos_f(a) acosf(a) | |
88 #define hv_acosh_f(a) acoshf(a) | |
89 #define hv_atan_f(a) atanf(a) | |
90 #define hv_atanh_f(a) atanhf(a) | |
91 #define hv_atan2_f(a, b) atan2f(a, b) | |
92 #define hv_exp_f(a) expf(a) | |
93 #define hv_abs_f(a) fabsf(a) | |
94 #define hv_sqrt_f(a) sqrtf(a) | |
95 #define hv_log_f(a) logf(a) | |
96 #define hv_log2_f(a) log2f(a) | |
97 #define hv_log10_f(a) log10f(a) | |
98 #define hv_ceil_f(a) ceilf(a) | |
99 #define hv_floor_f(a) floorf(a) | |
100 #define hv_round_f(a) roundf(a) | |
101 #define hv_pow_f(a, b) powf(a, b) | |
102 #define hv_fma_f(a, b, c) ((a*b)+c) // TODO(joe): use 'fmaf(a, b, c)' once emscripten supports it | |
103 | |
104 // Utilities | |
105 #define hv_assert(e) assert(e) | |
106 #define hv_clear_buffer(b, n) memset(b, 0, n*sizeof(float)) | |
107 | |
108 #endif // HV_WIN | |
109 #endif // _HEAVY_UTILS_WINDOWS_H_ |