Created
October 7, 2022 09:03
-
-
Save giuliomoro/bfa4281b2699e02ee87dd8cef792f463 to your computer and use it in GitHub Desktop.
hvcc basic build on macos 10.14.6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
static inline void* aligned_alloc(size_t alignment, size_t size){ | |
void* ret; | |
if(!posix_memalign(&ret, alignment, size)) | |
return ret; | |
else | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <Heavy_example.h> | |
void printHook(HeavyContextInterface *context, const char *printLabel, const char *msgString, const HvMessage *msg) { | |
const double timestampSecs = ((double) hv_msg_getTimestamp(msg)) / hv_getSampleRate(context); | |
printf("print: [@ %.3f] %s: %s\n", timestampSecs, printLabel, msgString); | |
} | |
int main() { | |
HeavyContextInterface *gHeavyContext = hv_example_new_with_options(44100, 2, 2, 0); | |
hv_setPrintHook(gHeavyContext, printHook); | |
unsigned int numElements = 64; | |
HvMessage* m = (HvMessage *)hv_alloca(hv_msg_getByteSize(numElements)); | |
hv_msg_init(m, numElements, 0); | |
for(unsigned int n = 0; n < numElements; ++n) | |
hv_msg_setFloat(m, n, n + 0.1f /*or whatev*/); | |
hv_sendMessageToReceiver(gHeavyContext, hv_stringToHash("myrecv"), 0, m); | |
int frames = 16; | |
hv_processInline(gHeavyContext, 0, 0, frames); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C_SRCS:=$(wildcard c/*.c) | |
CXX_SRCS:=$(wildcard c/*.cpp hvwrap.cpp) | |
C_OBJS:=$(C_SRCS:%.c=%.o) | |
CXX_OBJS:=$(CXX_SRCS:%.cpp=%.o) | |
CPPFLAGS:=-Ic -include aligned_alloc.h | |
CXXFLAGS:=-std=c++14 | |
CFLAGS:=-std=c11 | |
CXX:=clang++ | |
CC:=clang | |
%.o: %.c | |
$(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@ -c | |
%.o: %.cpp | |
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -c | |
all: a.out | |
a.out: $(CXX_OBJS) $(C_OBJS) | |
$(CXX) $^ -o $@ | |
clean: | |
rm -rf a.out $(CXX_OBJS) $(C_OBJS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment