diff --git a/Makefile b/Makefile old mode 100755 new mode 100644 index cdfe073..9477d49 --- a/Makefile +++ b/Makefile @@ -1,148 +1,148 @@ -# NOTE: C implies LADSPA, C++ implies VST -# it's hackish but it'll do for now - DISTNAME = crap VERSION = git -FULLNAME = ${DISTNAME}-${VERSION} +FULLNAME = $(DISTNAME)-$(VERSION) -BIN = ./bin -CRAP = ./crap -INCLUDE = ./include -TEMPLATE = ./template -UTIL = ./util +BIN ?= ./bin +VST_SDK_DIR ?= . BOTH = eq eq_const noise tube -LADSPA_ONLY = -VST_ONLY = delay_test -LADSPA = ${BOTH:=-ladspa} ${LADSPA_ONLY:=-ladspa} -VST = ${BOTH:=-vst} ${VST_ONLY:=-vst} -PLUGINS = ${LADSPA} ${VST} +LADSPA = $(BOTH) +VST = $(BOTH) delay_test -EXE = design -_ = util util_def param -HEADERS = ${_:%=$(INCLUDE)/%.h} -SHOBJ = ${PLUGINS:%=$(BIN)/$(DISTNAME)_%.so} -OBJ = ${PLUGINS:%=$(BIN)/$(DISTNAME)_%.o} $(BIN)/vstsdk.o +UTILS = design bench +INCLUDES = util util_def param -# only for dist target right now -SRC = ${BOTH:%=$(CRAP)/%.h} -SRC += ${LADSPA_ONLY:%=$(CRAP)/%.h} ${VST_ONLY:%=$(CRAP)/%.h} -SRC += ${EXE:%=$(UTIL)/%.c} +BENCH_AGAINST = eq_const -BENCH = $(BIN)/bench.o -AGAINST = $(BIN)/crap_eq_const-ladspa.so +### + +PROGRAM = ${UTILS:%=$(BIN)/%} +HEADERS = ${INCLUDES:%=include/%.h} + +LADSPA_SHOBJ = ${LADSPA:%=$(BIN)/$(DISTNAME)_%-ladspa.so} +VST_SHOBJ = ${VST:%=$(BIN)/$(DISTNAME)_%-vst.so} +SHOBJ = $(LADSPA_SHOBJ) $(VST_SHOBJ) +OBJ = ${SHOBJ:.so=.o} +AGAINST = $(BIN)/$(DISTNAME)_$(BENCH_AGAINST)-ladspa.so +#EXE = ${PROGRAM:=.exe} +EXE = $(BIN)/design.exe +DLL = ${SHOBJ:.so=.dll} -VST_SDK_DIR ?= . VST_CPP = audioeffect.cpp audioeffectx.cpp vstplugmain.cpp -VST_SUB_DIR = public.sdk/source/vst2.x -VST_SRC = ${VST_CPP:%=${VST_SDK_DIR}/${VST_SUB_DIR}/%} -# temp objects before combining to vstsdk.o +VST_CPP_DIR = $(VST_SDK_DIR)/public.sdk/source/vst2.x +VST_SRC = ${VST_CPP:%=$(VST_CPP_DIR)/%} VST_OBJ = ${VST_CPP:%.cpp=$(BIN)/%.o} -VST_DEF = ${VST_SDK_DIR}/public.sdk/samples/vst2.x/win/vstplug.def +VST_DEF = $(VST_SDK_DIR)/public.sdk/samples/vst2.x/win/vstplug.def -ALL_CFLAGS = -Wall -Wno-unused-function ${CFLAGS} -std=gnu99 -I $(INCLUDE) -ALL_CXXFLAGS = -Wno-write-strings ${CXXFLAGS} -I ${VST_SDK_DIR} -ALL_CXXFLAGS += -I $(INCLUDE) -DBUILDING_DLL=1 -ALL_LDFLAGS = -lm ${LDFLAGS} +GENERAL_FLAGS = -Wall -Wno-unused-function -I include +ALL_CFLAGS = $(GENERAL_FLAGS) -std=gnu99 $(CFLAGS) +ALL_CXXFLAGS = $(GENERAL_FLAGS) $(CXXFLAGS) +ALL_LDFLAGS = -lm $(LDFLAGS) -PREFIX ?= /usr/local -EXEC_PREFIX ?= ${PREFIX} -LIBDIR ?= ${EXEC_PREFIX}/lib -LADSPADIR ?= ${LIBDIR}/ladspa +LADSPA_FLAGS = +VST_FLAGS = -Wno-write-strings -Wno-narrowing +VST_FLAGS += -I $(VST_SDK_DIR) -DBUILDING_DLL=1 -LADSPADEST = ${DESTDIR}${LADSPADIR} +OPT_FLAGS = -Ofast -march=core2 -mfpmath=sse -ALL = ${SHOBJ} ${OBJ} ${EXE:%=$(BIN)/%} -MISC_CLEAN = bench ${BENCH} ${VST_OBJ} -MISC_DIST = LICENSE README.md Makefile -MISC_DIST += $(UTIL)/benchtime $(UTIL)/${BENCH:.o=.c} -MISC_DIST += $(UTIL)/generate -MISC_DIST += $(TEMPLATE)/vst.cpp $(TEMPLATE)/ladspa.c $(INCLUDE)/ladspa.h - -all: ladspa vst ${EXE:%=$(BIN)/%} - -.PHONY: options -options: - @echo "CPPFLAGS = ${CPPFLAGS}" - @echo "ALL_CFLAGS = ${ALL_CFLAGS}" - @echo "ALL_CXXFLAGS = ${ALL_CXXFLAGS}" - @echo "ALL_LDFLAGS = ${ALL_LDFLAGS}" - @echo "CC = ${CC}" - @echo "CXX = ${CXX}" - @echo "LD = ${LD}" - @echo - -ladspa: ${LADSPA:%=$(BIN)/$(DISTNAME)_%.so} - -vst: ${VST:%=$(BIN)/$(DISTNAME)_%.so} - -$(BIN)/bench: ${BENCH} - @echo ' CC '$@ - @${CC} ${ALL_CFLAGS} ${BENCH} -o $@ ${ALL_LDFLAGS} -rdynamic -ldl - -.PHONY: benchmark -benchmark: $(BIN)/bench ${AGAINST} - $(UTIL)/benchtime $(BIN)/bench ${AGAINST} - -$(VST_OBJ): ${VST_SRC} - @echo ' CXX '$@ - @${CXX} -c ${ALL_CXXFLAGS} ${CPPFLAGS} ${VST_SDK_DIR}/${VST_SUB_DIR}/$(notdir ${@:.o=.cpp}) -o $@ - -$(BIN)/vstsdk.o: ${VST_OBJ} - @echo ' LD '$@ - @${LD} -r ${VST_OBJ} -o $@ - -$(BIN)/%-ladspa.so: $(BIN)/%-ladspa.o - @echo ' LD '$@ - @${CC} ${ALL_CFLAGS} -shared $^ -o $@ ${ALL_LDFLAGS} - -$(BIN)/%-vst.so: $(BIN)/%-vst.o $(BIN)/vstsdk.o - @echo ' LD '$@ - @${CXX} ${ALL_CXXFLAGS} -shared $^ -o $@ ${ALL_LDFLAGS} - -$(BIN)/$(DISTNAME)_%-ladspa.o: $(CRAP)/%-ladspa.c ${HEADERS} $(INCLUDE)/ladspa.h - @echo ' CC '$@ - @${CC} -c ${ALL_CFLAGS} ${CPPFLAGS} $< -o $@ - -$(BIN)/$(DISTNAME)_%-vst.o: $(CRAP)/%-vst.cpp ${HEADERS} - @echo ' CXX '$@ - @${CXX} -c ${ALL_CXXFLAGS} ${CPPFLAGS} $< -o $@ - -$(CRAP)/%-ladspa.c: $(CRAP)/%.h $(TEMPLATE)/ladspa.c $(UTIL)/generate - @echo ' gen '$@ - @$(UTIL)/generate $(notdir $<) $@ $(TEMPLATE)/ladspa.c - -$(CRAP)/%-vst.cpp: $(CRAP)/%.h $(TEMPLATE)/vst.cpp $(UTIL)/generate - @$(UTIL)/generate $(notdir $<) $@ $(TEMPLATE)/vst.cpp +# any possibly produced files besides intermediates +ALL = $(SHOBJ) $(PROGRAM) $(BIN)/vstsdk.o $(EXE) $(DLL) .SUFFIXES: -$(BIN)/%: $(BIN)/%.o +# TODO: force options before clean before everything else + +.PHONY: all options clean dist pretest ladspa vst $(UTILS) +.PHONY: benchmark windows linux +all: pretest ladspa vst + +exe: $(EXE) + +dll: $(DLL) + +windows: ALL_CFLAGS += $(OPT_FLAGS) +windows: ALL_CXXFLAGS += $(OPT_FLAGS) +windows: dll + +linux: ALL_CFLAGS += $(OPT_FLAGS) -fpic +linux: ALL_CXXFLAGS += $(OPT_FLAGS) -fpic +linux: VST_FLAGS += -D__cdecl= +linux: all + +options: + @echo "CPPFLAGS = $(CPPFLAGS)" + @echo "ALL_CFLAGS = $(ALL_CFLAGS)" + @echo "ALL_CXXFLAGS = $(ALL_CXXFLAGS)" + @echo "ALL_LDFLAGS = $(ALL_LDFLAGS)" + @echo "CC = $(CC)" + @echo "CXX = $(CXX)" + @echo "LD = $(LD)" + @echo + +ladspa: $(LADSPA_SHOBJ) + +vst: $(VST_SHOBJ) + +pretest: util/sse_test.h + @$(CC) -E $(ALL_CFLAGS) $^ -o /dev/null + +benchmark: $(BIN)/bench $(AGAINST) + util/benchtime $(BIN)/bench $(AGAINST) + +$(UTILS): %: $(BIN)/% + +$(BIN)/%.exe: $(BIN)/% + @echo 'OBJCOPY '$@ + @objcopy -S $< $@ + +$(BIN)/%.dll: $(BIN)/%.so + @echo 'OBJCOPY '$@ + @objcopy -S $< $@ + +$(BIN)/%-ladspa.so: $(BIN)/%-ladspa.o + @echo ' LD '$@ + @$(CC) $(ALL_CFLAGS) $(LADSPA_FLAGS) -shared $^ -o $@ $(ALL_LDFLAGS) + +$(BIN)/%-vst.so: $(BIN)/%-vst.o $(BIN)/vstsdk.o + @echo ' LD '$@ + @$(CXX) $(ALL_CXXFLAGS) $(VST_FLAGS) -shared $^ -o $@ $(ALL_LDFLAGS) + +$(BIN)/$(DISTNAME)_%-ladspa.o: crap/%-ladspa.c $(HEADERS) include/ladspa.h @echo ' CC '$@ - @${CC} ${ALL_CFLAGS} $< -o $@ ${ALL_LDFLAGS} + @$(CC) -c $(ALL_CFLAGS) $(LADSPA_FLAG) $(CPPFLAGS) $< -o $@ -$(BIN)/%.o: $(UTIL)/%.c +$(BIN)/$(DISTNAME)_%-vst.o: crap/%-vst.cpp $(HEADERS) + @echo ' CXX '$@ + @$(CXX) -c $(ALL_CXXFLAGS) $(VST_FLAGS) $(CPPFLAGS) $< -o $@ + +crap/%-ladspa.c: crap/%.h template/ladspa.c util/generate + @echo ' gen '$@ + @util/generate $(notdir $<) $@ template/ladspa.c + +crap/%-vst.cpp: crap/%.h template/vst.cpp util/generate + @echo ' gen '$@ + @util/generate $(notdir $<) $@ template/vst.cpp + +$(BIN)/vstsdk.o: $(VST_OBJ) + @echo ' LD '$@ + @$(LD) -r $^ -o $@ + +.INTERMEDIATE: $(VST_OBJ) +$(VST_OBJ): $(BIN)/%.o: $(VST_CPP_DIR)/%.cpp + @echo ' CXX '$@ + @$(CXX) -c $(ALL_CXXFLAGS) $(VST_FLAGS) $(CPPFLAGS) $< -o $@ + +$(BIN)/bench: util/bench.c @echo ' CC '$@ - @${CC} -c ${ALL_CFLAGS} ${CPPFLAGS} $< -o $@ + @$(CC) $(ALL_CFLAGS) $(LADSPA_FLAGS) $< -o $@ $(ALL_LDFLAGS) -rdynamic -ldl -install: all - mkdir -p ${LADSPADEST} - install -d ${LADSPADEST} - install -m 644 $(BIN)/${LADSPA:=.so} ${LADSPADEST} +$(BIN)/design: util/design.c + @echo ' CC '$@ + @$(CC) $(ALL_CFLAGS) $< -o $@ $(ALL_LDFLAGS) -.PHONY: clean clean: - -rm -f ${ALL} ${MISC_CLEAN} + rm -f $(ALL) -.PHONY: dist dist: - @echo " dist target is broken for now, sorry" - @false - -rm -f ${FULLNAME}.tar.gz - mkdir ${FULLNAME} - cp ${MISC_DIST} ${FULLNAME} - cp ${HEADERS} ${FULLNAME} - cp ${SRC} ${FULLNAME} - tar -cf ${FULLNAME}.tar ${FULLNAME} - gzip ${FULLNAME}.tar - rm -r ${FULLNAME} + @echo "# dist target is unimplemented, trying git instead" + git archive --prefix=$(FULLNAME)/ HEAD -o $(FULLNAME).tar.gz diff --git a/README.md b/README.md index 088f836..bfb4df8 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,13 @@ connor's rancid audio plugins. LADSPA and VST. alternatively, configuration realizes any personality. +this is a set of hacked-together hacks to be hacked on +in the personal interest of learning and experimenting. +you should look elsewhere if you need an *enterprize-quality* +cross-platform library to build *lean & agile socially-networked* audio apps. + +MIT-licensed; go wild. + ## plugs ### crap Parametric Equalizer @@ -29,7 +36,7 @@ white noise generator. loud, full-range, 0dBFS. don't say i didn't warn you. __crap\_tube (0x50F7BA11)__ -static waveshaper with 4x oversampling, sounds kinda like a tube I guess? +static waveshaper with 4x oversampling, sounds kinda like a tube i guess? be aware that the oversampling is a bit naive and attenuates the signal past 17kHz, assuming a 44.1kHz sample rate. @@ -41,17 +48,16 @@ experimentation with delay compensation and EQ oversampling, not for use. ## build notes -`make` it. - -a `benchmark` target is included, however it doesn't build on Windows. - -for speed, try `CFLAGS="-O3 -ffast-math -march=core2 -mfpmath=sse"` -and the same for CXXFLAGS. - -on Linux, you'll need `CFLAGS+=" -fpic" CXXFLAGS+=" -fpic -D__cdecl="` +`make linux` or `make windows` (works well with [mxe]) +[mxe]: //mxe.cc remember to export `VST_SDK_DIR` to the path of your `vstsdk2.4/` +other targets: +* all: no hand-holding. +* design: simple CLI to the biquad coefficient calculator. +* benchmark: does what it says on the tin. no Windows support. + ## TODO * rename plugins (fix capitalization consistency and such) @@ -59,3 +65,4 @@ remember to export `VST_SDK_DIR` to the path of your `vstsdk2.4/` * ease up on the preprocessor ifs * polish parameter support * make code style consistent +* perhaps LV2 or AU support diff --git a/include/util.h b/include/util.h index bee8efc..8ec4f57 100644 --- a/include/util.h +++ b/include/util.h @@ -2,11 +2,6 @@ #ifdef __SSE2__ #include -#ifndef __SSE2_MATH__ -#warning SSE2 enabled but not forced, beware denormals -#endif -#else -#warning built without SSE2, denormals will be painful #endif static void diff --git a/util/sse_test.h b/util/sse_test.h new file mode 100644 index 0000000..555f0cb --- /dev/null +++ b/util/sse_test.h @@ -0,0 +1,7 @@ +#ifdef __SSE2__ +#ifndef __SSE2_MATH__ +#warning SSE2 enabled but not forced, beware denormals +#endif +#else +#warning built without SSE2, denormals will be painful +#endif