Add importer support in plugins
This commit is contained in:
parent
625cf2a93b
commit
37b5c3b1bc
3 changed files with 42 additions and 3 deletions
|
|
@ -1069,6 +1069,15 @@ void Editor::Impl::chooseSfzFile()
|
|||
fs->setTitle("Load SFZ file");
|
||||
fs->setDefaultExtension(CFileExtension("SFZ", "sfz"));
|
||||
|
||||
// also add extensions of importable files
|
||||
fs->addFileExtension(CFileExtension("WAV", "wav"));
|
||||
fs->addFileExtension(CFileExtension("FLAC", "flac"));
|
||||
fs->addFileExtension(CFileExtension("OGG", "ogg"));
|
||||
fs->addFileExtension(CFileExtension("MP3", "mp3"));
|
||||
fs->addFileExtension(CFileExtension("AIF", "aif"));
|
||||
fs->addFileExtension(CFileExtension("AIFF", "aiff"));
|
||||
fs->addFileExtension(CFileExtension("AIFC", "aifc"));
|
||||
|
||||
std::string initialDir = getFileChooserInitialDir(currentSfzFile_);
|
||||
if (!initialDir.empty())
|
||||
fs->setInitialDirectory(initialDir.c_str());
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
#include "sfizz_lv2.h"
|
||||
|
||||
#include "plugin/ForeignInstrument.h"
|
||||
|
||||
#include <lv2/atom/atom.h>
|
||||
#include <lv2/atom/forge.h>
|
||||
#include <lv2/atom/util.h>
|
||||
|
|
@ -1173,6 +1175,8 @@ sfizz_lv2_update_file_info(sfizz_plugin_t* self, const char *file_path)
|
|||
static bool
|
||||
sfizz_lv2_load_file(sfizz_plugin_t *self, const char *file_path)
|
||||
{
|
||||
bool status;
|
||||
|
||||
char buf[MAX_PATH_SIZE];
|
||||
if (file_path[0] == '\0')
|
||||
{
|
||||
|
|
@ -1180,7 +1184,22 @@ sfizz_lv2_load_file(sfizz_plugin_t *self, const char *file_path)
|
|||
file_path = buf;
|
||||
}
|
||||
|
||||
bool status = sfizz_load_file(self->synth, file_path);
|
||||
// bool status = sfizz_load_file(self->synth, file_path);
|
||||
|
||||
///
|
||||
const sfz::InstrumentFormatRegistry& formatRegistry = sfz::InstrumentFormatRegistry::getInstance();
|
||||
const sfz::InstrumentFormat* format = formatRegistry.getMatchingFormat(file_path);
|
||||
|
||||
if (!format)
|
||||
status = sfizz_load_file(self->synth, file_path);
|
||||
else {
|
||||
auto importer = format->createImporter();
|
||||
std::string virtual_path = std::string(file_path) + ".sfz";
|
||||
std::string sfz_text = importer->convertToSfz(file_path);
|
||||
status = sfizz_load_string(self->synth, virtual_path.c_str(), sfz_text.c_str());
|
||||
}
|
||||
|
||||
///
|
||||
sfizz_lv2_update_file_info(self, file_path);
|
||||
return status;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "SfizzVstState.h"
|
||||
#include "SfizzVstParameters.h"
|
||||
#include "SfizzFileScan.h"
|
||||
#include "plugin/ForeignInstrument.h"
|
||||
#include "base/source/fstreamer.h"
|
||||
#include "pluginterfaces/vst/ivstevents.h"
|
||||
#include "pluginterfaces/vst/ivstparameterchanges.h"
|
||||
|
|
@ -621,8 +622,18 @@ void SfizzVstProcessor::receiveMessage(int delay, const char* path, const char*
|
|||
|
||||
void SfizzVstProcessor::loadSfzFileOrDefault(sfz::Sfizz& synth, const std::string& filePath)
|
||||
{
|
||||
if (!filePath.empty())
|
||||
synth.loadSfzFile(filePath);
|
||||
if (!filePath.empty()) {
|
||||
const sfz::InstrumentFormatRegistry& formatRegistry = sfz::InstrumentFormatRegistry::getInstance();
|
||||
const sfz::InstrumentFormat* format = formatRegistry.getMatchingFormat(filePath);
|
||||
if (!format)
|
||||
synth.loadSfzFile(filePath);
|
||||
else {
|
||||
auto importer = format->createImporter();
|
||||
std::string virtualPath = filePath + ".sfz";
|
||||
std::string sfzText = importer->convertToSfz(filePath);
|
||||
synth.loadSfzString(virtualPath, sfzText);
|
||||
}
|
||||
}
|
||||
else
|
||||
synth.loadSfzString("default.sfz", defaultSfzText);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue