lv2: default files for sfz and scala
This commit is contained in:
parent
2f173f7209
commit
b23071e5ac
4 changed files with 58 additions and 17 deletions
|
|
@ -43,6 +43,17 @@ if (SFIZZ_USE_VCPKG OR SFIZZ_STATIC_LIBSNDFILE OR CMAKE_CXX_COMPILER_ID MATCHES
|
|||
file(COPY "lgpl-3.0.txt" DESTINATION ${PROJECT_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
# Copy resource files into the bundle
|
||||
set(LV2_RESOURCES
|
||||
DefaultInstrument.sfz
|
||||
DefaultScale.scl)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${PROJECT_BINARY_DIR}/Resources")
|
||||
foreach(res ${LV2_RESOURCES})
|
||||
file (COPY "${CMAKE_CURRENT_SOURCE_DIR}/resources/${res}"
|
||||
DESTINATION "${PROJECT_BINARY_DIR}/Resources")
|
||||
endforeach()
|
||||
|
||||
# Installation
|
||||
if (NOT MSVC)
|
||||
install (DIRECTORY ${PROJECT_BINARY_DIR} DESTINATION ${LV2PLUGIN_INSTALL_DIR}
|
||||
|
|
|
|||
3
lv2/resources/DefaultInstrument.sfz
Normal file
3
lv2/resources/DefaultInstrument.sfz
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<region>
|
||||
sample=*sine
|
||||
ampeg_attack=0.02 ampeg_release=0.1
|
||||
14
lv2/resources/DefaultScale.scl
Normal file
14
lv2/resources/DefaultScale.scl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Equal temperament
|
||||
12
|
||||
100.0
|
||||
200.0
|
||||
300.0
|
||||
400.0
|
||||
500.0
|
||||
600.0
|
||||
700.0
|
||||
800.0
|
||||
900.0
|
||||
1000.0
|
||||
1100.0
|
||||
1200.0
|
||||
47
lv2/sfizz.c
47
lv2/sfizz.c
|
|
@ -88,12 +88,11 @@
|
|||
#define LV2_DEBUG(...)
|
||||
#endif
|
||||
|
||||
static const char default_sfz_text[] =
|
||||
"<region>sample=*sine" "\n"
|
||||
"ampeg_attack=0.02 ampeg_release=0.1" "\n";
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Paths
|
||||
const char *bundle_path;
|
||||
|
||||
// Features
|
||||
LV2_URID_Map *map;
|
||||
LV2_URID_Unmap *unmap;
|
||||
|
|
@ -299,14 +298,27 @@ sfizz_lv2_parse_sample_rate(sfizz_plugin_t* self, const LV2_Options_Option* opt)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sfizz_lv2_get_default_sfz_path(LV2_Handle instance, char *path, size_t size)
|
||||
{
|
||||
sfizz_plugin_t *self = (sfizz_plugin_t *)instance;
|
||||
snprintf(path, size, "%s/%s", self->bundle_path, "Resources/DefaultInstrument.sfz");
|
||||
}
|
||||
|
||||
static void
|
||||
sfizz_lv2_get_default_scala_path(LV2_Handle instance, char *path, size_t size)
|
||||
{
|
||||
sfizz_plugin_t *self = (sfizz_plugin_t *)instance;
|
||||
snprintf(path, size, "%s/%s", self->bundle_path, "Resources/DefaultScale.scl");
|
||||
}
|
||||
|
||||
static LV2_Handle
|
||||
instantiate(const LV2_Descriptor *descriptor,
|
||||
double rate,
|
||||
const char *path,
|
||||
const char *bundle_path,
|
||||
const LV2_Feature *const *features)
|
||||
{
|
||||
UNUSED(descriptor);
|
||||
UNUSED(path);
|
||||
LV2_Options_Option *options = NULL;
|
||||
bool supports_bounded_block_size = false;
|
||||
bool options_has_block_size = false;
|
||||
|
|
@ -317,6 +329,10 @@ instantiate(const LV2_Descriptor *descriptor,
|
|||
if (!self)
|
||||
return NULL;
|
||||
|
||||
LV2_Handle instance = (LV2_Handle)self;
|
||||
|
||||
self->bundle_path = bundle_path;
|
||||
|
||||
// Set defaults
|
||||
self->max_block_size = MAX_BLOCK_SIZE;
|
||||
self->sample_rate = (float)rate;
|
||||
|
|
@ -434,7 +450,12 @@ instantiate(const LV2_Descriptor *descriptor,
|
|||
}
|
||||
|
||||
self->synth = sfizz_create_synth();
|
||||
sfizz_load_string(self->synth, "default.sfz", default_sfz_text);
|
||||
|
||||
sfizz_lv2_get_default_sfz_path(instance, self->sfz_file_path, MAX_PATH_SIZE);
|
||||
sfizz_lv2_get_default_scala_path(instance, self->scala_file_path, MAX_PATH_SIZE);
|
||||
|
||||
sfizz_load_file(self->synth, self->sfz_file_path);
|
||||
sfizz_load_scala_file(self->synth, self->scala_file_path);
|
||||
|
||||
return (LV2_Handle)self;
|
||||
}
|
||||
|
|
@ -902,16 +923,8 @@ sfizz_lv2_load_file(LV2_Handle instance, const char *file_path)
|
|||
{
|
||||
sfizz_plugin_t *self = (sfizz_plugin_t *)instance;
|
||||
|
||||
if (file_path[0] == '\0')
|
||||
{
|
||||
if (!sfizz_load_string(self->synth, "default.sfz", default_sfz_text))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sfizz_load_file(self->synth, file_path))
|
||||
return false;
|
||||
}
|
||||
if (!sfizz_load_file(self->synth, file_path))
|
||||
return false;
|
||||
|
||||
sfizz_lv2_update_file_info(self, file_path);
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue