From 34d6ed02918620ad4437bfcd12f4e4b6d0c7c1cc Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Sun, 9 Aug 2020 23:45:19 +0200 Subject: [PATCH] Add the program to display file wavetable info --- tests/CMakeLists.txt | 3 +++ tests/FileWavetable.cpp | 52 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tests/FileWavetable.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 31e134c8..08623b6d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -93,6 +93,9 @@ target_link_libraries(sfizz_plot_wavetables PRIVATE sfizz::sfizz) add_executable(sfizz_file_instrument FileInstrument.cpp) target_link_libraries(sfizz_file_instrument PRIVATE sfizz::sfizz) +add_executable(sfizz_file_wavetable FileWavetable.cpp) +target_link_libraries(sfizz_file_wavetable PRIVATE sfizz::sfizz) + add_executable(sfizz_tuning Tuning.cpp) target_link_libraries(sfizz_tuning PRIVATE sfizz::sfizz) diff --git a/tests/FileWavetable.cpp b/tests/FileWavetable.cpp new file mode 100644 index 00000000..9e1fa597 --- /dev/null +++ b/tests/FileWavetable.cpp @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#include "sfizz/FileMetadata.h" +#include "absl/strings/string_view.h" +#include + +static void printWavetable(const sfz::WavetableInfo& wt) +{ + printf("Table size: %u\n", wt.tableSize); + printf("Cross-table interpolation: %d\n", wt.crossTableInterpolation); + printf("One-shot: %d\n", wt.oneShot); +} + +static void usage(const char* argv0) +{ + fprintf( + stderr, + "Usage: %s \n", + argv0); +} + +int main(int argc, char *argv[]) +{ + fs::path path; + + if (argc == 2) + path = argv[1]; + else { + usage(argv[0]); + return 1; + } + + sfz::WavetableInfo wt {}; + + sfz::FileMetadataReader reader; + if (!reader.open(path)) { + fprintf(stderr, "Cannot open file\n"); + return 1; + } + if (!reader.extractWavetableInfo(wt)) { + fprintf(stderr, "Cannot get wavetable info\n"); + return 1; + } + + printWavetable(wt); + + return 0; +}