From 5ada2b7ce173be75b8520cdec3fd5b1f74cec22f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 9 Dec 2021 21:44:23 -0700 Subject: [PATCH] audio clip editor: draw waveforms (not sized horizonally appropriately yet) --- gtk2_ardour/audio_clip_editor.cc | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/audio_clip_editor.cc b/gtk2_ardour/audio_clip_editor.cc index 69a573f2bf..36f771be4b 100644 --- a/gtk2_ardour/audio_clip_editor.cc +++ b/gtk2_ardour/audio_clip_editor.cc @@ -64,7 +64,7 @@ AudioClipEditor::AudioClipEditor () frame = new Rectangle (root()); frame->name = "audio clip editor frame"; - frame->set_fill_color (UIConfiguration::instance().color (X_("theme:contrasting"))); + frame->set_fill (false); frame->set_outline_color (UIConfiguration::instance().color (X_("theme:darkest"))); frame->Event.connect (sigc::mem_fun (*this, &AudioClipEditor::event_handler)); } @@ -92,16 +92,15 @@ AudioClipEditor::set_region (boost::shared_ptr r) uint32_t n_chans = r->n_channels (); for (uint32_t n = 0; n < n_chans; ++n) { - WaveView* wv = new WaveView (this, r); + WaveView* wv = new WaveView (frame, r); wv->set_channel (n); waves.push_back (wv); } - int h = get_allocation().get_height (); + std::cerr << "Now have " << waves.size() << " waves" << std::endl; - if (h) { - set_wave_heights (h); - } + set_wave_heights (frame->get().height() - 2.0); + set_waveform_colors (); } void @@ -125,12 +124,15 @@ AudioClipEditor::set_wave_heights (int h) uint32_t n = 0; Distance ht = h / waves.size(); + std::cerr << "wave heights: " << ht << std::endl; + for (auto & wave : waves) { wave->set_height (ht); wave->set_y_position (n * ht); - wave->set_samples_per_pixel (8192); + wave->set_samples_per_pixel (256); wave->set_show_zero_line (false); wave->set_clip_level (1.0); + ++n; } } @@ -191,11 +193,18 @@ AudioClipEditorBox::~AudioClipEditorBox () void AudioClipEditorBox::set_region (boost::shared_ptr r) { + boost::shared_ptr ar = boost::dynamic_pointer_cast (r); + + if (!ar) { + return; + } + set_session(&r->session()); state_connection.disconnect(); _region = r; + editor->set_region (ar); PBD::PropertyChange interesting_stuff; region_changed(interesting_stuff);