| @@ -43,6 +43,9 @@ endif | |||
| ifeq ($(HAVE_AF_DEPS),true) | |||
| BUILD_CXX_FLAGS += -DWANT_AUDIOFILE | |||
| ifeq ($(HAVE_FFMPEG),true) | |||
| BUILD_CXX_FLAGS += -DHAVE_FFMPEG | |||
| endif | |||
| endif | |||
| ifeq ($(HAVE_MF_DEPS),true) | |||
| @@ -1143,8 +1143,127 @@ bool CarlaEngine::loadFilename(const char* const filename) | |||
| CARLA_ASSERT(filename != nullptr); | |||
| carla_debug("CarlaEngine::loadFilename(\"%s\")", filename); | |||
| // TODO | |||
| setLastError("Not implemented yet"); | |||
| QFileInfo fileInfo(filename); | |||
| if (! fileInfo.exists()) | |||
| { | |||
| setLastError("File does not exist"); | |||
| return false; | |||
| } | |||
| if (! fileInfo.isFile()) | |||
| { | |||
| setLastError("Not a file"); | |||
| return false; | |||
| } | |||
| if (! fileInfo.isReadable()) | |||
| { | |||
| setLastError("File is not readable"); | |||
| return false; | |||
| } | |||
| QString baseName(fileInfo.baseName()); | |||
| QString extension(fileInfo.suffix()); | |||
| const char* const baseNameStr(baseName.toUtf8().constData()); | |||
| // ------------------------------------------------------------------- | |||
| if (extension == "carxp" || extension == "carxs") | |||
| return loadProject(filename); | |||
| // ------------------------------------------------------------------- | |||
| if (extension == "gig") | |||
| return addPlugin(PLUGIN_GIG, filename, baseNameStr, nullptr); | |||
| if (extension == "sf2") | |||
| return addPlugin(PLUGIN_SF2, filename, baseNameStr, nullptr); | |||
| if (extension == "sfz") | |||
| return addPlugin(PLUGIN_SFZ, filename, baseNameStr, nullptr); | |||
| // ------------------------------------------------------------------- | |||
| if (extension == "aiff" || extension == "flac" || extension == "oga" || extension == "ogg" || extension == "w64" || extension == "wav") | |||
| { | |||
| #ifdef WANT_AUDIOFILE | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseNameStr, "audiofile")) | |||
| { | |||
| if (CarlaPlugin* const plugin = getPlugin(kData->curPluginCount-1)) | |||
| plugin->setCustomData(CUSTOM_DATA_STRING, "file00", filename, true); | |||
| return true; | |||
| } | |||
| return false; | |||
| #else | |||
| setLastError("This Carla build does not have Audio file support"); | |||
| return false; | |||
| #endif | |||
| } | |||
| if (extension == "3g2" || extension == "3gp" || extension == "aac" || extension == "ac3" || extension == "amr" || extension == "ape" || | |||
| extension == "mp2" || extension == "mp3" || extension == "mpc" || extension == "wma") | |||
| { | |||
| #ifdef WANT_AUDIOFILE | |||
| # ifdef HAVE_FFMPEG | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseNameStr, "audiofile")) | |||
| { | |||
| if (CarlaPlugin* const plugin = getPlugin(kData->curPluginCount-1)) | |||
| plugin->setCustomData(CUSTOM_DATA_STRING, "file00", filename, true); | |||
| return true; | |||
| } | |||
| return false; | |||
| # else | |||
| setLastError("This Carla build has Audio file support, but not libav/ffmpeg"); | |||
| return false; | |||
| # endif | |||
| #else | |||
| setLastError("This Carla build does not have Audio file support"); | |||
| return false; | |||
| #endif | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| if (extension == "mid" || extension == "midi") | |||
| { | |||
| #ifdef WANT_MIDIFILE | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseNameStr, "midifile")) | |||
| { | |||
| if (CarlaPlugin* const plugin = getPlugin(kData->curPluginCount-1)) | |||
| plugin->setCustomData(CUSTOM_DATA_STRING, "file", filename, true); | |||
| return true; | |||
| } | |||
| return false; | |||
| #else | |||
| setLastError("This Carla build does not have MIDI file support"); | |||
| return false; | |||
| #endif | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| // ZynAddSubFX | |||
| if (extension == "xmz" || extension == "xiz") | |||
| { | |||
| #ifdef WANT_ZYNADDSUBFX | |||
| if (addPlugin(PLUGIN_INTERNAL, nullptr, baseNameStr, "zynaddsubfx")) | |||
| { | |||
| if (CarlaPlugin* const plugin = getPlugin(kData->curPluginCount-1)) | |||
| plugin->setCustomData(CUSTOM_DATA_STRING, (extension == "xmz") ? "CarlaAlternateFile1" : "CarlaAlternateFile2", filename, true); | |||
| return true; | |||
| } | |||
| return false; | |||
| #else | |||
| setLastError("This Carla build does not have ZynAddSubFX support"); | |||
| return false; | |||
| #endif | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| setLastError("Unknown file extension"); | |||
| return false; | |||
| } | |||
| @@ -27,6 +27,7 @@ | |||
| #include <QtCore/QThread> | |||
| #include "zynaddsubfx/Misc/Master.h" | |||
| #include "zynaddsubfx/Misc/Part.h" | |||
| #include "zynaddsubfx/Misc/Util.h" | |||
| #ifdef WANT_ZYNADDSUBFX_UI | |||
| @@ -234,6 +235,17 @@ protected: | |||
| fThread.loadLater(bank, program); | |||
| } | |||
| void setCustomData(const char* const key, const char* const value) | |||
| { | |||
| CARLA_ASSERT(key != nullptr); | |||
| CARLA_ASSERT(value != nullptr); | |||
| if (std::strcmp(key, "CarlaAlternateFile1") == 0) // xmz | |||
| kMaster->loadXML(value); | |||
| if (std::strcmp(key, "CarlaAlternateFile2") == 0) // xiz | |||
| kMaster->part[0]->loadXMLinstrument(value); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| // Plugin process calls | |||
| @@ -1358,7 +1358,7 @@ void CarlaPlugin::setCustomData(const char* const type, const char* const key, c | |||
| if (std::strcmp(type, CUSTOM_DATA_STRING) == 0) | |||
| { | |||
| // Ignore some keys | |||
| if (std::strncmp(key, "OSC:", 4) == 0 || std::strcmp(key, "guiVisible") == 0) | |||
| if (std::strncmp(key, "OSC:", 4) == 0 || std::strncmp(key, "CarlaAlternateFile", 18) == 0 || std::strcmp(key, "guiVisible") == 0) | |||
| saveData = false; | |||
| //else if (std::strcmp(key, CARLA_BRIDGE_MSG_SAVE_NOW) == 0 || std::strcmp(key, CARLA_BRIDGE_MSG_SET_CHUNK) == 0 || std::strcmp(key, CARLA_BRIDGE_MSG_SET_CUSTOM) == 0) | |||
| // saveData = false; | |||
| @@ -32,7 +32,7 @@ | |||
| #endif | |||
| #if defined(NDEBUG) && ! defined(BUILD_BRIDGE) | |||
| # WANT_LOGS | |||
| # define WANT_LOGS | |||
| # include <fcntl.h> | |||
| # include <QtCore/QThread> | |||
| #endif | |||
| @@ -380,7 +380,7 @@ const char* carla_get_supported_file_types() | |||
| // Plugin presets | |||
| #ifdef WANT_ZYNADDSUBFX | |||
| retText += ";*.xmz"; | |||
| retText += ";*.xmz;*.xiz"; | |||
| #endif | |||
| } | |||
| @@ -10,10 +10,6 @@ include ../Makefile.mk | |||
| BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo) -I../../theme | |||
| ifeq ($(HAVE_FFMPEG),true) | |||
| BUILD_CXX_FLAGS += -DHAVE_FFMPEG | |||
| endif | |||
| ifeq ($(HAVE_QT5),true) | |||
| BUILD_CXX_FLAGS += $(shell pkg-config --cflags Qt5Core Qt5Widgets) | |||
| else | |||
| @@ -61,6 +61,7 @@ PKGCONFIG += fluidsynth | |||
| PKGCONFIG += linuxsampler | |||
| # AudioFile | |||
| DEFINES += HAVE_FFMPEG | |||
| PKGCONFIG += libavcodec libavformat libavutil sndfile | |||
| # MidiFile | |||
| @@ -859,79 +859,14 @@ class CarlaMainW(QMainWindow): | |||
| self.scene.render(painter) | |||
| self.fExportImage.save(newPath, imgFormat, 100) | |||
| def showLastError(self, isProject): | |||
| CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), | |||
| self.tr("Failed to load %s" % (self.tr("project") if isProject else self.tr("plugin"))), | |||
| cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok) | |||
| @pyqtSlot(QModelIndex) | |||
| def slot_fileTreeDoubleClicked(self, modelIndex): | |||
| filename = self.fDirModel.filePath(modelIndex) | |||
| print(filename) | |||
| if not os.path.exists(filename): | |||
| return | |||
| if not os.path.isfile(filename): | |||
| return | |||
| basename = os.path.basename(filename) | |||
| extension = filename.rsplit(".", 1)[-1].lower() | |||
| if extension in ("carxp", "carxs"): | |||
| if not Carla.host.load_project(filename): | |||
| self.showLastError(True) | |||
| elif extension == "gig": | |||
| if not Carla.host.add_plugin(BINARY_NATIVE, PLUGIN_GIG, filename, None, basename, None): | |||
| self.showLastError(False) | |||
| elif extension == "sf2": | |||
| if not Carla.host.add_plugin(BINARY_NATIVE, PLUGIN_SF2, filename, None, basename, None): | |||
| self.showLastError(False) | |||
| elif extension == "sfz": | |||
| if not Carla.host.add_plugin(BINARY_NATIVE, PLUGIN_SFZ, filename, None, basename, None): | |||
| self.showLastError(False) | |||
| elif extension in ("aac", "flac", "oga", "ogg", "mp3", "wav"): | |||
| # check if last plugin is audiofile | |||
| if self.fPluginCount > 0: | |||
| pluginId = self.fPluginCount-1 | |||
| pwidget = self.fPluginList[pluginId] | |||
| if pwidget is not None and pwidget.fPluginInfo["label"] == "audiofile": | |||
| Carla.host.set_custom_data(pluginId, CUSTOM_DATA_STRING, "file00", filename) | |||
| return | |||
| self.fLastLoadedPluginId = -2 | |||
| if Carla.host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, None, None, "audiofile", None): | |||
| while (self.fLastLoadedPluginId == -2): sleep(0.2) | |||
| idx = self.fLastLoadedPluginId | |||
| self.fLastLoadedPluginId = -1 | |||
| Carla.host.set_custom_data(idx, CUSTOM_DATA_STRING, "file00", filename) | |||
| else: | |||
| self.fLastLoadedPluginId = -1 | |||
| self.showLastError(False) | |||
| elif extension in ("mid", "midi"): | |||
| # check if last plugin is midifile | |||
| if self.fPluginCount > 0: | |||
| pluginId = self.fPluginCount-1 | |||
| pwidget = self.fPluginList[pluginId] | |||
| if pwidget is not None and pwidget.fPluginInfo["label"] == "midifile": | |||
| Carla.host.set_custom_data(pluginId, CUSTOM_DATA_STRING, "file", filename) | |||
| return | |||
| self.fLastLoadedPluginId = -2 | |||
| if Carla.host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, None, None, "midifile", None): | |||
| while (self.fLastLoadedPluginId == -2): sleep(0.2) | |||
| idx = self.fLastLoadedPluginId | |||
| self.fLastLoadedPluginId = -1 | |||
| Carla.host.set_custom_data(idx, CUSTOM_DATA_STRING, "file", filename) | |||
| else: | |||
| self.fLastLoadedPluginId = -1 | |||
| self.showLastError(False) | |||
| if not Carla.host.load_filename(filename): | |||
| CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), | |||
| self.tr("Failed to load file"), | |||
| cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok) | |||
| @pyqtSlot(float) | |||
| def slot_canvasScaleChanged(self, scale): | |||