diff --git a/templates/vst3/src/vst3.c b/templates/vst3/src/vst3.c index 8e67915..b4bf45f 100644 --- a/templates/vst3/src/vst3.c +++ b/templates/vst3/src/vst3.c @@ -613,7 +613,7 @@ static Steinberg_tresult pluginProcess(void* thisInterface, struct Steinberg_Vst break; case Steinberg_Vst_Event_EventTypes_kNoteOffEvent: { - const uint8_t data[3] = { 0x90 | ev.Steinberg_Vst_Event_noteOff.channel, ev.Steinberg_Vst_Event_noteOff.pitch, (uint8_t)(127.f * ev.Steinberg_Vst_Event_noteOff.velocity) }; + const uint8_t data[3] = { 0x80 | ev.Steinberg_Vst_Event_noteOff.channel, ev.Steinberg_Vst_Event_noteOff.pitch, (uint8_t)(127.f * ev.Steinberg_Vst_Event_noteOff.velocity) }; plugin_midi_msg_in(&p->p, midiInIndex[ev.busIndex], data); } break; diff --git a/templates/web-make/Makefile b/templates/web-make/Makefile index bfdda9f..8dec608 100644 --- a/templates/web-make/Makefile +++ b/templates/web-make/Makefile @@ -16,6 +16,11 @@ LDFLAGS_ALL = \ -Wl,--lto-O3 \ -Wl,-strip-all \ -Wl,--export-table \ + -Wl,--export=malloc \ + -Wl,--export=realloc \ + -Wl,--export=calloc \ + -Wl,--export=free \ + -Wl,--export=memset \ -Wl,--export=processor_new \ -Wl,--export=processor_free \ -Wl,--export=processor_get_x_buf \ diff --git a/templates/web/src/walloc.c b/templates/web/src/walloc.c index 68cb155..3ea4b2d 100644 --- a/templates/web/src/walloc.c +++ b/templates/web/src/walloc.c @@ -5,6 +5,7 @@ #include "walloc.h" #include +#include "memset.h" extern unsigned char __heap_base; @@ -109,6 +110,17 @@ void *realloc(void *ptr, size_t size) { return p; } +void *calloc(size_t nmemb, size_t size) { + if (nmemb == 0 || SIZE_MAX / nmemb > size || (SIZE_MAX / nmemb == size && SIZE_MAX % nmemb != 0)) + return NULL; + size_t s = nmemb * size; + void *m = malloc(s); + if (m == NULL) + return NULL; + memset(m, 0, s); + return m; +} + void free(void *ptr) { header *h = (header *)((char *)ptr - sizeof(header)); h->free = 1; diff --git a/templates/web/src/walloc.h b/templates/web/src/walloc.h index d65dcb8..f4a2bb9 100644 --- a/templates/web/src/walloc.h +++ b/templates/web/src/walloc.h @@ -13,6 +13,7 @@ extern "C" { void *malloc(size_t size); void *realloc(void *ptr, size_t size); +void *calloc(size_t nmemb, size_t size); void free(void *ptr); #ifdef __cplusplus