diff --git a/Makefile b/Makefile index db3d1c6..fd5e209 100644 --- a/Makefile +++ b/Makefile @@ -255,7 +255,13 @@ endif ifeq ($(FAUST), 1) SOURCES += src/FaustEngine.cpp FLAGS += -I/use/local/include + +# Using LLVM LDFLAGS += -L/usr/local/lib -lfaust + +# Test using MIR +#LDFLAGS += -L/usr/local/lib -lfaust dep/lib/mir-gen.o dep/lib/mir.o + DEPS += $(faust) OBJECTS += $(faust) DISTRIBUTABLES += faust_libraries diff --git a/src/FaustEngine.cpp b/src/FaustEngine.cpp index 504e3ac..ef37f1e 100644 --- a/src/FaustEngine.cpp +++ b/src/FaustEngine.cpp @@ -23,7 +23,6 @@ #include "ScriptEngine.hpp" -#include #include #include #include @@ -35,6 +34,14 @@ using namespace std; #define kBufferSize 64 +//#define MIR + +#ifdef MIR +#include +#else +#include +#endif + extern rack::Plugin* pluginInstance; // UI handler for switches, knobs and lights @@ -205,7 +212,11 @@ class FaustEngine : public ScriptEngine { delete [] fInputs; delete [] fOutputs; delete fDSP; - deleteDSPFactory(fDSPFactory); + #ifdef MIR + deleteInterpreterDSPFactory(static_cast(fDSPFactory)); + #else + deleteDSPFactory(static_cast(fDSPFactory)); + #endif } string getEngineName() override @@ -227,7 +238,11 @@ class FaustEngine : public ScriptEngine { string error_msg; // Try to load the machine code cache + #ifdef MIR + fDSPFactory = readInterpreterDSPFactoryFromBitcodeFile(temp_cache, error_msg); + #else fDSPFactory = readDSPFactoryFromMachineFile(temp_cache, "", error_msg); + #endif if (!fDSPFactory) { // Otherwise recompile the DSP @@ -237,7 +252,11 @@ class FaustEngine : public ScriptEngine { argv[argc++] = fDSPLibraries.c_str(); argv[argc] = nullptr; // NULL terminated argv + #ifdef MIR + fDSPFactory = createInterpreterDSPFactoryFromString("FaustDSP", script, argc, argv, error_msg); + #else fDSPFactory = createDSPFactoryFromString("FaustDSP", script, argc, argv, "", error_msg, -1); + #endif if (!fDSPFactory) { display("ERROR : cannot create factory !"); WARN("Faust Prototype : %s", error_msg.c_str()); @@ -245,7 +264,11 @@ class FaustEngine : public ScriptEngine { } else { // And save the cache display("Compiling factory finished"); - writeDSPFactoryToMachineFile(fDSPFactory, temp_cache, ""); + #ifdef MIR + writeInterpreterDSPFactoryToBitcodeFile(static_cast(fDSPFactory), temp_cache); + #else + writeDSPFactoryToMachineFile(static_cast(fDSPFactory), temp_cache, ""); + #endif } } @@ -315,8 +338,8 @@ class FaustEngine : public ScriptEngine { } private: - llvm_dsp_factory* fDSPFactory; - llvm_dsp* fDSP; + dsp_factory* fDSPFactory; + dsp* fDSP; FAUSTFLOAT** fInputs; FAUSTFLOAT** fOutputs; RackUI fRackUI;