void
AudioDialog::try_to_load_analysis ()
{
- shared_ptr<AudioAnalysis> a;
-
- if (boost::filesystem::exists (_content->audio_analysis_path())) {
- a.reset (new AudioAnalysis (_content->audio_analysis_path ()));
- } else {
- if (IsShown ()) {
- _content->analyse_audio (bind (&AudioDialog::try_to_load_analysis, this));
- }
+ if (!boost::filesystem::exists (_content->audio_analysis_path()) && IsShown ()) {
+ _content->analyse_audio (bind (&AudioDialog::analysis_finished, this));
+ return;
}
-
+
+ shared_ptr<AudioAnalysis> a;
+
+ a.reset (new AudioAnalysis (_content->audio_analysis_path ()));
_plot->set_analysis (a);
if (_channel_checkbox[0]) {
}
}
+void
+AudioDialog::analysis_finished ()
+{
+ if (!boost::filesystem::exists (_content->audio_analysis_path())) {
+ /* We analysed and still nothing showed up, so maybe it was cancelled or it failed.
+ Give up.
+ */
+ _plot->set_message (_("Could not analyse audio."));
+ return;
+ }
+
+ try_to_load_analysis ();
+}
+
void
AudioDialog::channel_clicked (wxCommandEvent& ev)
{
void type_clicked (wxCommandEvent &);
void smoothing_changed (wxScrollEvent &);
void try_to_load_analysis ();
+ void analysis_finished ();
boost::shared_ptr<AudioContent> _content;
AudioPlot* _plot;
: wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
, _gain (0)
, _smoothing (max_smoothing / 2)
+ , _message (_("Please wait; audio is being analysed..."))
{
#ifndef __WXOSX__
SetDoubleBuffered (true);
Refresh ();
}
+void
+AudioPlot::set_message (wxString s)
+{
+ _message = s;
+ Refresh ();
+}
+
void
AudioPlot::paint (wxPaintEvent &)
{
if (!_analysis || _analysis->channels() == 0) {
gc->SetFont (gc->CreateFont (*wxNORMAL_FONT));
- gc->DrawText (_("Please wait; audio is being analysed..."), 32, 32);
+ gc->DrawText (_message, 32, 32);
return;
}
void set_type_visible (int t, bool v);
void set_gain (float);
void set_smoothing (int);
+ void set_message (wxString);
static const int max_smoothing;
float _x_scale;
float _y_scale;
+ wxString _message;
+
static const int _minimum;
};