update Export Report GUI
[ardour.git] / gtk2_ardour / export_report.cc
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
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.
8  *
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.
13  *
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.
17  */
18
19 #include <algorithm>
20
21 #include <pangomm/layout.h>
22 #include <gtkmm/label.h>
23 #include <gtkmm/table.h>
24 #include <gtkmm/stock.h>
25
26 #include "pbd/openuri.h"
27 #include "gtkmm2ext/utils.h"
28 #include "gtkmm2ext/utils.h"
29 #include "canvas/utils.h"
30 #include "canvas/colors.h"
31
32 #include "audiographer/general/analyser.h"
33
34 #include "ardour/audiofilesource.h"
35 #include "ardour/audioregion.h"
36 #include "ardour/auditioner.h"
37 #include "ardour/dB.h"
38 #include "ardour/region_factory.h"
39 #include "ardour/session.h"
40 #include "ardour/smf_source.h"
41 #include "ardour/source_factory.h"
42 #include "ardour/srcfilesource.h"
43
44 #include "audio_clock.h"
45 #include "export_report.h"
46 #include "logmeter.h"
47 #include "ui_config.h"
48
49 #include "i18n.h"
50
51 using namespace Gtk;
52 using namespace ARDOUR;
53
54 ExportReport::ExportReport (Session* session, StatusPtr s)
55         : ArdourDialog (_("Export Report/Analysis"))
56         , status (s)
57         , _session (session)
58         , _audition_num (-1)
59         , _page_num (0)
60 {
61         set_resizable (false);
62         pages.set_scrollable ();
63
64         AnalysisResults & ar = status->result_map;
65
66         std::vector<double> dashes;
67         dashes.push_back (3.0);
68         dashes.push_back (5.0);
69
70         int page = 0;
71         for (AnalysisResults::iterator i = ar.begin (); i != ar.end (); ++i, ++page) {
72                 Label *l;
73                 VBox *vb = manage (new VBox ());
74                 Table *t = manage (new Table (4, 4));
75                 Table *wtbl = manage (new Table (3, 2));
76                 int wrow = 0;
77                 t->set_border_width (0);
78                 t->set_spacings (4);
79                 wtbl->set_spacings (4);
80                 vb->set_spacing (4);
81                 vb->set_border_width (4);
82                 vb->pack_start (*t, false, false, 2);
83                 vb->pack_start (*wtbl, false, false, 2);
84
85                 std::string path = i->first;
86                 ExportAnalysisPtr p = i->second;
87
88                 std::list<CimgPlayheadArea*> playhead_widgets;
89
90                 l = manage (new Label (_("File:"), ALIGN_END));
91                 t->attach (*l, 0, 1, 0, 1);
92                 l = manage (new Label ());
93                 l->set_ellipsize (Pango::ELLIPSIZE_START);
94                 l->set_width_chars (48);
95                 l->set_max_width_chars (48);
96                 l->set_text (path);
97                 l->set_alignment (ALIGN_START, ALIGN_CENTER);
98                 t->attach (*l, 1, 3, 0, 1, FILL, SHRINK);
99
100                 Button *b = manage (new Button (_("Open Folder")));
101                 t->attach (*b, 3, 4, 0, 2, FILL, SHRINK);
102                 b->signal_clicked ().connect (sigc::bind (sigc::mem_fun (*this, &ExportReport::open_folder), path));
103
104                 SoundFileInfo info;
105                 std::string errmsg;
106
107                 framecnt_t file_length = 0;
108                 framecnt_t sample_rate = 0;
109                 framecnt_t start_off = 0;
110                 unsigned int channels = 0;
111
112                 if (AudioFileSource::get_soundfile_info (path, info, errmsg)) {
113                         AudioClock * clock;
114
115                         file_length = info.length;
116                         sample_rate = info.samplerate;
117                         start_off = info.timecode;
118                         channels = info.channels;
119
120                         files.insert (std::make_pair (page, AuditionInfo (path, channels)));
121
122                         /* File Info Table */
123
124                         framecnt_t const nfr = _session ? _session->nominal_frame_rate () : 25;
125                         double src_coef = (double) nfr / info.samplerate;
126
127                         l = manage (new Label (_("Format:"), ALIGN_END));
128                         t->attach (*l, 0, 1, 1, 2);
129                         std::string fmt = info.format_name;
130                         std::replace (fmt.begin (), fmt.end (), '\n', ' ');
131                         l = manage (new Label ());
132                         l->set_ellipsize (Pango::ELLIPSIZE_START);
133                         l->set_width_chars (48);
134                         l->set_max_width_chars (48);
135                         l->set_text (fmt);
136                         l->set_alignment (ALIGN_START, ALIGN_CENTER);
137                         t->attach (*l, 1, 3, 1, 2, FILL, SHRINK);
138
139                         l = manage (new Label (_("Channels:"), ALIGN_END));
140                         t->attach (*l, 0, 1, 2, 3);
141                         l = manage (new Label (string_compose ("%1", info.channels), ALIGN_START));
142                         t->attach (*l, 1, 2, 2, 3);
143
144                         l = manage (new Label (_("Sample rate:"), ALIGN_END));
145                         t->attach (*l, 0, 1, 3, 4);
146                         l = manage (new Label (string_compose (_("%1 Hz"), info.samplerate), ALIGN_START));
147                         t->attach (*l, 1, 2, 3, 4);
148
149                         l = manage (new Label (_("Duration:"), ALIGN_END));
150                         t->attach (*l, 2, 3, 2, 3);
151                         clock = manage (new AudioClock ("sfboxLengthClock", true, "", false, false, true, false));
152                         clock->set_session (_session);
153                         clock->set_mode (AudioClock::MinSec);
154                         clock->set (info.length * src_coef + 0.5, true);
155                         t->attach (*clock, 3, 4, 2, 3);
156
157                         l = manage (new Label (_("Timecode:"), ALIGN_END));
158                         t->attach (*l, 2, 3, 3, 4);
159                         clock = manage (new AudioClock ("sfboxTimecodeClock", true, "", false, false, false, false));
160                         clock->set_session (_session);
161                         clock->set_mode (AudioClock::Timecode);
162                         clock->set (info.timecode * src_coef + 0.5, true);
163                         t->attach (*clock, 3, 4, 3, 4);
164                 } else {
165                         l = manage (new Label (_("Error:"), ALIGN_END));
166                         t->attach (*l, 0, 1, 1, 2);
167                         l = manage (new Label (errmsg, ALIGN_START));
168                         t->attach (*l, 1, 4, 1, 2);
169                 }
170
171                 int w, h;
172                 Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (get_pango_context ());
173
174                 // calc geometry of numerics
175                 const float dbfs = accurate_coefficient_to_dB (p->peak);
176                 const float dbtp = accurate_coefficient_to_dB (p->truepeak);
177
178 #define TXTSIZE(LINE, TXT, FONT) {                                     \
179   layout->set_font_description (UIConfiguration::instance ().FONT ()); \
180   layout->set_text (TXT);                                              \
181   layout->get_pixel_size (w, h);                                       \
182   if (w > mnw) { mnw = w; }                                            \
183   if (h > lin[LINE]) { lin[LINE] = h; }                                \
184 }
185
186 #define TXTWIDTH(TXT, FONT) {                                          \
187   layout->set_font_description (UIConfiguration::instance ().FONT ()); \
188   layout->set_text (TXT);                                              \
189   layout->get_pixel_size (w, h);                                       \
190   if (w > mml) { mml = w; }                                            \
191 }
192
193                 int m_r = 0; // right side
194                 int mnh = 0; // mono height
195                 int mnw = 0; // max numeric width
196                 int anw = 0; // spectrum annotation text width
197
198                 int lin[4] = { 0, 0, 0, 0 }; // max line height
199
200                 TXTSIZE(0, _("(too short integration time)"), get_SmallFont);
201
202                 TXTSIZE(0, _("-88"), get_SmallMonospaceFont);
203                 anw = w;
204                 m_r = anw + 10;
205                 mnh = h + 1;
206
207                 TXTSIZE(0, _("Peak:"), get_SmallFont);
208                 TXTSIZE(1, string_compose (_("%1 dBFS"), std::setprecision (1), std::fixed, dbfs), get_LargeFont);
209                 TXTSIZE(2, _("True Peak:"), get_SmallFont);
210                 TXTSIZE(3, string_compose (_("%1 dBTP"), std::setprecision (1), std::fixed, dbtp), get_LargeFont);
211
212                 TXTSIZE(0, _("Integrated Loudness:"), get_SmallFont);
213                 TXTSIZE(1, string_compose (_("%1 LUFS"), std::setprecision (1), std::fixed, p->loudness), get_LargeFont);
214                 TXTSIZE(2, _("Loudness Range:"), get_SmallFont);
215                 TXTSIZE(3, string_compose (_("%1 LU"), std::setprecision (1), std::fixed, p->loudness_range), get_LargeFont);
216
217                 mnw += 8;
218                 const int ht = lin[0] * 1.25 + lin[1] * 1.25 + lin[2] * 1.25 + lin[3] + 8;
219                 const int hh = std::max (100, ht);
220                 int m_l =  2 * mnw + /*hist-width*/ 540 + /*box spacing*/ 8 - /*peak-width*/ 800 - m_r; // margin left
221
222                 int mml = 0; // min margin left -- ensure left margin is wide enough
223                 TXTWIDTH (_("Time"), get_SmallFont);
224                 TXTWIDTH (_("100"), get_SmallMonospaceFont);
225                 m_l = (std::max(anw + mnh + 14, std::max (m_l, mml + 8)) + 3) & ~3;
226
227                 mnw = (m_l - /*hist-width*/ 540 - /*box spacing*/ 8 + /*peak-width*/ 800 + m_r) / 2;
228                 const int nw2 = mnw / 2; // nums, horizontal center
229
230                 int y0[4];
231                 y0[0] = (hh - ht) * .5 + lin[0] * .25;
232                 y0[1] = y0[0] + lin[0] * 1.25;
233                 y0[2] = y0[1] + lin[1] * 1.25;
234                 y0[3] = y0[2] + lin[2] * 1.25;
235
236
237                 { /* peak, loudness and R128 histogram */
238                         Cairo::RefPtr<Cairo::ImageSurface> nums = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, mnw, hh);
239                         Cairo::RefPtr<Cairo::ImageSurface> ebur = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, mnw, hh);
240                         Cairo::RefPtr<Cairo::ImageSurface> hist = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, 540, hh);
241
242                         /* peak and true-peak numerics */
243                         Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create (nums);
244                         cr->set_source_rgba (0, 0, 0, 1.0);
245                         cr->paint ();
246
247                         layout->set_font_description (UIConfiguration::instance ().get_SmallFont ());
248                         layout->set_alignment (Pango::ALIGN_LEFT);
249                         layout->set_text (_("Peak:"));
250                         layout->get_pixel_size (w, h);
251                         cr->move_to (rint (nw2 - w * .5), y0[0]);
252                         cr->set_source_rgba (.7, .7, .7, 1.0);
253                         layout->show_in_cairo_context (cr);
254
255                         layout->set_font_description (UIConfiguration::instance ().get_LargeFont ());
256                         layout->set_text (string_compose (_("%1 dBFS"), std::setprecision (1), std::fixed, dbfs));
257                         layout->get_pixel_size (w, h);
258                         cr->move_to (rint (nw2 - w * .5), y0[1]);
259                         if (dbfs >= 0.f) { cr->set_source_rgba (1.0, .1, .1, 1.0); }
260                         else if (dbfs > -1.f) { cr->set_source_rgba (1.0, .7, .0, 1.0); }
261                         layout->show_in_cairo_context (cr);
262
263                         if (p->have_dbtp) {
264                                 layout->set_font_description (UIConfiguration::instance ().get_SmallFont ());
265                                 layout->set_text (_("True Peak:"));
266                                 layout->get_pixel_size (w, h);
267                                 cr->move_to (rint (nw2 - w * .5), y0[2]);
268                                 cr->set_source_rgba (.7, .7, .7, 1.0);
269                                 layout->show_in_cairo_context (cr);
270
271                                 layout->set_font_description (UIConfiguration::instance ().get_LargeFont ());
272                                 layout->set_text (string_compose (_("%1 dBTP"), std::setprecision (1), std::fixed, dbtp));
273                                 layout->get_pixel_size (w, h);
274                                 cr->move_to (rint (nw2 - w * .5), y0[3]);
275                                 if (dbtp >= 0.f) { cr->set_source_rgba (1.0, .1, .1, 1.0); }
276                                 else if (dbtp > -1.f) { cr->set_source_rgba (1.0, .7, .0, 1.0); }
277                                 layout->show_in_cairo_context (cr);
278                         }
279
280                         nums->flush ();
281
282                         /* EBU R128 numerics */
283                         cr = Cairo::Context::create (ebur);
284                         cr->set_source_rgba (0, 0, 0, 1.0);
285                         cr->paint ();
286
287                         cr->set_source_rgba (.7, .7, .7, 1.0);
288
289                         if (!i->second->have_loudness) {
290                                 layout->set_alignment (Pango::ALIGN_CENTER);
291                                 layout->set_font_description (UIConfiguration::instance ().get_LargeFont ());
292                                 layout->set_text (_("Not\nAvailable"));
293                                 layout->get_pixel_size (w, h);
294                                 cr->move_to (rint (nw2 - w * .5), rint ((hh - h) * .5));
295                                 layout->show_in_cairo_context (cr);
296                         }
297                         else if (p->loudness == -200 && p->loudness_range == 0) {
298                                 layout->set_alignment (Pango::ALIGN_CENTER);
299                                 layout->set_font_description (UIConfiguration::instance ().get_LargeFont ());
300                                 layout->set_text (_("Not\nAvailable"));
301                                 layout->get_pixel_size (w, h);
302                                 cr->move_to (rint (nw2 - w * .5), rint (hh * .5 - h * .6));
303                                 layout->show_in_cairo_context (cr);
304                                 int yy = h * .5;
305
306                                 layout->set_font_description (UIConfiguration::instance ().get_SmallFont ());
307                                 layout->set_text (_("(too short integration time)"));
308                                 layout->get_pixel_size (w, h);
309                                 cr->move_to (rint (nw2 - w * .5), rint (hh * .5 + yy));
310                                 layout->show_in_cairo_context (cr);
311
312                         } else {
313                                 layout->set_font_description (UIConfiguration::instance ().get_SmallFont ());
314                                 layout->set_alignment (Pango::ALIGN_LEFT);
315                                 layout->set_text (_("Integrated Loudness:"));
316                                 layout->get_pixel_size (w, h);
317                                 cr->move_to (rint (nw2 - w * .5), y0[0]);
318                                 layout->show_in_cairo_context (cr);
319
320                                 layout->set_font_description (UIConfiguration::instance ().get_LargeFont ());
321                                 layout->set_text (string_compose (_("%1 LUFS"), std::setprecision (1), std::fixed,  p->loudness));
322                                 layout->get_pixel_size (w, h);
323                                 cr->move_to (rint (nw2 - w * .5), y0[1]);
324                                 layout->show_in_cairo_context (cr);
325
326                                 layout->set_font_description (UIConfiguration::instance ().get_SmallFont ());
327                                 layout->set_text (_("Loudness Range:"));
328                                 layout->get_pixel_size (w, h);
329                                 cr->move_to (rint (nw2 - w * .5), y0[2]);
330                                 layout->show_in_cairo_context (cr);
331
332                                 layout->set_font_description (UIConfiguration::instance ().get_LargeFont ());
333                                 layout->set_text (string_compose (_("%1 LU"), std::setprecision (1), std::fixed, p->loudness_range));
334                                 layout->get_pixel_size (w, h);
335                                 cr->move_to (rint (nw2 - w * .5), y0[3]);
336                                 layout->show_in_cairo_context (cr);
337                         }
338                         ebur->flush ();
339
340                         /* draw loudness histogram */
341                         cr = Cairo::Context::create (hist);
342                         cr->set_source_rgba (0, 0, 0, 1.0);
343                         cr->paint ();
344
345                         cr->set_source_rgba (.7, .7, .7, 1.0);
346                         cr->set_line_width (1.0);
347
348                         if (p->loudness_hist_max > 0 && i->second->have_loudness) {
349                                 for (size_t x = 0 ; x < 510; ++x) {
350                                         cr->move_to (x - .5, hh);
351                                         cr->line_to (x - .5, (float) hh * (1.0 - p->loudness_hist[x] / (float) p->loudness_hist_max));
352                                         cr->stroke ();
353                                 }
354                         } else {
355                                 // TODO print "Not Avail"
356                         }
357
358                         layout->set_font_description (UIConfiguration::instance ().get_SmallerFont ());
359                         layout->set_alignment (Pango::ALIGN_CENTER);
360
361                         // Label
362                         layout->set_text (_("LUFS\n(short)"));
363                         layout->get_pixel_size (w, h);
364                         Gtkmm2ext::rounded_rectangle (cr, 5, rint (.5 * (hh - w) - 1), h + 2, w + 2, 4);
365                         cr->set_source_rgba (.1, .1, .1, 0.7);
366                         cr->fill ();
367                         cr->save ();
368                         cr->move_to (6, rint (.5 * (hh + w)));
369                         cr->set_source_rgba (.9, .9, .9, 1.0);
370                         cr->rotate (M_PI / -2.0);
371                         layout->show_in_cairo_context (cr);
372                         cr->restore ();
373
374                         // x-Axis
375                         layout->set_font_description (UIConfiguration::instance ().get_SmallMonospaceFont ());
376                         layout->set_alignment (Pango::ALIGN_LEFT);
377                         for (int g = -53; g <= -8; g += 5) {
378                                 // grid-lines. [110] -59LUFS .. [650]: -5 LUFS
379                                 layout->set_text (string_compose ("%1", std::setw(3), std::setfill(' '), g));
380                                 layout->get_pixel_size (w, h);
381
382                                 cr->set_operator (Cairo::OPERATOR_OVER);
383                                 Gtkmm2ext::rounded_rectangle (cr,
384                                                 rint ((g + 59.0) * 10.0 - h * .5), 5,
385                                                 h + 2, w + 2, 4);
386                                 const float pk = (g + 59.0) / 54.0;
387                                 ArdourCanvas::Color c = ArdourCanvas::hsva_to_color (252 - 260 * pk, .9, .3 + pk * .4, .6);
388                                 ArdourCanvas::set_source_rgba (cr, c);
389                                 cr->fill ();
390
391                                 cr->save ();
392                                 cr->set_source_rgba (.9, .9, .9, 1.0);
393                                 cr->move_to (rint ((g + 59.0) * 10.0 - h * .5), w + 6.0);
394                                 cr->rotate (M_PI / -2.0);
395                                 layout->show_in_cairo_context (cr);
396                                 cr->restore ();
397
398                                 cr->set_operator (Cairo::OPERATOR_ADD);
399                                 cr->save ();
400                                 cr->set_source_rgba (.3, .3, .3, 1.0);
401                                 cr->set_dash (dashes, 1.0);
402                                 cr->set_line_cap (Cairo::LINE_CAP_ROUND);
403                                 cr->move_to (rint ((g + 59.0) * 10.0) + .5, w + 8.0);
404                                 cr->line_to (rint ((g + 59.0) * 10.0) + .5, hh);
405                                 cr->stroke ();
406                                 cr->restore ();
407                         }
408
409                         // add normalization gain factor here (for want of a better place)
410                         if (p->normalized) {
411                                 const float ndb = accurate_coefficient_to_dB (p->norm_gain_factor);
412                                 layout->set_font_description (UIConfiguration::instance ().get_SmallFont ());
413                                 layout->set_alignment (Pango::ALIGN_LEFT);
414                                 layout->set_text (string_compose (_("Normalization Gain: %1 dB"), std::setprecision (2), std::showpos, std::fixed, ndb));
415                                 layout->get_pixel_size (w, h);
416                                 cr->set_operator (Cairo::OPERATOR_OVER);
417                                 layout->get_pixel_size (w, h);
418                                 Gtkmm2ext::rounded_rectangle (cr, 5, rint (.5 * (hh - w) - 1), h + 2, w + 2, 4);
419                                 cr->set_source_rgba (.1, .1, .1, 0.7);
420                                 cr->fill ();
421                                 cr->set_source_rgba (.3, .7, .3, 1.0);
422                                 cr->move_to (6, hh - h - 2);
423                                 layout->show_in_cairo_context (cr);
424                         }
425
426                         hist->flush ();
427
428                         CimgArea *nu = manage (new CimgArea (nums));
429                         CimgArea *eb = manage (new CimgArea (ebur));
430                         CimgArea *hi = manage (new CimgArea (hist));
431                         HBox *hb = manage (new HBox ());
432                         hb->set_spacing (4);
433                         hb->pack_start (*nu, false, false);
434                         hb->pack_start (*hi, false, false);
435                         hb->pack_start (*eb, false, false);
436
437                         wtbl->attach (*hb, 0, 2, wrow, wrow + 1, SHRINK, SHRINK);
438                         ++wrow;
439                 }
440
441 #define XAXISLABEL(POS, TXT) {                            \
442   const float yy = rint (POS);                            \
443   layout->set_text (TXT);                                 \
444   layout->get_pixel_size (w, h);                          \
445   cr->move_to (m_l - 8 - w, rint ((POS) - h * .5));       \
446   cr->set_source_rgba (.9, .9, .9, 1.0);                  \
447   cr->set_operator (Cairo::OPERATOR_OVER);                \
448   layout->show_in_cairo_context (cr);                     \
449   cr->move_to (m_l - 4, yy - .5);                         \
450   cr->line_to (m_l + width, yy - .5);                     \
451   cr->set_source_rgba (.3, .3, .3, 1.0);                  \
452   cr->set_operator (Cairo::OPERATOR_ADD);                 \
453   cr->stroke ();                                          \
454 }
455
456                 for (uint32_t c = 0; c < p->n_channels; ++c) {
457                         /* draw waveform */
458                         const size_t width = sizeof (p->peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4;
459
460                         Cairo::RefPtr<Cairo::ImageSurface> wave;
461                         Cairo::RefPtr<Cairo::ImageSurface> wave_log;
462                         Cairo::RefPtr<Cairo::ImageSurface> wave_rect;
463                         Cairo::RefPtr<Cairo::ImageSurface> wave_lr;
464                         draw_waveform(wave, p, c, m_l, width, anw, lin[0], false, false);
465                         draw_waveform(wave_log, p, c, m_l, width, anw, lin[0], true, false);
466                         draw_waveform(wave_rect, p, c, m_l, width, anw, lin[0], false, true);
467                         draw_waveform(wave_lr, p, c, m_l, width, anw, lin[0], true, true);
468
469                         CimgWaveArea *wv = manage (new CimgWaveArea (wave, wave_log, wave_rect, wave_lr, m_l, width));
470
471                         playhead_widgets.push_back (wv);
472                         wv->seek_playhead.connect (sigc::bind<0> (sigc::mem_fun (*this, &ExportReport::audition_seek), page));
473
474                         VBox *lrb = manage (new VBox());
475                         ToggleButton *log = manage (new ToggleButton (S_("Logscale|L")));
476                         ToggleButton *rec = manage (new ToggleButton (S_("Rectified|R")));
477                         lrb->pack_start (*log, false, false, 5);
478                         lrb->pack_end (*rec, false, false, 5);
479                         log->signal_toggled ().connect (sigc::bind (sigc::mem_fun (wv, &CimgWaveArea::set_logscale), log));
480                         rec->signal_toggled ().connect (sigc::bind (sigc::mem_fun (wv, &CimgWaveArea::set_rectified), rec));
481                         lrb->show_all ();
482
483                         wtbl->attach (*wv, 0, 1, wrow, wrow + 1, SHRINK, SHRINK);
484                         wtbl->attach (*lrb, 1, 2, wrow, wrow + 1, SHRINK, SHRINK);
485                         ++wrow;
486                 }
487
488                 if (channels > 0 && file_length > 0 && sample_rate > 0)
489                 {
490                         /* Time Axis  -- re-use waveform width */
491                         const size_t width = sizeof (p->peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4;
492                         layout->set_font_description (UIConfiguration::instance ().get_SmallMonospaceFont ());
493                         layout->set_text (_("00:00:00.000"));
494                         layout->get_pixel_size (w, h);
495                         int height = h * 1.75;
496                         Cairo::RefPtr<Cairo::ImageSurface> ytme = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, m_l + width, height);
497                         Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create (ytme);
498                         cr->set_operator (Cairo::OPERATOR_SOURCE);
499                         cr->set_source_rgba (0, 0, 0, 1.0);
500                         cr->paint ();
501                         cr->rectangle (0, 0, m_l, height);
502                         cr->set_source_rgba (0, 0, 0, 0);
503                         cr->fill ();
504                         cr->set_operator (Cairo::OPERATOR_OVER);
505
506                         cr->set_line_width (1.0);
507                         for (int i = 0; i <= 4; ++i) {
508                                 const float fract = (float) i / 4.0;
509                                 // " XX:XX:XX.XXX"  [space/minus] 12 chars = 13.
510                                 const float xalign = (i == 4) ? 1.0 : (i == 0) ? 1.0 / 13.0 : 7.0 / 13.0;
511
512                                 char buf[16];
513                                 AudioClock::print_minsec (start_off + file_length * fract,
514                                                 buf, sizeof (buf), sample_rate);
515
516                                 layout->set_text (buf);
517                                 layout->get_pixel_size (w, h);
518                                 cr->move_to (rint (m_l + width * fract - w * xalign), rint (.5 * (height - h)));
519                                 cr->set_source_rgba (.9, .9, .9, 1.0);
520                                 layout->show_in_cairo_context (cr);
521
522                                 cr->set_source_rgba (.7, .7, .7, 1.0);
523                                 cr->move_to (rint (m_l + width * fract) - .5, 0);
524                                 cr->line_to (rint (m_l + width * fract) - .5, ceil  (height * .15));
525                                 cr->move_to (rint (m_l + width * fract) - .5, floor (height * .85));
526                                 cr->line_to (rint (m_l + width * fract) - .5, height);
527                                 cr->stroke ();
528                         }
529
530                         layout->set_font_description (UIConfiguration::instance ().get_SmallFont ());
531                         layout->set_text (_("Time"));
532                         cr->set_source_rgba (.9, .9, .9, 1.0);
533                         layout->get_pixel_size (w, h);
534                         cr->move_to (rint (m_l - w - anw - 2), rint (.5 * (height - h)));
535                         layout->show_in_cairo_context (cr);
536
537                         ytme->flush ();
538                         CimgPlayheadArea *tm = manage (new CimgPlayheadArea (ytme, m_l, width, true));
539                         playhead_widgets.push_back (tm);
540                         tm->seek_playhead.connect (sigc::bind<0> (sigc::mem_fun (*this, &ExportReport::audition_seek), page));
541                         wtbl->attach (*tm, 0, 1, wrow, wrow + 1, SHRINK, SHRINK);
542                         ++wrow;
543                 }
544
545                 {
546                         /* Draw Spectrum */
547                         const size_t swh = sizeof (p->spectrum) / sizeof (float);
548                         const size_t height = sizeof (p->spectrum[0]) / sizeof (float);
549                         const size_t width = swh / height;
550
551                         Cairo::RefPtr<Cairo::ImageSurface> spec = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, m_l + width, height);
552                         Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create (spec);
553                         cr->set_operator (Cairo::OPERATOR_SOURCE);
554                         cr->rectangle (0, 0, m_l, height);
555                         cr->set_source_rgba (0, 0, 0, 0);
556                         cr->fill ();
557                         cr->rectangle (m_l, 0, width, height);
558                         cr->set_source_rgba (0, 0, 0, 1.0);
559                         cr->fill ();
560                         cr->set_operator (Cairo::OPERATOR_OVER);
561
562                         for (size_t x = 0 ; x < width; ++x) {
563                                 for (size_t y = 0 ; y < height; ++y) {
564                                         const float pk = p->spectrum[x][y];
565                                         ArdourCanvas::Color c = ArdourCanvas::hsva_to_color (252 - 260 * pk, .9, sqrt(pk));
566                                         ArdourCanvas::set_source_rgba (cr, c);
567                                         cr->rectangle (m_l + x - .5, y - .5, 1, 1);
568                                         cr->fill ();
569                                 }
570                         }
571
572                         // Unit
573                         layout->set_font_description (UIConfiguration::instance ().get_SmallerFont ());
574                         layout->set_text (_("Hz"));
575                         layout->get_pixel_size (w, h);
576                         cr->move_to (rint (m_l - h - anw - 2), rint ((height + w) * .5));
577                         cr->set_source_rgba (.9, .9, .9, 1.0);
578                         cr->save ();
579                         cr->rotate (M_PI / -2.0);
580                         layout->show_in_cairo_context (cr);
581                         cr->restore ();
582
583                         // x-Axis
584                         cr->set_line_width (1.0);
585                         cr->set_dash (dashes, 2.0);
586                         cr->set_line_cap (Cairo::LINE_CAP_ROUND);
587
588                         layout->set_font_description (UIConfiguration::instance ().get_SmallMonospaceFont ());
589                         //XAXISLABEL (p->freq[0], _("50Hz"));
590                         XAXISLABEL (p->freq[1], _("100"));
591                         XAXISLABEL (p->freq[2], _("500"));
592                         XAXISLABEL (p->freq[3], _("1K"));
593                         XAXISLABEL (p->freq[4], _("5K"));
594                         XAXISLABEL (p->freq[5], _("10K"));
595                         spec->flush ();
596
597                         // annotations
598                         Cairo::RefPtr<Cairo::ImageSurface> scale = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, m_r, height);
599                         cr = Cairo::Context::create (scale);
600                         cr->set_operator (Cairo::OPERATOR_SOURCE);
601                         cr->rectangle (0, 0, m_r, height);
602                         cr->set_source_rgba (0, 0, 0, 0);
603                         cr->fill ();
604
605                         cr->set_operator (Cairo::OPERATOR_OVER);
606                         layout->set_font_description (UIConfiguration::instance ().get_SmallerFont ());
607                         layout->set_alignment (Pango::ALIGN_LEFT);
608                         layout->set_text (_("dBFS"));
609                         layout->get_pixel_size (w, h);
610                         cr->move_to (rint (.5 * (m_r - w)), height - h - 2);
611                         cr->set_source_rgba (.9, .9, .9, 1.0);
612                         layout->show_in_cairo_context (cr);
613
614                         int innertop = ceil (mnh * .5) + 1;
615                         size_t innerheight = (height - 2 * innertop - h - 2);
616
617                         cr->rectangle (1, innertop - 1,  m_r - 2 - anw, innerheight + 2);
618                         cr->set_source_rgba (0, 0, 0, 1.0);
619                         cr->fill_preserve ();
620                         cr->set_line_width (1.0);
621                         cr->set_source_rgba (.7, .7, .6, 1.0);
622                         cr->stroke ();
623
624                         for (size_t y = 0 ; y < innerheight - 2; ++y) {
625                                         const float pk = 1.0 - (float) y / innerheight;
626                                         ArdourCanvas::Color c = ArdourCanvas::hsva_to_color (252 - 260 * pk, .9, sqrt(pk));
627                                         ArdourCanvas::set_source_rgba (cr, c);
628                                         cr->rectangle (2, innertop + y + .5, m_r - 4 - anw, 1);
629                                         cr->fill ();
630                         }
631
632                         layout->set_font_description (UIConfiguration::instance ().get_SmallMonospaceFont ());
633                         for (int i = 0; i <= 4; ++i) {
634                                 const float fract = (float) i / 4.0;
635                                 const float yalign = .5; // (i == 4) ? 0 : (i == 0) ? 1.0 : .5;
636                                 char buf[16];
637                                 snprintf (buf, sizeof (buf), "%.0f", AudioGrapher::Analyser::fft_range_db * -fract);
638                                 layout->set_text (buf);
639                                 layout->get_pixel_size (w, h);
640
641                                 cr->move_to (m_r - anw, rint (innertop + fract * innerheight - h * yalign));
642                                 cr->set_source_rgba (.9, .9, .9, 1.0);
643                                 layout->show_in_cairo_context (cr);
644                         }
645                         scale->flush ();
646
647                         CimgPlayheadArea *sp = manage (new CimgPlayheadArea (spec, m_l, width));
648                         playhead_widgets.push_back (sp);
649                         sp->seek_playhead.connect (sigc::bind<0> (sigc::mem_fun (*this, &ExportReport::audition_seek), page));
650                         CimgArea *an = manage (new CimgArea (scale));
651                         wtbl->attach (*sp, 0, 1, wrow, wrow + 1, SHRINK, SHRINK);
652                         wtbl->attach (*an, 1, 2, wrow, wrow + 1, SHRINK, SHRINK);
653                         ++wrow;
654                 }
655
656                 timeline[page] = playhead_widgets;
657
658                 HBox *tab = manage (new HBox ());
659                 l = manage (new Label (Glib::path_get_basename (path)));
660                 Gtk::Image *img =  manage (new Image (Stock::MEDIA_PLAY, ICON_SIZE_MENU));
661                 tab->pack_start (*img);
662                 tab->pack_start (*l);
663                 l->show();
664                 tab->show();
665                 img->hide();
666                 pages.pages ().push_back (Notebook_Helpers::TabElem (*vb, *tab));
667                 pages.signal_switch_page().connect (sigc::mem_fun (*this, &ExportReport::on_switch_page));
668         }
669
670         pages.set_show_tabs (true);
671         pages.show_all ();
672         pages.set_name ("ExportReportNotebook");
673         pages.set_current_page (0);
674
675         get_vbox ()->set_spacing (4);
676         get_vbox ()->pack_start (pages, false, false);
677
678         if (_session) {
679                 _session->AuditionActive.connect(auditioner_connections, invalidator (*this), boost::bind (&ExportReport::audition_active, this, _1), gui_context());
680                 _session->the_auditioner()->AuditionProgress.connect(auditioner_connections, invalidator (*this), boost::bind (&ExportReport::audition_progress, this, _1, _2), gui_context());
681         }
682
683         play_btn = add_button (Stock::MEDIA_PLAY, RESPONSE_ACCEPT);
684         stop_btn = add_button (Stock::MEDIA_STOP, RESPONSE_ACCEPT);
685         add_button (Stock::CLOSE, RESPONSE_CLOSE);
686
687         set_default_response (RESPONSE_CLOSE);
688         stop_btn->signal_clicked().connect (sigc::mem_fun (*this, &ExportReport::stop_audition));
689         play_btn->signal_clicked().connect (sigc::mem_fun (*this, &ExportReport::play_audition));
690         stop_btn->set_sensitive (false);
691         show_all ();
692 }
693
694 int
695 ExportReport::run ()
696 {
697         do {
698                 int i = ArdourDialog::run ();
699                 if (i == Gtk::RESPONSE_DELETE_EVENT || i == RESPONSE_CLOSE) {
700                         break;
701                 }
702         } while (1);
703
704         if (_session) {
705                 _session->cancel_audition();
706         }
707         return RESPONSE_CLOSE;
708 }
709
710 void
711 ExportReport::open_folder (std::string p)
712 {
713         PBD::open_uri (Glib::path_get_dirname(p));
714 }
715
716 void
717 ExportReport::audition_active (bool active)
718 {
719         stop_btn->set_sensitive (active);
720         play_btn->set_sensitive (!active);
721
722         if (!active && _audition_num == _page_num && timeline.find (_audition_num) != timeline.end ()) {
723                 for (std::list<CimgPlayheadArea*>::const_iterator i = timeline[_audition_num].begin();
724                                 i != timeline[_audition_num].end();
725                                 ++i) {
726                         (*i)->set_playhead (-1);
727                 }
728         }
729
730         if (_audition_num >= 0 ) {
731                 Widget *page = pages.get_nth_page (_audition_num);
732                 HBox *box = static_cast<Gtk::HBox*> (pages.get_tab_label (*page));
733                 if (!active) {
734                         (*(box->get_children().begin()))->hide ();
735                 } else {
736                         (*(box->get_children().begin()))->show ();
737                 }
738         }
739
740         if (!active) {
741                 _audition_num = -1;
742         }
743 }
744
745 void
746 ExportReport::audition (std::string path, unsigned n_chn, int page)
747 {
748         assert (_session);
749         _session->cancel_audition();
750
751         if (n_chn ==0) { return; }
752
753         /* can't really happen, unless the user replaces the file while the dialog is open.. */
754         if (!Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
755                 PBD::warning << string_compose(_("Could not read file: %1 (%2)."), path, strerror(errno)) << endmsg;
756                 return;
757         }
758         if (SMFSource::valid_midi_file (path)) { return; }
759
760         boost::shared_ptr<Region> r;
761         SourceList srclist;
762         boost::shared_ptr<AudioFileSource> afs;
763         bool old_sbp = AudioSource::get_build_peakfiles ();
764
765         /* don't even think of building peakfiles for these files */
766         AudioSource::set_build_peakfiles (false);
767
768         for (unsigned int n = 0; n < n_chn; ++n) {
769                 try {
770                         afs = boost::dynamic_pointer_cast<AudioFileSource> (
771                                 SourceFactory::createExternal (DataType::AUDIO, *_session,
772                                                                                  path, n,
773                                                                                  Source::Flag (ARDOUR::AudioFileSource::NoPeakFile), false));
774                         if (afs->sample_rate() != _session->nominal_frame_rate()) {
775                                 boost::shared_ptr<SrcFileSource> sfs (new SrcFileSource(*_session, afs, ARDOUR::SrcGood));
776                                 srclist.push_back(sfs);
777                         } else {
778                                 srclist.push_back(afs);
779                         }
780                 } catch (failed_constructor& err) {
781                         PBD::error << _("Could not access soundfile: ") << path << endmsg;
782                         AudioSource::set_build_peakfiles (old_sbp);
783                         return;
784                 }
785         }
786
787         AudioSource::set_build_peakfiles (old_sbp);
788
789         if (srclist.empty()) {
790                 return;
791         }
792
793         afs = boost::dynamic_pointer_cast<AudioFileSource> (srclist[0]);
794         std::string rname = region_name_from_path (afs->path(), false);
795
796         PBD::PropertyList plist;
797
798         plist.add (ARDOUR::Properties::start, 0);
799         plist.add (ARDOUR::Properties::length, srclist[0]->length(srclist[0]->timeline_position()));
800         plist.add (ARDOUR::Properties::name, rname);
801         plist.add (ARDOUR::Properties::layer, 0);
802
803         r = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (srclist, plist, false));
804
805         r->set_position(0);
806         _session->audition_region(r);
807         _audition_num = page;
808 }
809
810 void
811 ExportReport::play_audition ()
812 {
813         if (_audition_num >= 0 || !_session) { return; }
814         if (files.find (_page_num) == files.end()) { return; }
815         audition (files[_page_num].path, files[_page_num].channels, _page_num);
816 }
817
818 void
819 ExportReport::stop_audition ()
820 {
821         if (_audition_num == _page_num && timeline.find (_audition_num) != timeline.end ()) {
822                 for (std::list<CimgPlayheadArea*>::const_iterator i = timeline[_audition_num].begin();
823                                 i != timeline[_audition_num].end();
824                                 ++i) {
825                         (*i)->set_playhead (-1);
826                 }
827         }
828         if (_session) {
829                 _session->cancel_audition();
830         }
831 }
832
833 void
834 ExportReport::on_switch_page (GtkNotebookPage*, guint page_num)
835 {
836         if (_audition_num == _page_num) {
837                 for (std::list<CimgPlayheadArea*>::const_iterator i = timeline[_audition_num].begin();
838                                 i != timeline[_audition_num].end();
839                                 ++i) {
840                         (*i)->set_playhead (-1);
841                 }
842         }
843         _page_num = page_num;
844 }
845
846 void
847 ExportReport::audition_progress (framecnt_t pos, framecnt_t len)
848 {
849         if (_audition_num == _page_num && timeline.find (_audition_num) != timeline.end ()) {
850                 const float p = (float)pos / len;
851                 for (std::list<CimgPlayheadArea*>::const_iterator i = timeline[_audition_num].begin();
852                                 i != timeline[_audition_num].end();
853                                 ++i) {
854                         (*i)->set_playhead (p);
855                 }
856         }
857 }
858
859 void
860 ExportReport::audition_seek (int page, float pos)
861 {
862         if (_audition_num == page && _session) {
863                 _session->the_auditioner()->seek_to_percent (100.f * pos);
864         }
865 }
866
867 void
868 ExportReport::draw_waveform (Cairo::RefPtr<Cairo::ImageSurface>& wave, ExportAnalysisPtr p, uint32_t c, int m_l, size_t width, int anw, int height, bool log, bool rect)
869 {
870         int w, h;
871         Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (get_pango_context ());
872         const float height_2 = std::min (100, 8 * height / (int) p->n_channels); // TODO refine
873         const float ht = 2.f * height_2;
874
875         std::vector<double> dashes;
876         dashes.push_back (3.0);
877         dashes.push_back (5.0);
878
879         wave = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, m_l + width, ht);
880         Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create (wave);
881         cr->set_operator (Cairo::OPERATOR_SOURCE);
882         cr->rectangle (0, 0, m_l, ht);
883         cr->set_source_rgba (0, 0, 0, 0);
884         cr->fill ();
885         cr->rectangle (m_l, 0, width, ht);
886         cr->set_source_rgba (0, 0, 0, 1.0);
887         cr->fill ();
888         cr->set_operator (Cairo::OPERATOR_OVER);
889
890         cr->set_source_rgba (.7, .7, .7, 1.0);
891         cr->set_line_width (1.0);
892
893         // -1dB range
894         float clip_top;
895         float clip_bot;
896
897         if (rect) {
898                 clip_bot = ht;
899
900                 if (log) {
901                         clip_top = ht * (1.f - alt_log_meter (-1));
902                         for (size_t x = 0 ; x < width; ++x) {
903                                 const float v = alt_log_meter (fast_coefficient_to_dB (std::max (fabsf (p->peaks[c][x].max), fabsf (p->peaks[c][x].min))));
904                                 cr->move_to (m_l + x - .5, ht - ht * v);
905                                 cr->line_to (m_l + x - .5, ht);
906                         }
907                         cr->stroke ();
908                 } else {
909                         clip_top = ht * (1.f - dB_to_coefficient (-1));
910                         for (size_t x = 0 ; x < width; ++x) {
911                                 const float v = std::max (fabsf (p->peaks[c][x].max), fabsf (p->peaks[c][x].min));
912                                 cr->move_to (m_l + x - .5, ht - ht * v);
913                                 cr->line_to (m_l + x - .5, ht);
914                         }
915                         cr->stroke ();
916                 }
917         } else {
918                 if (log) {
919                         clip_top = height_2 - height_2 * alt_log_meter (-1);
920                         clip_bot = height_2 + height_2 * alt_log_meter (-1);
921                         for (size_t x = 0 ; x < width; ++x) {
922                                 float pmax, pmin;
923                                 if (p->peaks[c][x].max > 0) {
924                                         pmax =  alt_log_meter (fast_coefficient_to_dB (p->peaks[c][x].max));
925                                 } else {
926                                         pmax = -alt_log_meter (fast_coefficient_to_dB (-p->peaks[c][x].max));
927                                 }
928
929                                 if (p->peaks[c][x].min > 0) {
930                                         pmin =  alt_log_meter (fast_coefficient_to_dB (p->peaks[c][x].min));
931                                 } else {
932                                         pmin = -alt_log_meter (fast_coefficient_to_dB (-p->peaks[c][x].min));
933                                 }
934                                 cr->move_to (m_l + x - .5, height_2 - height_2 * pmax);
935                                 cr->line_to (m_l + x - .5, height_2 - height_2 * pmin);
936                         }
937                         cr->stroke ();
938                 } else {
939                         clip_top = height_2 - height_2 * dB_to_coefficient (-1);
940                         clip_bot = height_2 + height_2 * dB_to_coefficient (-1);
941                         for (size_t x = 0 ; x < width; ++x) {
942                                 cr->move_to (m_l + x - .5, height_2 - height_2 * p->peaks[c][x].max);
943                                 cr->line_to (m_l + x - .5, height_2 - height_2 * p->peaks[c][x].min);
944                         }
945                         cr->stroke ();
946                 }
947         }
948
949         // > 0dBFS
950         cr->set_source_rgba (1.0, 0, 0, 1.0);
951         for (size_t x = 0 ; x < width; ++x) {
952                 if (p->peaks[c][x].max >= 1.0) {
953                         cr->move_to (m_l + x - .5, 0);
954                         cr->line_to (m_l + x - .5, clip_top);
955                 }
956                 if (p->peaks[c][x].min <= -1.0) {
957                         cr->move_to (m_l + x - .5, clip_bot);
958                         cr->line_to (m_l + x - .5, ht);
959                 }
960         }
961         cr->stroke ();
962
963         // > -1dBTP
964         cr->set_source_rgba (1.0, 0.7, 0, 0.7);
965         for (std::set<framepos_t>::const_iterator i = p->truepeakpos[c].begin (); i != p->truepeakpos[c].end (); ++i) {
966                 cr->move_to (m_l + (*i) - .5, clip_top);
967                 cr->line_to (m_l + (*i) - .5, clip_bot);
968                 cr->stroke ();
969         }
970
971         if (!rect) {
972                 // zero line
973                 cr->set_source_rgba (.3, .3, .3, 0.7);
974                 cr->move_to (m_l + 0, height_2 - .5);
975                 cr->line_to (m_l + width, height_2 - .5);
976                 cr->stroke ();
977         }
978
979         // Unit
980         layout->set_font_description (UIConfiguration::instance ().get_SmallerFont ());
981         layout->set_alignment (Pango::ALIGN_LEFT);
982         layout->set_text (_("dBFS"));
983         layout->get_pixel_size (w, h);
984         cr->move_to (rint (m_l - h - anw - 10), rint (height_2 + w * .5));
985         cr->set_source_rgba (.9, .9, .9, 1.0);
986         cr->save ();
987         cr->rotate (M_PI / -2.0);
988         layout->show_in_cairo_context (cr);
989         cr->restore ();
990
991         // x-Axis
992         cr->set_line_width (1.0);
993         cr->set_dash (dashes, 2.0);
994         cr->set_line_cap (Cairo::LINE_CAP_ROUND);
995
996         layout->set_font_description (UIConfiguration::instance ().get_SmallMonospaceFont ());
997
998         if (rect) {
999                 if (log) {
1000                         XAXISLABEL ((ht - ht * alt_log_meter (-36)), _("-36"));
1001                         XAXISLABEL ((ht - ht * alt_log_meter (-18)), _("-18"));
1002                         XAXISLABEL ((ht - ht * alt_log_meter (-9)), _("-9"));
1003                         XAXISLABEL ((ht - ht * alt_log_meter (-3)), _("-3"));
1004                 } else {
1005                         XAXISLABEL ((ht - ht * .1259), _("-18"));
1006                         XAXISLABEL ((ht - ht * .3548), _("-9"));
1007                         XAXISLABEL ((ht - ht * .7079), _("-3"));
1008                 }
1009         } else {
1010                 if (log) {
1011                         XAXISLABEL ((height_2 - height_2 * alt_log_meter (-18)), _("-18"));
1012                         XAXISLABEL ((height_2 - height_2 * alt_log_meter (-9)), _("-9"));
1013                         XAXISLABEL ((height_2 - height_2 * alt_log_meter (-3)), _("-3"));
1014                         XAXISLABEL ((height_2 + height_2 * alt_log_meter (-18)), _("-18"));
1015                         XAXISLABEL ((height_2 + height_2 * alt_log_meter (-9)), _("-9"));
1016                         XAXISLABEL ((height_2 + height_2 * alt_log_meter (-3)), _("-3"));
1017                 } else {
1018                         XAXISLABEL (height_2 * 0.6452, _("-9"));
1019                         XAXISLABEL (height_2 * 1.3548, _("-9"));
1020                         XAXISLABEL (height_2 * 0.2921, _("-3"));
1021                         XAXISLABEL (height_2 * 1.7079, _("-3"));
1022                 }
1023         }
1024         wave->flush ();
1025 }