Merge pull request #715 from jpcima/importers-library
Importers library
This commit is contained in:
commit
158b324ca6
12 changed files with 73 additions and 11 deletions
|
|
@ -11,5 +11,8 @@ endif()
|
|||
add_executable(sfizz_preprocessor Preprocessor.cpp)
|
||||
target_link_libraries(sfizz_preprocessor PRIVATE sfizz::parser sfizz::pugixml sfizz::cxxopts)
|
||||
|
||||
add_executable(sfizz_importer Importer.cpp)
|
||||
target_link_libraries(sfizz_importer PRIVATE sfizz::import)
|
||||
|
||||
add_executable(sfizz_hiir_designer HIIRDesigner.cpp)
|
||||
target_link_libraries(sfizz_hiir_designer PRIVATE sfizz::hiir_polyphase_iir2designer)
|
||||
|
|
|
|||
39
devtools/Importer.cpp
Normal file
39
devtools/Importer.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include "sfizz/import/ForeignInstrument.h"
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const sfz::InstrumentFormatRegistry& formatRegistry = sfz::InstrumentFormatRegistry::getInstance();
|
||||
|
||||
if (argc != 2) {
|
||||
std::cerr << "Usage: sfizz_importer <foreign-instrument>\n";
|
||||
std::cerr << "--\n" "Supported formats:\n";
|
||||
for (const sfz::InstrumentFormat* format : formatRegistry.getAllFormats())
|
||||
std::cerr << " * " << format->name() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
const fs::path foreignPath = fs::u8path(argv[1]);
|
||||
|
||||
const sfz::InstrumentFormat* format = formatRegistry.getMatchingFormat(foreignPath);
|
||||
|
||||
if (!format) {
|
||||
std::cerr << "There is no support for files of this format.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto importer = format->createImporter();
|
||||
std::string text = importer->convertToSfz(foreignPath);
|
||||
|
||||
if (text.empty()) {
|
||||
std::cerr << "The conversion has failed.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << text;
|
||||
if (text.back() != '\n')
|
||||
std::cout << '\n';
|
||||
std::cout << std::flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,15 +1,10 @@
|
|||
add_library(plugins-common STATIC EXCLUDE_FROM_ALL
|
||||
"common/plugin/MessageUtils.h"
|
||||
"common/plugin/MessageUtils.cpp"
|
||||
"common/plugin/ForeignInstrument.h"
|
||||
"common/plugin/ForeignInstrument.cpp"
|
||||
"common/plugin/foreign_instruments/AudioFile.h"
|
||||
"common/plugin/foreign_instruments/AudioFile.cpp")
|
||||
"common/plugin/MessageUtils.cpp")
|
||||
target_include_directories(plugins-common PUBLIC "common")
|
||||
target_link_libraries(plugins-common
|
||||
PUBLIC sfizz::spin_mutex
|
||||
PUBLIC sfizz::filesystem absl::strings
|
||||
PRIVATE sfizz::pugixml absl::memory)
|
||||
PUBLIC sfizz::filesystem absl::strings)
|
||||
add_library(sfizz::plugins-common ALIAS plugins-common)
|
||||
|
||||
if((SFIZZ_LV2 AND SFIZZ_LV2_UI) OR SFIZZ_VST)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ source_group("Turtle Files" FILES
|
|||
add_library(${LV2PLUGIN_PRJ_NAME} MODULE
|
||||
${PROJECT_NAME}.cpp
|
||||
${LV2PLUGIN_TTL_SRC_FILES})
|
||||
target_link_libraries(${LV2PLUGIN_PRJ_NAME} PRIVATE sfizz::sfizz sfizz::plugins-common)
|
||||
target_link_libraries(${LV2PLUGIN_PRJ_NAME} PRIVATE sfizz::sfizz sfizz::import sfizz::plugins-common)
|
||||
|
||||
if(SFIZZ_LV2_UI)
|
||||
add_library(${LV2PLUGIN_PRJ_NAME}_ui MODULE
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "sfizz_lv2.h"
|
||||
|
||||
#include "plugin/ForeignInstrument.h"
|
||||
#include "sfizz/import/ForeignInstrument.h"
|
||||
|
||||
#include <lv2/atom/atom.h>
|
||||
#include <lv2/atom/forge.h>
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ if(WIN32)
|
|||
endif()
|
||||
target_link_libraries(${VSTPLUGIN_PRJ_NAME}
|
||||
PRIVATE sfizz::sfizz
|
||||
PRIVATE sfizz::import
|
||||
PRIVATE sfizz::editor
|
||||
PRIVATE sfizz::plugins-common
|
||||
PRIVATE sfizz::pugixml sfizz::filesystem)
|
||||
|
|
@ -200,7 +201,8 @@ elseif(SFIZZ_AU)
|
|||
"${APPLE_COREMIDI_LIBRARY}")
|
||||
|
||||
target_link_libraries(${AUPLUGIN_PRJ_NAME}
|
||||
PRIVATE ${PROJECT_NAME}::${PROJECT_NAME}
|
||||
PRIVATE sfizz::sfizz
|
||||
PRIVATE sfizz::import
|
||||
PRIVATE sfizz::editor
|
||||
PRIVATE sfizz::plugins-common
|
||||
PRIVATE sfizz::pugixml sfizz::filesystem)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "SfizzVstState.h"
|
||||
#include "SfizzVstParameters.h"
|
||||
#include "SfizzFileScan.h"
|
||||
#include "plugin/ForeignInstrument.h"
|
||||
#include "sfizz/import/ForeignInstrument.h"
|
||||
#include "base/source/fstreamer.h"
|
||||
#include "pluginterfaces/vst/ivstevents.h"
|
||||
#include "pluginterfaces/vst/ivstparameterchanges.h"
|
||||
|
|
|
|||
|
|
@ -242,6 +242,24 @@ if(SFIZZ_RELEASE_ASSERTS)
|
|||
target_compile_definitions(sfizz_messaging PUBLIC "SFIZZ_ENABLE_RELEASE_ASSERT=1")
|
||||
endif()
|
||||
|
||||
# Import library
|
||||
set(SFIZZ_IMPORT_HEADERS
|
||||
sfizz/import/ForeignInstrument.h
|
||||
sfizz/import/foreign_instruments/AudioFile.h)
|
||||
|
||||
set(SFIZZ_IMPORT_SOURCES
|
||||
sfizz/import/ForeignInstrument.cpp
|
||||
sfizz/import/foreign_instruments/AudioFile.cpp)
|
||||
|
||||
add_library(sfizz_import STATIC)
|
||||
add_library(sfizz::import ALIAS sfizz_import)
|
||||
target_sources(sfizz_import PRIVATE
|
||||
${SFIZZ_IMPORT_HEADERS} ${SFIZZ_IMPORT_SOURCES})
|
||||
target_include_directories(sfizz_import PUBLIC ".")
|
||||
target_link_libraries(sfizz_import
|
||||
PUBLIC absl::strings absl::memory sfizz::filesystem
|
||||
PRIVATE sfizz::pugixml)
|
||||
|
||||
# Sfizz spinlock mutex
|
||||
add_library(sfizz_spin_mutex STATIC
|
||||
sfizz/utility/spin_mutex/spin_mutex.h
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ public:
|
|||
*/
|
||||
const InstrumentFormat* getMatchingFormat(const fs::path& path) const;
|
||||
|
||||
/**
|
||||
* @brief Get the list of registered formats.
|
||||
*/
|
||||
const std::vector<const InstrumentFormat*>& getAllFormats() const noexcept { return formats_; }
|
||||
|
||||
private:
|
||||
std::vector<const InstrumentFormat*> formats_;
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue