+ /* calc heights & alignment of png-image */
+ const float specth = sizeof (p->spectrum[0]) / sizeof (float);
+ const float waveh2 = std::min (100, 8 * lin[0] / (int) p->n_channels);
+
+ Cairo::RefPtr<Cairo::ImageSurface> png_surface;
+ int png_w = 0;
+ int png_y0 = 0;
+
+ if (with_file && UIConfiguration::instance().get_save_export_analysis_image ()) { /*png image */
+ const int top_w = 540 + 2 * (mnw + 4); // 4px spacing
+ const int wav_w = m_l + m_r + 4 + sizeof (p->peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4;
+ const int spc_w = m_l + m_r + 4 + sizeof (p->spectrum) / sizeof (float) / specth;
+ int ann_h = 0;
+ int linesp = 0;
+
+ if (channels > 0 && file_length > 0 && sample_rate > 0) {
+ layout->set_font_description (UIConfiguration::instance ().get_SmallMonospaceFont ());
+ layout->set_text (_("00:00:00.000"));
+ layout->get_pixel_size (w, h);
+ int height = h * 1.75;
+ ann_h = 4 + height /* Time Axis */;
+
+ layout->set_font_description (UIConfiguration::instance ().get_SmallFont ());
+ layout->set_text (_("0|A8"));
+ layout->get_pixel_size (w, h);
+ linesp = h * 1.5;
+ ann_h += 4 + 3 * linesp; /* File Info */;
+ }
+
+ const int png_h = hh + 4 + p->n_channels * (2 * waveh2 + 4) + ann_h + specth + 4;
+ png_w = std::max (std::max (top_w, wav_w), spc_w);
+
+ png_surface = Cairo::ImageSurface::create (Cairo::FORMAT_RGB24, png_w, png_h);
+ Cairo::RefPtr<Cairo::Context> pcx = Cairo::Context::create (png_surface);
+ pcx->set_source_rgb (.2, .2, .2);
+ pcx->paint ();
+
+ if (channels > 0 && file_length > 0 && sample_rate > 0) {
+ png_y0 += 4;
+ // Add file-name, format, duration, sample-rate & timecode
+ pcx->set_source_rgb (.7, .7, .7);
+ layout->set_font_description (UIConfiguration::instance ().get_SmallFont ());
+ layout->set_alignment (Pango::ALIGN_LEFT);
+
+#define IMGLABEL(X0, STR, VAL) { \
+ layout->set_text (STR); \
+ pcx->move_to (X0, png_y0); \
+ layout->get_pixel_size (w, h); \
+ layout->show_in_cairo_context (pcx); \
+ layout->set_text (VAL); \
+ pcx->move_to (X0 + w + 2, png_y0); \
+ layout->show_in_cairo_context (pcx); \
+}
+
+ // TODO get max width of labels per column, right-align labels, x-align 1/3, 2/3 columns
+ const int lx0 = m_l;
+ const int lx1 = m_l + png_w * 2 / 3; // right-col is short (channels, SR, duration)
+ std::string sha1sum = ARDOUR::compute_sha1_of_file (path);
+ if (!sha1sum.empty()) {
+ sha1sum = " (sha1: " + sha1sum + ")";
+ }
+
+ IMGLABEL (lx0, _("File:"), Glib::path_get_basename (path) + sha1sum);
+ IMGLABEL (lx1, _("Channels:"), string_compose ("%1", channels));
+ png_y0 += linesp;
+
+ IMGLABEL (lx0, _("Format:"), file_fmt);
+ IMGLABEL (lx1, _("Sample rate:"), string_compose (_("%1 Hz"), sample_rate));
+ png_y0 += linesp;
+
+ if (_session) {
+ Timecode::Time tct;
+ _session->sample_to_timecode (start_off, tct, false, false);
+ IMGLABEL (lx0, _("Timecode:"), Timecode::timecode_format_time (tct));
+ }
+ IMGLABEL (lx1, _("Duration:"), Timecode::timecode_format_sampletime (file_length, sample_rate, 1000, false));
+ png_y0 += linesp;
+ }
+ }