tests: test that vst3 instrument produces audio

This commit is contained in:
Alexandros Theodotou 2023-08-30 01:33:46 +09:00
parent b30c237fdb
commit d3e6cb112d
No known key found for this signature in database
GPG Key ID: 022EAE42313D70F3
5 changed files with 218 additions and 14 deletions

View File

@ -1506,6 +1506,13 @@ ext_vst_plugins = {
}
have_ext_vst_plugins = {}
ext_vst_plugin_paths = {}
ext_vst3_plugins = {
'onetrick_simian': 'Punk Labs LLC OneTrick SIMIAN.vst3',
'dexed': 'Dexed.vst3',
'surge_xt': 'Surge XT.vst3',
}
have_ext_vst3_plugins = {}
ext_vst3_plugin_paths = {}
# when using the lilv subproject, we can't use lv2ls and
# lv2info
lv2info_bin = find_program ('lv2info', required: false)
@ -1542,7 +1549,22 @@ if get_option ('tests') and lilv_dep.type_name () != 'internal'
if have_ext_vst
ext_vst_plugin_paths += {
name: run_command (
get_vst_path_bin, filename,
get_vst_path_bin, filename, '',
check: true).stdout ().strip ()
}
endif
endforeach
foreach name, filename : ext_vst3_plugins
have_ext_vst3 = run_command (
get_vst_path_bin,
filename).returncode () == 0
have_ext_vst3_plugins += {
name: have_ext_vst3
}
if have_ext_vst3
ext_vst3_plugin_paths += {
name: run_command (
get_vst_path_bin, filename, '3',
check: true).stdout ().strip ()
}
endif
@ -1642,6 +1664,11 @@ foreach name, filename : ext_vst_plugins
filename: ext_vst_plugin_paths.get(name, 'N/A')
}
endforeach
foreach name, filename : ext_vst3_plugins
tests_summary += {
filename: ext_vst3_plugin_paths.get(name, 'N/A')
}
endforeach
summary (tests_summary, section: 'Tests')
summary ({

View File

@ -79,8 +79,10 @@ test_plugin_manager_reload_lilv_world_w_path (
}
/**
* Get a plugin setting clone from the given
* URI in the given bundle.
* Get a plugin setting clone from the given URI in the given
* bundle.
*
* If non-LV2, the path should be passed to pl_bundle.
*/
PluginSetting *
test_plugin_manager_get_plugin_setting (
@ -88,10 +90,43 @@ test_plugin_manager_get_plugin_setting (
const char * pl_uri,
bool with_carla)
{
LilvNode * path = lilv_new_uri (LILV_WORLD, pl_bundle);
g_assert_nonnull (path);
lilv_world_load_bundle (LILV_WORLD, path);
lilv_node_free (path);
if (pl_uri)
{
LilvNode * path = lilv_new_uri (LILV_WORLD, pl_bundle);
g_assert_nonnull (path);
lilv_world_load_bundle (LILV_WORLD, path);
lilv_node_free (path);
}
else
{
char * basename = g_path_get_basename (pl_bundle);
char * tmpdir =
g_dir_make_tmp ("zrythm_vst_XXXXXX", NULL);
char * dest_path =
g_build_filename (tmpdir, basename, NULL);
if (g_str_has_suffix (pl_bundle, "vst3"))
{
g_assert_true (io_copy_dir (
dest_path, pl_bundle, true, true, NULL));
}
else
{
GFile * pl_bundle_file =
g_file_new_for_path (pl_bundle);
GFile * pl_bundle_file_in_tmp =
g_file_new_for_path (dest_path);
g_assert_true (g_file_copy (
pl_bundle_file, pl_bundle_file_in_tmp,
G_FILE_COPY_NONE, NULL, NULL, NULL, NULL));
//g_object_unref (pl_bundle_file);
//g_object_unref (pl_bundle_file_in_tmp);
}
g_setenv ("VST3_PATH", tmpdir, true);
g_setenv ("VST_PATH", tmpdir, true);
g_free (tmpdir);
g_free (dest_path);
g_free (basename);
}
plugin_manager_clear_plugins (PLUGIN_MANAGER);
plugin_manager_scan_plugins (PLUGIN_MANAGER, 1.0, NULL);
@ -104,9 +139,24 @@ test_plugin_manager_get_plugin_setting (
{
PluginDescriptor * cur_descr = g_ptr_array_index (
PLUGIN_MANAGER->plugin_descriptors, i);
if (string_is_equal (cur_descr->uri, pl_uri))
if (pl_uri)
{
descr = plugin_descriptor_clone (cur_descr);
if (string_is_equal (cur_descr->uri, pl_uri))
{
descr = plugin_descriptor_clone (cur_descr);
}
}
else if (cur_descr->protocol != PROT_LV2)
{
char * basename = g_path_get_basename (pl_bundle);
char * descr_basename =
g_path_get_basename (cur_descr->path);
if (string_is_equal (descr_basename, basename))
{
descr = plugin_descriptor_clone (cur_descr);
}
g_free (basename);
g_free (descr_basename);
}
}
g_return_val_if_fail (descr, NULL);

View File

@ -238,6 +238,32 @@ if get_option ('tests')
name.to_upper() + '_PATH', '')
endif
endforeach
# VST3
foreach name, filename : ext_vst3_plugins
have_plugin = have_ext_vst3_plugins.get (
name, false)
if have_plugin
path = ext_vst3_plugin_paths[name]
# C
test_config.set (
'HAVE_' + name.to_upper(), 1)
test_config.set_quoted (
name.to_upper() + '_PATH', path)
# Guile
test_config_guile.set (
'HAVE_' + name.to_upper(), '#t')
test_config_guile.set_quoted (
name.to_upper() + '_PATH', path)
else
# Guile
test_config_guile.set (
'HAVE_' + name.to_upper(), '#f')
test_config_guile.set_quoted (
name.to_upper() + '_PATH', '')
endif
endforeach
test_config_h = configure_file (
output: 'zrythm-test-config.h',
configuration: test_config,

View File

@ -14,6 +14,95 @@
#include "tests/helpers/plugin_manager.h"
#include "tests/helpers/zrythm.h"
static void
test_vst_instrument_makes_sound (void)
{
#ifdef HAVE_CARLA
for (int i = 0; i < 2; i++)
{
const char * pl_path = NULL;
# ifdef HAVE_NOIZEMAKER
if (i == 0)
{
/* vst2 */
pl_path = NOIZEMAKER_PATH;
}
# endif
# ifdef HAVE_SURGE_XT
if (i == 1)
{
/* vst3 */
pl_path = SURGE_XT_PATH;
}
# endif
if (!pl_path)
continue;
test_helper_zrythm_init ();
/* stop dummy audio engine processing so we can
* process manually */
test_project_stop_dummy_engine ();
/* create instrument track */
test_plugin_manager_create_tracks_from_plugin (
pl_path, NULL, true, true, 1);
Track * track =
TRACKLIST->tracks[TRACKLIST->num_tracks - 1];
/* create midi note */
Position pos, end_pos;
position_init (&pos);
position_set_to_bar (&end_pos, 3);
ZRegion * r = midi_region_new (
&pos, &end_pos, track_get_name_hash (track), 0, 0);
bool success = track_add_region (
track, r, NULL, 0, F_GEN_NAME, F_NO_PUBLISH_EVENTS,
NULL);
g_assert_true (success);
MidiNote * mn =
midi_note_new (&r->id, &pos, &end_pos, 57, 120);
midi_region_add_midi_note (r, mn, F_NO_PUBLISH_EVENTS);
engine_process (
AUDIO_ENGINE, AUDIO_ENGINE->block_length);
engine_process (
AUDIO_ENGINE, AUDIO_ENGINE->block_length);
engine_process (
AUDIO_ENGINE, AUDIO_ENGINE->block_length);
/* bounce */
ExportSettings * settings = export_settings_new ();
export_settings_set_bounce_defaults (
settings, EXPORT_FORMAT_WAV, NULL, __func__);
settings->time_range = TIME_RANGE_LOOP;
settings->bounce_with_parents = true;
settings->mode = EXPORT_MODE_FULL;
EngineState state;
GPtrArray * conns =
exporter_prepare_tracks_for_export (settings, &state);
/* start exporting in a new thread */
GThread * thread = g_thread_new (
"bounce_thread",
(GThreadFunc) exporter_generic_export_thread,
settings);
g_thread_join (thread);
exporter_post_export (settings, conns, &state);
g_assert_false (
audio_file_is_silent (settings->file_uri));
export_settings_free (settings);
test_helper_zrythm_cleanup ();
}
#endif
}
static void
test_mono_plugin (void)
{
@ -202,6 +291,9 @@ main (int argc, char * argv[])
#define TEST_PREFIX "/plugins/carla native plugin/"
g_test_add_func (
TEST_PREFIX "test vst instrument makes sound",
(GTestFunc) test_vst_instrument_makes_sound);
g_test_add_func (
TEST_PREFIX "test mono plugin",
(GTestFunc) test_mono_plugin);

View File

@ -1,17 +1,26 @@
#! /bin/sh
# SPDX-FileCopyrightText: © 2020 Alexandros Theodotou <alex@zrythm.org>
# SPDX-FileCopyrightText: © 2020, 2023 Alexandros Theodotou <alex@zrythm.org>
# SPDX-License-Identifier: LicenseRef-ZrythmLicense
#
# This is used during the tests to create a temporary
# lv2 plugin environment before calling lv2lint
# This program prints the absolute path of a given vst or
# vst3 plugin basename
set -e
plugin_filename=$1
version=$2
for i in $(echo $VST_PATH | sed "s/:/ /g"); do
vst_path_env_name="VST${version}_PATH"
vst_path="${!vst_path_env_name}"
if [ -z "$vst_path" ]; then
vst_path="/usr/lib/vst:/usr/lib/vst3"
fi
for i in $(echo "$vst_path" | sed "s/:/ /g"); do
full_path="$i/$plugin_filename"
if ls $full_path; then
if ls "$full_path" >/dev/null 2>&1; then
echo "$full_path";
exit 0
fi
done