From b89bc24a9871c4ba746b556a52e1b1bbe74d7f4e Mon Sep 17 00:00:00 2001 From: redtide Date: Sun, 22 Sep 2019 01:20:53 +0200 Subject: [PATCH 1/2] Fix Travis OSX build (libsndfile). --- .travis/before_install.sh | 2 +- CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis/before_install.sh b/.travis/before_install.sh index 349edbfc..248954a6 100755 --- a/.travis/before_install.sh +++ b/.travis/before_install.sh @@ -10,5 +10,5 @@ elif [ "$TRAVIS_OS_NAME" = "osx" ]; then sudo ln -s /usr/local /opt/local brew update brew upgrade cmake - brew install jack libsndfile + brew install jack fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 95862d44..c42efe4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,10 @@ if (WIN32) set_target_properties(sndfile PROPERTIES LINKER_LANGUAGE CXX) file(COPY "${WIN_SNDFILE_PATH}/bin/libsndfile-1.dll" DESTINATION ${CMAKE_BINARY_DIR}) target_include_directories(sndfile INTERFACE "${WIN_SNDFILE_PATH}/include") +elseif (APPLE) + add_library(sndfile STATIC IMPORTED) + set_target_properties(sndfile PROPERTIES LINKER_LANGUAGE CXX) + target_include_directories(sndfile INTERFACE "usr/local/include") endif() add_subdirectory(sfizz) From f3348aa112423138644bc57642235bdeb9d2fcc9 Mon Sep 17 00:00:00 2001 From: paulfd Date: Sun, 22 Sep 2019 02:11:22 +0200 Subject: [PATCH 2/2] Added a script to change the sample names in an existing file that assumes case-insensitivity. --- scripts/sfz_sample_checks.py | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 scripts/sfz_sample_checks.py diff --git a/scripts/sfz_sample_checks.py b/scripts/sfz_sample_checks.py new file mode 100755 index 00000000..359b6266 --- /dev/null +++ b/scripts/sfz_sample_checks.py @@ -0,0 +1,72 @@ +#!/usr/bin/python3 +import re +import os +import argparse + +rex = r"sample=([a-zA-Z0-9-_#.&\/\s\\\(\),\*]+?)\s*(?=[a-zA-Z0-9_]*=|//.*|$|<[a-z]+>)" + + +parser = argparse.ArgumentParser(description="Simple script to update the sample names in an existing SFZ files") +parser.add_argument('file', type=str, help="SFZ input file") +parser.add_argument('--output', type=str, help="Output file name; if not specified, _corrected will be appended to the input") +parser.add_argument('--test', action='store_true', help="Test run") +args = parser.parse_args() + +assert os.path.exists(args.file), "File does not exists" + +root_directory = os.path.dirname(args.file) + '/' + +def case_insensitive_check(filename): + elements = filename.split('/') + path = '' + for e in elements: + if path != '': + path += '/' + found = False + + if os.path.exists(root_directory + path + e): + path += e + continue + + for dir_entry in os.listdir(root_directory + path): + if dir_entry.lower() == e.lower(): + path += dir_entry + found = True + + if found == False: + return None + + return path + +with open(args.file, 'r') as file: + content = file.read() + +output_content = content +replacements = 0 +for match in re.findall(rex, content): + if not os.path.exists(root_directory + match): + possible = case_insensitive_check(match) + if possible is not None: + print("{} -> {}".format(match, possible)) + replacements += 1 + output_content = re.sub(match, possible, output_content) + else: + print("{} -> ????".format(match)) + +if args.test: + exit(0) + +if replacements == 0: + print("All samples seem to exist, not writing a file...") + exit(0) + +if args.output is None: + output_file, ext = os.path.splitext(args.file) + output_file += '_corrected' + output_file += ext +else: + output_file = args.output + +print("Writing corrected file to", output_file) +with open(output_file, 'w') as file: + file.write(output_content) \ No newline at end of file