diff --git a/src/sfizz.h b/src/sfizz.h index 7b2a0c66..68c9a9e7 100644 --- a/src/sfizz.h +++ b/src/sfizz.h @@ -361,6 +361,21 @@ SFIZZ_EXPORTED_API char* sfizz_get_unknown_opcodes(sfizz_synth_t* synth); */ SFIZZ_EXPORTED_API bool sfizz_should_reload_file(sfizz_synth_t* synth); +/** + * @brief Enable logging of timings to sidecar CSV files. This can produce + * many outputs so use with caution. + * + * @param synth + */ +SFIZZ_EXPORTED_API void sfizz_enable_logging(sfizz_synth_t* synth); + +/** + * @brief Disable logging + * + * @param synth + */ +SFIZZ_EXPORTED_API void sfizz_disable_logging(sfizz_synth_t* synth); + #ifdef __cplusplus } #endif diff --git a/src/sfizz.hpp b/src/sfizz.hpp index 5437d6a8..e7f0f63d 100644 --- a/src/sfizz.hpp +++ b/src/sfizz.hpp @@ -248,6 +248,17 @@ public: * @return false */ bool shouldReloadFile(); + /** + * @brief Enable logging of timings to sidecar CSV files. This can produce + * many outputs so use with caution. + * + */ + void enableLogging() noexcept; + /** + * @brief Disable logging; + * + */ + void disableLogging() noexcept; private: std::unique_ptr synth; }; diff --git a/src/sfizz/Logger.cpp b/src/sfizz/Logger.cpp index b6a11135..5ecb4f3b 100644 --- a/src/sfizz/Logger.cpp +++ b/src/sfizz/Logger.cpp @@ -65,7 +65,7 @@ sfz::Logger::~Logger() << prefix << "_file_log.csv"; fs::path fileLogPath{ fs::current_path() / fileLogFilename.str() }; - DBG("Logging file times to " << fileLogPath.filename()); + std::cout << "Logging file times to " << fileLogPath.filename() << '\n'; std::ofstream loadLogFile { fileLogPath.native() }; loadLogFile << "WaitDuration,LoadDuration,FileSize,FileName" << '\n'; for (auto& time: fileTimes) @@ -81,7 +81,7 @@ sfz::Logger::~Logger() << prefix << "_callback_log.csv"; fs::path callbackLogPath{ fs::current_path() / callbackLogFilename.str() }; - DBG("Logging callback times to " << callbackLogPath.filename()); + std::cout << "Logging callback times to " << callbackLogPath.filename() << '\n'; std::ofstream callbackLogFile { callbackLogPath.native() }; callbackLogFile << "Dispatch,RenderMethod,Data,Amplitude,Filters,Panning,NumVoices,NumSamples" << '\n'; for (auto& time: callbackTimes) diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index c2ddb75e..63ef098f 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -822,3 +822,13 @@ bool sfz::Synth::shouldReloadFile() { return (checkModificationTime() > modificationTime); } + +void sfz::Synth::enableLogging() noexcept +{ + resources.logger.enableLogging(); +} + +void sfz::Synth::disableLogging() noexcept +{ + resources.logger.disableLogging(); +} diff --git a/src/sfizz/Synth.h b/src/sfizz/Synth.h index e0569aeb..f2c6fd11 100644 --- a/src/sfizz/Synth.h +++ b/src/sfizz/Synth.h @@ -340,6 +340,17 @@ public: * @return false */ bool shouldReloadFile(); + /** + * @brief Enable logging of timings to sidecar CSV files. This can produce + * many outputs so use with caution. + * + */ + void enableLogging() noexcept; + /** + * @brief Disable logging; + * + */ + void disableLogging() noexcept; protected: /** * @brief The parser callback; this is called by the parent object each time diff --git a/src/sfizz/sfizz.cpp b/src/sfizz/sfizz.cpp index bf98af37..9115f318 100644 --- a/src/sfizz/sfizz.cpp +++ b/src/sfizz/sfizz.cpp @@ -184,3 +184,13 @@ bool sfz::Sfizz::shouldReloadFile() { return synth->shouldReloadFile(); } + +void sfz::Sfizz::enableLogging() noexcept +{ + synth->enableLogging(); +} + +void sfz::Sfizz::disableLogging() noexcept +{ + synth->disableLogging(); +} diff --git a/src/sfizz/sfizz_wrapper.cpp b/src/sfizz/sfizz_wrapper.cpp index 8a29c1e8..7168e510 100644 --- a/src/sfizz/sfizz_wrapper.cpp +++ b/src/sfizz/sfizz_wrapper.cpp @@ -232,6 +232,17 @@ bool sfizz_should_reload_file(sfizz_synth_t* synth) return self->shouldReloadFile(); } +void sfizz_enable_logging(sfizz_synth_t* synth) +{ + auto self = reinterpret_cast(synth); + return self->enableLogging(); +} +void sfizz_disable_logging(sfizz_synth_t* synth) +{ + auto self = reinterpret_cast(synth); + return self->disableLogging(); +} + #ifdef __cplusplus } #endif