Mercurial > hg > beaglert
changeset 321:4475c0bc2aaa Doxy prerelease
Merge
author | Robert Jack <robert.h.jack@gmail.com> |
---|---|
date | Fri, 27 May 2016 12:32:11 +0100 |
parents | 634c1d1f37bc (current diff) ff1d22e2c5a0 (diff) |
children | dde921ea256b |
files | Makefile |
diffstat | 9 files changed, 342 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Fri May 27 12:30:44 2016 +0100 +++ b/Makefile Fri May 27 12:32:11 2016 +0100 @@ -33,13 +33,13 @@ ifndef COMPILER # check whether clang is installed - TEST_COMPILER := $(shell which clang) - ifneq ($(strip $(TEST_COMPILER)), ) - # if it is installed, use it - COMPILER := clang - else +# TEST_COMPILER := $(shell which clang) +# ifneq ($(strip $(TEST_COMPILER)), ) +# # if it is installed, use it +# COMPILER := clang +# else COMPILER := gcc - endif +# endif endif ifeq ($(COMPILER), clang)
--- a/projects/heavy/pd/hello-midi/_main.pd Fri May 27 12:30:44 2016 +0100 +++ b/projects/heavy/pd/hello-midi/_main.pd Fri May 27 12:32:11 2016 +0100 @@ -7,9 +7,9 @@ #X text 202 438 @krighxz / BELA / heavy / 12/2015; #X text 226 457 beaglert.cc / enzienaudio.com; #X obj 39 132 mtof; -#X floatatom 79 59 5 0 0 0 - - -; -#X floatatom 122 59 5 0 0 0 - - -; -#X floatatom 41 63 5 0 0 0 - - -; +#X floatatom 79 59 5 0 0 0 - - -, f 5; +#X floatatom 122 59 5 0 0 0 - - -, f 5; +#X floatatom 41 63 5 0 0 0 - - -, f 5; #X obj 26 170 phasor~ 440; #X text 100 363 (the harsh sound of success); #X obj 260 83 * 20; @@ -36,12 +36,13 @@ #X obj 40 28 bela_notein 0; #X obj 260 60 bela_ctlin 5 0; #X obj 220 151 bela_ctlin 6 0; -#X obj 408 121 bela_pgmin 3; #X text 537 58 [ctlin]; #X text 332 27 [notein]; #X text 140 29 <== the bela equivalent of ==>; #X text 349 59 <== the bela equivalent of ==>; #X text 483 121 <== the bela equivalent of ==>; +#X obj 405 175 print pgmin; +#X obj 408 121 bela_pgmin 0; #X connect 3 0 0 1; #X connect 3 0 0 0; #X connect 7 0 11 0; @@ -77,3 +78,4 @@ #X connect 33 2 9 0; #X connect 34 0 13 0; #X connect 35 0 19 0; +#X connect 42 0 41 0;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/projects/heavy/pd/hello-midi/backmain.pd Fri May 27 12:32:11 2016 +0100 @@ -0,0 +1,79 @@ +#N canvas 85 58 1280 685 10; +#X obj 19 396 dac~ 1 2; +#X text 39 1 Hello world!; +#X text 37 11 ============; +#X obj 31 353 *~ 0.1; +#X text 202 448 ---------------------------------; +#X text 202 438 @krighxz / BELA / heavy / 12/2015; +#X text 226 457 beaglert.cc / enzienaudio.com; +#X obj 39 132 mtof; +#X floatatom 79 59 5 0 0 0 - - -, f 5; +#X floatatom 122 59 5 0 0 0 - - -, f 5; +#X floatatom 41 63 5 0 0 0 - - -, f 5; +#X obj 26 170 phasor~ 440; +#X text 100 363 (the harsh sound of success); +#X obj 260 83 * 20; +#X obj 261 112 + 200; +#X obj 132 85 loadbang; +#X msg 131 111 1000; +#X obj 125 166 sig~; +#X text 673 121 [pgmin]; +#X obj 218 178 * 10; +#X obj 30 250 hip~; +#X obj 26 275 hip~; +#X obj 20 302 hip~; +#X obj 19 323 hip~; +#X obj 87 192 lop~ 4; +#X obj 152 256 line; +#X obj 200 200 + 50; +#X msg 170 227 \$1 200; +#X msg 93 114 0; +#X msg 185 112 0; +#X obj 29 224 vcf~ 4; +#X obj 70 333 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X obj 42 92 mono; +#X obj 40 28 bela_notein 0; +#X obj 260 60 bela_ctlin 5 0; +#X obj 220 151 bela_ctlin 6 0; +#X obj 408 121 bela_pgmin 3; +#X text 537 58 [ctlin]; +#X text 332 27 [notein]; +#X text 140 29 <== the bela equivalent of ==>; +#X text 349 59 <== the bela equivalent of ==>; +#X text 483 121 <== the bela equivalent of ==>; +#X connect 3 0 0 1; +#X connect 3 0 0 0; +#X connect 7 0 11 0; +#X connect 8 0 32 1; +#X connect 10 0 32 0; +#X connect 11 0 30 0; +#X connect 13 0 14 0; +#X connect 14 0 17 0; +#X connect 15 0 16 0; +#X connect 15 0 29 0; +#X connect 15 0 28 0; +#X connect 16 0 17 0; +#X connect 17 0 24 0; +#X connect 19 0 26 0; +#X connect 20 0 21 0; +#X connect 21 0 22 0; +#X connect 22 0 23 0; +#X connect 23 0 3 0; +#X connect 24 0 30 1; +#X connect 25 0 20 1; +#X connect 25 0 21 1; +#X connect 25 0 22 1; +#X connect 25 0 23 1; +#X connect 26 0 27 0; +#X connect 27 0 25 0; +#X connect 29 0 19 0; +#X connect 30 0 20 0; +#X connect 31 0 3 1; +#X connect 32 0 7 0; +#X connect 32 1 31 0; +#X connect 33 0 10 0; +#X connect 33 1 8 0; +#X connect 33 2 9 0; +#X connect 34 0 13 0; +#X connect 35 0 19 0;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/projects/heavy/pd/hello-midi/bela_ctlin.pd Fri May 27 12:32:11 2016 +0100 @@ -0,0 +1,76 @@ +#N canvas 554 204 703 475 10; +#X obj 53 431 outlet; +#X obj 108 429 outlet; +#X obj 99 127 r ctlin; +#X obj 92 151 unpack f f f; +#X obj 154 429 outlet; +#X obj 86 322 spigot; +#X text 51 450 value; +#X text 105 450 number; +#X obj 211 138 loadbang; +#X obj 177 193 \$1; +#X obj 126 214 == \$1; +#X obj 119 299 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X obj 84 349 unpack f f f; +#X obj 143 247 ||; +#X obj 177 217 == 0; +#X text 70 11 Emulates ctlin \, except number of outlets is fixed. +; +#X obj 228 247 ||; +#X obj 262 217 == 0; +#X obj 212 214 == \$2; +#X obj 262 193 \$2; +#X obj 177 277 &&; +#X obj 211 163 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X text 173 299 If (inputController==\$1 || \$1==0) && (inputChannel==\$2 +|| \$2==0); +#X text 197 52 Known issue: trying to select inputController 0 will +result i accepting all controllers (because a pd external cannot tell +the difference between \$1 been explicitely set to 0 and the patch +not having any argument); +#X text 162 450 channel; +#X obj 56 192 pack f f f; +#X obj 80 408 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X floatatom 81 382 5 0 0 0 - - -, f 5; +#X obj 121 412 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X floatatom 122 386 5 0 0 0 - - -, f 5; +#X obj 172 406 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X floatatom 173 380 5 0 0 0 - - -, f 5; +#X obj 122 92 s ctlin; +#X obj 64 29 r bela_ctlin; +#X connect 2 0 3 0; +#X connect 3 0 25 0; +#X connect 3 1 10 0; +#X connect 3 1 25 1; +#X connect 3 2 18 0; +#X connect 3 2 25 2; +#X connect 5 0 12 0; +#X connect 8 0 21 0; +#X connect 9 0 14 0; +#X connect 10 0 13 0; +#X connect 11 0 5 1; +#X connect 12 0 0 0; +#X connect 12 0 27 0; +#X connect 12 1 1 0; +#X connect 12 1 29 0; +#X connect 12 2 4 0; +#X connect 12 2 31 0; +#X connect 13 0 20 0; +#X connect 14 0 13 1; +#X connect 16 0 20 1; +#X connect 17 0 16 1; +#X connect 18 0 16 0; +#X connect 19 0 17 0; +#X connect 20 0 11 0; +#X connect 21 0 9 0; +#X connect 21 0 19 0; +#X connect 25 0 5 0; +#X connect 27 0 26 0; +#X connect 29 0 28 0; +#X connect 31 0 30 0; +#X connect 33 0 32 0;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/projects/heavy/pd/hello-midi/bela_notein.pd Fri May 27 12:32:11 2016 +0100 @@ -0,0 +1,59 @@ +#N canvas 399 23 629 685 10; +#X obj 94 481 outlet; +#X obj 165 475 outlet; +#X obj 141 184 unpack f f f; +#X obj 221 472 outlet; +#X obj 143 365 spigot; +#X obj 268 181 loadbang; +#X obj 234 236 \$1; +#X obj 183 257 == \$1; +#X obj 176 342 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X obj 143 392 unpack f f f; +#X obj 200 290 ||; +#X obj 234 260 == 0; +#X obj 268 206 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X text 160 65 Emulates notein \, except number of outlets is fixed. +; +#X text 92 499 notenumber; +#X text 161 489 velocity; +#X text 220 486 channel; +#X text 229 311 If (inputChannel==\$1 || \$1==0); +#X obj 115 232 pack f f f; +#X obj 82 428 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X floatatom 84 410 5 0 0 0 - - -, f 5; +#X obj 145 448 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X floatatom 147 430 5 0 0 0 - - -, f 5; +#X obj 198 451 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X floatatom 200 433 5 0 0 0 - - -, f 5; +#X obj 131 112 s notein; +#X obj 140 149 r notein; +#X obj 135 84 r bela_notein; +#X connect 2 0 18 0; +#X connect 2 1 18 1; +#X connect 2 2 7 0; +#X connect 2 2 18 2; +#X connect 4 0 9 0; +#X connect 5 0 12 0; +#X connect 6 0 11 0; +#X connect 7 0 10 0; +#X connect 8 0 4 1; +#X connect 9 0 0 0; +#X connect 9 0 20 0; +#X connect 9 1 1 0; +#X connect 9 1 22 0; +#X connect 9 2 3 0; +#X connect 9 2 24 0; +#X connect 10 0 8 0; +#X connect 11 0 10 1; +#X connect 12 0 6 0; +#X connect 18 0 4 0; +#X connect 20 0 19 0; +#X connect 22 0 21 0; +#X connect 24 0 23 0; +#X connect 26 0 2 0; +#X connect 27 0 25 0;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/projects/heavy/pd/hello-midi/bela_pgmin.pd Fri May 27 12:32:11 2016 +0100 @@ -0,0 +1,53 @@ +#N canvas 623 197 587 546 10; +#X obj 73 413 outlet; +#X obj 174 411 outlet; +#X obj 106 304 spigot; +#X obj 197 126 loadbang; +#X obj 197 175 \$1; +#X obj 146 196 == \$1; +#X obj 139 281 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X obj 163 229 ||; +#X obj 197 199 == 0; +#X obj 197 151 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X obj 89 111 unpack f f; +#X obj 106 332 unpack f f; +#X text 52 436 program number; +#X text 182 432 channel; +#X text 193 281 If (channel==\$1 || \$1==0); +#X text 167 45 emulates pgmin except it always has 2 outlets and requires +the input parameters to be explicitely set. Set them to 0 to avoid +filtering; +#X text 262 132 It'd be nicer with [t l l] but have to compensate for +the fact that it is not supported by heavy; +#X obj 77 183 pack f f; +#X floatatom 72 355 5 0 0 0 - - -, f 5; +#X obj 63 379 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X floatatom 150 361 5 0 0 0 - - -, f 5; +#X obj 141 385 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X obj 91 63 s pgmin; +#X obj 93 87 r pgmin; +#X obj 89 42 r bela_pgmin; +#X connect 2 0 11 0; +#X connect 3 0 9 0; +#X connect 4 0 8 0; +#X connect 5 0 7 0; +#X connect 6 0 2 1; +#X connect 7 0 6 0; +#X connect 8 0 7 1; +#X connect 9 0 4 0; +#X connect 10 0 17 0; +#X connect 10 1 5 0; +#X connect 10 1 17 1; +#X connect 11 0 0 0; +#X connect 11 0 18 0; +#X connect 11 1 1 0; +#X connect 11 1 20 0; +#X connect 17 0 2 0; +#X connect 18 0 19 0; +#X connect 20 0 21 0; +#X connect 23 0 10 0; +#X connect 24 0 22 0;
--- a/scripts/hvresources/HvUtils.h Fri May 27 12:30:44 2016 +0100 +++ b/scripts/hvresources/HvUtils.h Fri May 27 12:32:11 2016 +0100 @@ -25,6 +25,8 @@ #endif #elif __APPLE__ #define HV_APPLE 1 +#elif __ANDROID__ + #define HV_ANDROID 1 #elif __unix__ || __unix #define HV_UNIX 1 #else @@ -45,10 +47,12 @@ #define hv_uint16_t uint16_t // SIMD-specific includes -#ifndef HV_SIMD_NONE +#if !(HV_SIMD_NONE || HV_SIMD_NEON || HV_SIMD_SSE || HV_SIMD_AVX) #define HV_SIMD_NEON __ARM_NEON__ #define HV_SIMD_SSE (__SSE__ && __SSE2__ && __SSE3__ && __SSSE3__ && __SSE4_1__) #define HV_SIMD_AVX (__AVX__ && HV_SIMD_SSE) +#endif +#ifndef HV_SIMD_FMA #define HV_SIMD_FMA __FMA__ #endif @@ -139,11 +143,17 @@ #elif HV_APPLE #define hv_alloca(_n) alloca(_n) #if HV_SIMD_AVX + #include <mm_malloc.h> #define hv_malloc(_n) _mm_malloc(_n, 32) #define hv_free(x) _mm_free(x) - #elif HV_SIMD_SSE || HV_SIMD_NEON + #elif HV_SIMD_SSE + #include <mm_malloc.h> #define hv_malloc(_n) _mm_malloc(_n, 16) #define hv_free(x) _mm_free(x) + #elif HV_SIMD_NEON + // malloc on ios always has 16-byte alignment + #define hv_malloc(_n) malloc(_n) + #define hv_free(x) free(x) #else // HV_SIMD_NONE #define hv_malloc(_n) malloc(_n) #define hv_free(x) free(x) @@ -154,10 +164,18 @@ #if HV_SIMD_AVX #define hv_malloc(_n) aligned_alloc(32, _n) #define hv_free(x) free(x) - #elif HV_SIMD_SSE || HV_SIMD_NEON - //#define hv_malloc(_n) aligned_alloc(16, _n) - #define hv_malloc(_n) memalign(16, _n) + #elif HV_SIMD_SSE + #define hv_malloc(_n) aligned_alloc(16, _n) #define hv_free(x) free(x) + #elif HV_SIMD_NEON + #if HV_ANDROID + #define hv_malloc(_n) memalign(16, _n) + #define hv_free(x) free(x) + #else + //#define hv_malloc(_n) aligned_alloc(16, _n) + #define hv_malloc(_n) memalign(16, _n) + #define hv_free(x) free(x) + #endif #else // HV_SIMD_NONE #define hv_malloc(_n) malloc(_n) #define hv_free(_n) free(_n) @@ -209,7 +227,12 @@ #define hv_abs_f(a) fabsf(a) #define hv_sqrt_f(a) sqrtf(a) #define hv_log_f(a) logf(a) -#define hv_log2_f(a) log2f(a) +#if HV_ANDROID + // NOTE(mhroth): for whatever silly reason, log2f is not defined! + #define hv_log2_f(a) (1.44269504088896f*logf(a)) +#else + #define hv_log2_f(a) log2f(a) +#endif // HV_ANDROID #define hv_log10_f(a) log10f(a) #define hv_ceil_f(a) ceilf(a) #define hv_floor_f(a) floorf(a) @@ -231,4 +254,31 @@ #endif #define hv_min_max_log2(a) __hv_utils_min_max_log2(a) +// Atomics +#if HV_WIN +#include <Windows.h> +#define hv_atomic_bool volatile LONG +#define HV_SPINLOCK_ACQUIRE(_x) \ +while (InterlockedCompareExchange(&_x, true, false)) { } +#define HV_SPINLOCK_RELEASE(_x) (_x = false) +#elif defined(__has_include) +#if __has_include(<stdatomic.h>) +#include <stdatomic.h> +#define hv_atomic_bool volatile atomic_bool +#define HV_SPINLOCK_ACQUIRE(_x) \ +bool expected = false; \ +while (!atomic_compare_exchange_strong(&_x, &expected, true)) { expected = false; } +#define HV_SPINLOCK_RELEASE(_x) atomic_store(&_x, false) +#else +#define hv_atomic_bool volatile bool +#define HV_SPINLOCK_ACQUIRE(_x) _x = true; +#define HV_SPINLOCK_RELEASE(_x) _x = false; +#endif +#else +#define hv_atomic_bool volatile bool +#define HV_SPINLOCK_ACQUIRE(_x) _x = true; +#define HV_SPINLOCK_RELEASE(_x) _x = false; +#endif + + #endif // _HEAVY_UTILS_H_
--- a/scripts/hvresources/render.cpp Fri May 27 12:30:44 2016 +0100 +++ b/scripts/hvresources/render.cpp Fri May 27 12:32:11 2016 +0100 @@ -117,6 +117,10 @@ //hv_vscheduleMessageForReceiver(gHeavyContext, "bbb_bang", 0.0f, "b"); { int num; + unsigned int hvHashes[3]; + hvHashes[0] = hv_stringToHash("bela_notein"); + hvHashes[1] = hv_stringToHash("bela_ctlin"); + hvHashes[2] = hv_stringToHash("bela_pgmin"); while((num = midi.getParser()->numAvailableMessages()) > 0){ static MidiChannelMessage message; message = midi.getParser()->getNextChannelMessage(); @@ -127,16 +131,16 @@ float velocity = message.getDataByte(1); float channel = message.getChannel(); // rt_printf("message: noteNumber: %f, velocity: %f, channel: %f\n", noteNumber, velocity, channel); - hv_vscheduleMessageForReceiver(gHeavyContext, "bela_notein", 0, "fff", noteNumber, velocity, channel); + hv_vscheduleMessageForReceiver(gHeavyContext, hvHashes[0], 0, "fff", noteNumber, velocity, channel); } break; case kmmControlChange: { - hv_vscheduleMessageForReceiver(gHeavyContext, "bela_ctlin", 0, "fff", + hv_vscheduleMessageForReceiver(gHeavyContext, hvHashes[1], 0, "fff", (float)message.getDataByte(1), (float)message.getDataByte(0), (float)message.getChannel()); } break; case kmmProgramChange: - hv_vscheduleMessageForReceiver(gHeavyContext, "bela_pgmin", 0, "ff", + hv_vscheduleMessageForReceiver(gHeavyContext, hvHashes[2], 0, "ff", (float)message.getDataByte(0), (float)message.getChannel()); break; }