using std::vector;
using std::pair;
using boost::shared_ptr;
+using boost::weak_ptr;
using boost::bind;
using boost::optional;
using boost::const_pointer_cast;
* @param film Film we are using.
* @param content Content to analyse, or 0 to analyse all of the film's audio.
*/
-AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content)
+AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer, shared_ptr<Content> content)
: wxDialog (
parent,
wxID_ANY,
#endif
)
, _film (film)
+ , _viewer (viewer)
, _content (content)
, _channels (film->audio_channels ())
, _plot (0)
_cursor = new StaticText (this, wxT("Cursor: none"));
left->Add (_cursor, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP);
- _plot = new AudioPlot (this);
+ _plot = new AudioPlot (this, viewer);
left->Add (_plot, 1, wxTOP | wxEXPAND, 12);
_sample_peak = new StaticText (this, wxT (""));
left->Add (_sample_peak, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP);
#include <boost/signals2.hpp>
class AudioPlot;
+class FilmViewer;
class Film;
class AudioDialog : public wxDialog
{
public:
- AudioDialog (wxWindow* parent, boost::shared_ptr<Film> film, boost::shared_ptr<Content> content = boost::shared_ptr<Content> ());
+ AudioDialog (wxWindow* parent, boost::shared_ptr<Film> film, boost::weak_ptr<FilmViewer> viewer, boost::shared_ptr<Content> content = boost::shared_ptr<Content>());
bool Show (bool show = true);
boost::shared_ptr<AudioAnalysis> _analysis;
boost::weak_ptr<Film> _film;
+ boost::weak_ptr<FilmViewer> _viewer;
/** content to analyse, or 0 to analyse all the film's content */
boost::weak_ptr<Content> _content;
int _channels;
return;
}
- _audio_dialog = new AudioDialog (this, _parent->film (), ac.front ());
+ _audio_dialog = new AudioDialog (this, _parent->film(), _parent->film_viewer(), ac.front());
_audio_dialog->Show ();
}
/*
- Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
#include "audio_plot.h"
+#include "wx_util.h"
+#include "film_viewer.h"
#include "lib/audio_decoder.h"
#include "lib/audio_analysis.h"
#include "lib/compose.hpp"
-#include "wx/wx_util.h"
#include <wx/graphics.h>
#include <boost/bind.hpp>
#include <iostream>
using boost::bind;
using boost::optional;
using boost::shared_ptr;
+using boost::weak_ptr;
using namespace dcpomatic;
int const AudioPlot::_minimum = -70;
int const AudioPlot::_cursor_size = 8;
int const AudioPlot::max_smoothing = 128;
-AudioPlot::AudioPlot (wxWindow* parent)
+AudioPlot::AudioPlot (wxWindow* parent, weak_ptr<FilmViewer> viewer)
: wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
+ , _viewer (viewer)
, _smoothing (max_smoothing / 2)
, _gain_correction (0)
{
Bind (wxEVT_PAINT, boost::bind (&AudioPlot::paint, this));
Bind (wxEVT_MOTION, boost::bind (&AudioPlot::mouse_moved, this, _1));
Bind (wxEVT_LEAVE_WINDOW, boost::bind (&AudioPlot::mouse_leave, this, _1));
+ Bind (wxEVT_LEFT_DOWN, boost::bind(&AudioPlot::left_down, this));
SetMinSize (wxSize (640, 512));
}
}
}
+
+void
+AudioPlot::left_down ()
+{
+ if (_cursor) {
+ shared_ptr<FilmViewer> fv = _viewer.lock ();
+ if (fv) {
+ fv->seek (_cursor->time, true);
+ }
+ }
+}
+
+
void
AudioPlot::mouse_moved (wxMouseEvent& ev)
{
/*
- Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
#include <vector>
struct Metrics;
+class FilmViewer;
class AudioPlot : public wxPanel
{
public:
- explicit AudioPlot (wxWindow *);
+ explicit AudioPlot (wxWindow *, boost::weak_ptr<FilmViewer> viewer);
void set_analysis (boost::shared_ptr<AudioAnalysis>);
void set_channel_visible (int c, bool v);
void plot_rms (wxGraphicsPath &, int, Metrics const &) const;
float y_for_linear (float, Metrics const &) const;
AudioPoint get_point (int channel, int point) const;
+ void left_down ();
void mouse_moved (wxMouseEvent& ev);
void mouse_leave (wxMouseEvent& ev);
void search (std::map<int, PointList> const & search, wxMouseEvent const & ev, double& min_dist, Point& min_point) const;
+ boost::weak_ptr<FilmViewer> _viewer;
boost::shared_ptr<AudioAnalysis> _analysis;
bool _channel_visible[MAX_DCP_AUDIO_CHANNELS];
bool _type_visible[AudioPoint::COUNT];
_audio_dialog = 0;
}
- AudioDialog* d = new AudioDialog (_panel, _film);
+ AudioDialog* d = new AudioDialog (_panel, _film, _viewer);
d->Show ();
}