2 * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "export_report.h"
21 #include <gtkmm/label.h>
22 #include <gtkmm/stock.h>
24 #include "canvas/utils.h"
25 #include "canvas/colors.h"
30 using namespace ARDOUR;
32 ExportReport::ExportReport (StatusPtr s)
33 : ArdourDialog (_("Export Report/Analysis"))
37 AnalysisResults & ar = status->result_map;
38 //size_t n_results = ar.size();
40 for (AnalysisResults::iterator i = ar.begin(); i != ar.end(); ++i) {
42 VBox *vb = manage (new VBox());
45 l = manage (new Label(string_compose (_("File: %1"), i->first)));
48 ExportAnalysisPtr p = i->second;
49 if (i->second->have_loudness) {
50 // TODO loudness histogram, HBox
51 // TODO use cairo-widget and BIG numbers
52 l = manage (new Label(string_compose (_("Loudness: %1 LUFS"), p->loudness)));
54 l = manage (new Label(string_compose (_("Loudness Range: %1 LU"), p->loudness_range)));
59 // TODO re-use Canvas::WaveView::draw_image() somehow.
60 const size_t peaks = sizeof(p->_peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 2;
61 const float height_2 = 150.0;
62 Cairo::RefPtr<Cairo::ImageSurface> wave = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, peaks, 2 * height_2);
63 Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create (wave);
64 cr->rectangle (0, 0, peaks, 2 * height_2);
65 cr->set_source_rgba (0, 0, 0, 1.0);
67 cr->set_source_rgba (.7, .7, .7, 1.0);
68 cr->set_line_width (1.0);
69 for (size_t x = 0 ; x < peaks; ++x) {
70 cr->move_to (x - .5, height_2 - height_2 * p->_peaks[x].max);
71 cr->line_to (x - .5, height_2 - height_2 * p->_peaks[x].min);
76 CimgArea *wv = manage (new CimgArea (wave));
81 // TODO: get geometry from ExportAnalysis
82 const size_t width = 800;
83 const size_t height = 256;
84 Cairo::RefPtr<Cairo::ImageSurface> spec = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, width, height);
85 Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create (spec);
86 cr->rectangle (0, 0, width, height);
87 cr->set_source_rgba (0, 0, 0, 1.0);
89 for (size_t x = 0 ; x < width; ++x) {
90 for (size_t y = 0 ; y < height; ++y) {
91 const float pk = p->_spectrum[x][y];
92 ArdourCanvas::Color c = ArdourCanvas::hsva_to_color (252 - 260 * pk, .9, .3 + pk * .4);
93 ArdourCanvas::set_source_rgba (cr, c);
94 cr->rectangle (x - .5, y - .5, 1, 1);
99 CimgArea *sp = manage (new CimgArea (spec));
100 vb->pack_start (*sp);
103 // TODO ellipsize tab-text
104 pages.pages().push_back (Notebook_Helpers::TabElem (*vb, Glib::path_get_basename (i->first)));
107 pages.set_show_tabs (true);
109 pages.set_name ("ExportReportNotebook");
110 pages.set_current_page (0);
112 get_vbox()->set_spacing (12);
113 get_vbox()->pack_start (pages);
115 add_button (Stock::CLOSE, RESPONSE_ACCEPT);
116 set_default_response (RESPONSE_ACCEPT);
118 //pages.signal_switch_page().connect (sigc::mem_fun (*this, &ExportReport::handle_page_change));
124 return ArdourDialog::run ();