Pass sfz loading percentage to log_function with Log::INFO loglevel
Closed this issue · 2 comments
As of v0.1.0, loading an sfz file yields loading percentage written to stdout. A graphical interface must then create a piped acces to stdout and read the percentage loading to display it in a graphical widget (see line 27 of liquidmainwindow.cpp of qliquidsfz). This is not very convenient. Moreover, in a command-line user interface, it is not convenient from the library to write to stdout because it can break the output of the command-line user interface.
Therefore, i propose for libliquidsfz to not write loading percentage to stdout, at least if a log fonction has been set with Synth::set_log_function()
to the Synth
object. And i propose loading percentage to be passed to the log function with a Log::INFO
level.
Another proposition is to add in the API a (for example) Synth::set_loadpercent_function()
with a handler being void (*fun) (int percent)
. With percent
being a regularly updated integer representing the current loading percentage. Then the application can display the status when loading an sfz file, wich is a long operation.
Comments welcomed, of course!
I totally agree with you that printf() is unacceptable for a library. I would also say that Log::INFO is a bad idea, because at the UI you probably want a progress bar widget. So you need to get a number from somewhere so you can update the progressbar (and parsing info messages sounds fragile). I've added a new set_progress_function() API now. Please verify that this is good enough for you, and if yes, close your issue. The commit is here:
Thank you for your response and the new set_progress_function()
. This works for me, like a charm. Closing the issue.