Permalink
Browse files

o Remember the max output value in the stats

  to be displayed on the web server. Could be used to display something
  like Max -17dB or so. Also, makes clipping remembering easier :)
  • Loading branch information...
1 parent fb3fb9a commit a5c63829f8cf39e28248fbd7e5489e69c567a0f5 @hzeller committed Sep 21, 2012
Showing with 19 additions and 12 deletions.
  1. +2 −1 file-handler.h
  2. +17 −11 folve-filesystem.cc
View
@@ -23,7 +23,7 @@
struct HandlerStats {
HandlerStats()
: duration_seconds(-1), progress(-1), status(OPEN), last_access(0),
- in_gapless(false), out_gapless(false) {}
+ max_output_value(0), in_gapless(false), out_gapless(false) {}
std::string filename; // filesystem name.
std::string format; // File format info if recognized.
std::string message; // Per file (error) message if any.
@@ -33,6 +33,7 @@ struct HandlerStats {
enum Status { OPEN, IDLE, RETIRED };
Status status; // Status of this file handler.
double last_access; // Last access in hi-res seconds since epoch.
+ float max_output_value; // Clipping ? Should be [0 .. 1]
bool in_gapless; // Were we handed a processor to continue.
bool out_gapless; // Did we pass on our processor.
};
View
@@ -210,12 +210,14 @@ class SndFileHandler :
stats->progress = 0.0;
else
stats->progress = 1.0 * frames_done / in_info_.frames;
- if (processor_ && processor_->max_output_value() > 1.0) {
+ if (base_stats_.max_output_value) {
+ // TODO: the status server could inspect this value and make better
+ // rendering.
base_stats_.message =
StringPrintf("Output clipping! "
"(max=%.3f; Multiply gain with <= %.5f<br/>in %s)",
- processor_->max_output_value(),
- 1.0 / processor_->max_output_value(),
+ base_stats_.max_output_value,
+ 1.0 / base_stats_.max_output_value,
config_path_.c_str());
}
}
@@ -416,7 +418,7 @@ class SndFileHandler :
processor_->WriteProcessed(snd_out_, r);
if (passed_processor) {
base_stats_.out_gapless = true;
- LogClipping();
+ ExtractOutputValues();
processor_ = NULL; // we handed over ownership.
}
if (next_file) fs_->Close(found->c_str(), next_file);
@@ -499,18 +501,22 @@ class SndFileHandler :
}
}
- void LogClipping() {
- if (processor_ && processor_->max_output_value() > 1.0) {
- syslog(LOG_ERR, "Observed output clipping (%s). "
- "Max=%.3f; Multiply gain with <= %.5f in %s",
- base_stats_.filename.c_str(), processor_->max_output_value(),
- 1.0 / processor_->max_output_value(), config_path_.c_str());
+ void ExtractOutputValues() {
+ if (processor_) {
+ base_stats_.max_output_value = processor_->max_output_value();
processor_->ResetMaxValues();
}
}
+
void Close() {
if (snd_out_ == NULL) return; // done.
- LogClipping();
+ ExtractOutputValues();
+ if (base_stats_.max_output_value > 1.0) {
+ syslog(LOG_ERR, "Observed output clipping in '%s': "
+ "Max=%.3f; Multiply gain with <= %.5f in %s",
+ base_stats_.filename.c_str(), base_stats_.max_output_value,
+ 1.0 / base_stats_.max_output_value, config_path_.c_str());
+ }
// We can't disable buffer writes here, because outfile closing will flush
// the last couple of sound samples.
if (snd_in_) sf_close(snd_in_);

0 comments on commit a5c6382

Please sign in to comment.