Browse Source

Add Interp/MIR backend support.

faust
Stephane Letz Andrew Belt 4 years ago
parent
commit
c14a5d3af6
2 changed files with 34 additions and 5 deletions
  1. +6
    -0
      Makefile
  2. +28
    -5
      src/FaustEngine.cpp

+ 6
- 0
Makefile View File

@@ -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


+ 28
- 5
src/FaustEngine.cpp View File

@@ -23,7 +23,6 @@

#include "ScriptEngine.hpp"

#include <faust/dsp/llvm-dsp.h>
#include <faust/dsp/libfaust.h>
#include <faust/gui/DecoratorUI.h>
#include <faust/gui/ValueConverter.h>
@@ -35,6 +34,14 @@ using namespace std;

#define kBufferSize 64

//#define MIR

#ifdef MIR
#include <faust/dsp/interpreter-dsp.h>
#else
#include <faust/dsp/llvm-dsp.h>
#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<interpreter_dsp_factory*>(fDSPFactory));
#else
deleteDSPFactory(static_cast<llvm_dsp_factory*>(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<interpreter_dsp_factory*>(fDSPFactory), temp_cache);
#else
writeDSPFactoryToMachineFile(static_cast<llvm_dsp_factory*>(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;


Loading…
Cancel
Save