From d0792a7721b4588380ebcb77f9ae1bf47f274661 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 24 Dec 2021 19:49:09 +0100 Subject: [PATCH] Update Export Graph rendering for variable size --- gtk2_ardour/export_analysis_graphs.cc | 9 ++++----- gtk2_ardour/export_report.cc | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/gtk2_ardour/export_analysis_graphs.cc b/gtk2_ardour/export_analysis_graphs.cc index 93b1083f44..97190260f4 100644 --- a/gtk2_ardour/export_analysis_graphs.cc +++ b/gtk2_ardour/export_analysis_graphs.cc @@ -52,7 +52,7 @@ ArdourGraphs::draw_waveform (Glib::RefPtr pctx, ExportAnalysisPt { int w, h, anw; const float ht = 2.f * height_2; - const size_t width = sizeof (p->peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4; + const size_t width = p->width; std::vector dashes; dashes.push_back (3.0); dashes.push_back (5.0); @@ -241,10 +241,9 @@ Cairo::RefPtr ArdourGraphs::draw_spectrum (Glib::RefPtr pctx, ExportAnalysisPtr p, int height, int m_l) { int w, h, anw; - const size_t swh = sizeof (p->spectrum) / sizeof (float); - const size_t width = swh / height; + const size_t width = p->width; - assert (height == sizeof (p->spectrum[0]) / sizeof (float)); + assert (height == p->spectrum[0].size ()); std::vector dashes; dashes.push_back (3.0); @@ -536,7 +535,7 @@ ArdourGraphs::plot_loudness (Glib::RefPtr pctx, ExportAnalysisPt layout->set_text ("00:00:00.0"); layout->get_pixel_size (w, h); - const size_t width = sizeof (p->lgraph_i) / sizeof (float); // 800 + const size_t width = p->width; const int n_labels = width / (w * 1.75); if (height < 0) { diff --git a/gtk2_ardour/export_report.cc b/gtk2_ardour/export_report.cc index 584e7b5880..a6b13dd771 100644 --- a/gtk2_ardour/export_report.cc +++ b/gtk2_ardour/export_report.cc @@ -102,6 +102,8 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) std::string path = i->first; ExportAnalysisPtr p = i->second; + const size_t p_width = p->width; + std::list playhead_widgets; if (with_file) { @@ -246,14 +248,14 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) const int ht = lin[0] * 1.25 + lin[1] * 1.25 + lin[2] * 1.25 + lin[3] *1.25 + lin[4] * 1.25 + lin[5]; const int hh = std::max (100, ht + 12); const int htn = lin[0] * 1.25 + lin[1] * 1.25 + lin[2] * 1.25 + lin[3]; - int m_l = 2 * mnw + /*hist-width*/ 540 + /*box spacing*/ 8 - /*peak-width*/ 800 - m_r; // margin left + int m_l = 2 * mnw + /*hist-width*/ 540 + /*box spacing*/ 8 - /*peak-width*/ p_width - m_r; // margin left int mml = 0; // min margin left -- ensure left margin is wide enough TXTWIDTH (_("Time"), get_SmallFont); TXTWIDTH (_("100"), get_SmallMonospaceFont); m_l = (std::max(anw + mnh + 14, std::max (m_l, mml + 8)) + 3) & ~3; - mnw = (m_l - /*hist-width*/ 540 - /*box spacing*/ 8 + /*peak-width*/ 800 + m_r) / 2; + mnw = (m_l - /*hist-width*/ 540 - /*box spacing*/ 8 + /*peak-width*/ p_width + m_r) / 2; const int nw2 = mnw / 2; // nums, horizontal center int y0[6]; @@ -269,7 +271,7 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) y0[5] = y0[4] + lin[4] * 1.25; /* calc heights & alignment of png-image */ - const float specth = sizeof (p->spectrum[0]) / sizeof (float); + const float specth = p->spectrum[0].size (); const float waveh2 = std::min (100, 8 * lin[0] / (int) p->n_channels); const float loudnh = 180; @@ -290,8 +292,8 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) 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; + const int wav_w = m_l + m_r + 4 + p->width; + const int spc_w = m_l + m_r + 4 + p->width / specth; int ann_h = 0; int linesp = 0; @@ -569,7 +571,7 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) for (uint32_t c = 0; c < p->n_channels; ++c) { /* draw waveform */ - const size_t width = sizeof (p->peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4; + const size_t width = p->width; Cairo::RefPtr wave = ArdourGraphs::draw_waveform (get_pango_context (), p, c, waveh2, m_l, false, false); Cairo::RefPtr wave_log = ArdourGraphs::draw_waveform (get_pango_context (), p, c, waveh2, m_l, true, false); @@ -596,7 +598,7 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) if (channels > 0 && file_length > 0 && sample_rate > 0) { /* Time Axis -- re-use waveform width */ - const size_t width = sizeof (p->peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4; + const size_t width = p->width; Cairo::RefPtr ytme = ArdourGraphs::time_axis (get_pango_context (), width, m_l, start_off, file_length, sample_rate); CimgPlayheadArea *tm = manage (new CimgPlayheadArea (ytme, m_l, width, true)); @@ -706,9 +708,9 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) max_wx = std::max (max_wx, w); /* calc geometry of conformity analysis, add 1/2 max_wx space */ - int max_w = std::min (800, max_wl + max_wx * 1.5); + int max_w = std::min (p_width, max_wl + max_wx * 1.5); - int per_line = std::min (5, 800 / max_w); + int per_line = std::min (5, p_width / max_w); assert (per_line > 0); int lines = ceilf ((float)n_reports / per_line); @@ -727,7 +729,7 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) ++i; } - int cw = 800 + m_l; + int cw = p_width + m_l; int ch = (lines * 1.3 + .65) * lin[0]; Cairo::RefPtr conf = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, cw, ch);