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