Added API functions to activate logging

This commit is contained in:
Paul Fd 2020-02-18 16:16:24 +01:00
parent 1461680e20
commit 1bb373cfa0
7 changed files with 70 additions and 2 deletions

View file

@ -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

View file

@ -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<sfz::Synth> synth;
};

View file

@ -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)

View file

@ -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();
}

View file

@ -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

View file

@ -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();
}

View file

@ -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<sfz::Synth*>(synth);
return self->enableLogging();
}
void sfizz_disable_logging(sfizz_synth_t* synth)
{
auto self = reinterpret_cast<sfz::Synth*>(synth);
return self->disableLogging();
}
#ifdef __cplusplus
}
#endif