X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Faudio_streamview.cc;h=969e439cfd1168173a21667cfb86cc046438f53b;hb=refs%2Fheads%2Fcarl-master;hp=7b84219b750883553a5cc375bb6e329b91b79006;hpb=0cca2724311b8df9989dc46efad12bdbe05c3883;p=ardour.git diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 7b84219b75..969e439cfd 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -1,20 +1,25 @@ /* - Copyright (C) 2001, 2006 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * Copyright (C) 2006-2014 David Robillard + * Copyright (C) 2007-2012 Carl Hetherington + * Copyright (C) 2007-2017 Paul Davis + * Copyright (C) 2007 Doug McLain + * Copyright (C) 2014-2017 Robin Gareus + * Copyright (C) 2015-2016 Nick Mainsbridge + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ #include #include @@ -29,6 +34,7 @@ #include "ardour/audioregion.h" #include "ardour/audiofilesource.h" #include "ardour/audio_track.h" +#include "ardour/record_enable_control.h" #include "ardour/region_factory.h" #include "ardour/profile.h" #include "ardour/rc_configuration.h" @@ -41,14 +47,14 @@ #include "tape_region_view.h" #include "audio_time_axis.h" #include "region_selection.h" +#include "region_gain_line.h" #include "selection.h" #include "public_editor.h" -#include "ardour_ui.h" #include "rgb_macros.h" #include "gui_thread.h" -#include "utils.h" +#include "ui_config.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -110,15 +116,15 @@ AudioStreamView::create_region_view (boost::shared_ptr r, bool wait_for_ break; case Destructive: region_view = new TapeAudioRegionView (_canvas_group, _trackview, region, - _samples_per_pixel, region_color); + _samples_per_pixel, region_color); break; default: - fatal << string_compose (_("programming error: %1"), "illegal track mode in ::add_region_view_internal") << endmsg; - /*NOTREACHED*/ + fatal << string_compose (_("programming error: %1"), "illegal track mode in ::create_region_view()") << endmsg; + abort(); /*NOTREACHED*/ } - region_view->init (region_color, wait_for_waves); + region_view->init (wait_for_waves); region_view->set_amplitude_above_axis(_amplitude_above_axis); region_view->set_height (child_height ()); @@ -142,35 +148,8 @@ AudioStreamView::add_region_view_internal (boost::shared_ptr r, bool wai return 0; } -// if(!recording){ -// for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { -// if ((*i)->region() == r) { -// cerr << "audio_streamview in add_region_view_internal region found" << endl; - /* great. we already have a AudioRegionView for this Region. use it again. */ - -// (*i)->set_valid (true); - - // this might not be necessary -// AudioRegionView* const arv = dynamic_cast(*i); - -// if (arv) { -// arv->set_waveform_scale (_waveform_scale); -// arv->set_waveform_shape (_waveform_shape); -// } - -// return NULL; -// } -// } -// } - region_views.push_front (region_view); - if (_trackview.editor().internal_editing()) { - region_view->hide_rect (); - } else { - region_view->show_rect (); - } - /* catch region going away */ r->DropReferences.connect (*this, invalidator (*this), boost::bind (&AudioStreamView::remove_region_view, this, boost::weak_ptr (r)), gui_context()); @@ -207,14 +186,14 @@ AudioStreamView::setup_rec_box () { //cerr << _trackview.name() << " streamview SRB region_views.size() = " << region_views.size() << endl; - if (_trackview.session()->transport_rolling()) { + if (!_trackview.session()->transport_stopped()) { // cerr << "\trolling\n"; if (!rec_active && _trackview.session()->record_status() == Session::Recording && - _trackview.track()->record_enabled()) { - if (_trackview.audio_track()->mode() == Normal && Config->get_show_waveforms_while_recording() && rec_regions.size() == rec_rects.size()) { + _trackview.track()->rec_enable_control()->get_value()) { + if (_trackview.audio_track()->mode() == Normal && UIConfiguration::instance().get_show_waveforms_while_recording() && rec_regions.size() == rec_rects.size()) { /* add a new region, but don't bother if they set show-waveforms-while-recording mid-record */ @@ -236,10 +215,10 @@ AudioStreamView::setup_rec_box () // handle multi - framepos_t start = 0; + samplepos_t start = 0; if (rec_regions.size() > 0) { start = rec_regions.back().first->start() - + _trackview.track()->get_captured_frames(rec_regions.size()-1); + + _trackview.track()->get_captured_samples(rec_regions.size()-1); } PropertyList plist; @@ -253,63 +232,21 @@ AudioStreamView::setup_rec_box () boost::dynamic_pointer_cast(RegionFactory::create (sources, plist, false))); assert(region); - region->set_position (_trackview.session()->transport_frame()); + region->set_position (_trackview.session()->transport_sample()); rec_regions.push_back (make_pair(region, (RegionView*) 0)); } /* start a new rec box */ - boost::shared_ptr at; - - at = _trackview.audio_track(); /* we know what it is already */ - framepos_t const frame_pos = at->current_capture_start (); - gdouble xstart = _trackview.editor().sample_to_pixel (frame_pos); - gdouble xend = xstart; /* keeps gcc optimized happy, really set in switch() below */ - uint32_t fill_color; - - switch (_trackview.audio_track()->mode()) { - case Normal: - case NonLayered: - xend = xstart; - fill_color = ARDOUR_UI::config()->get_canvasvar_RecordingRect(); - break; - - case Destructive: - xend = xstart + 2; - fill_color = ARDOUR_UI::config()->get_canvasvar_RecordingRect(); - /* make the recording rect translucent to allow - the user to see the peak data coming in, etc. - */ - fill_color = UINT_RGBA_CHANGE_A (fill_color, 120); - break; - } - - ArdourCanvas::Rectangle * rec_rect = new ArdourCanvas::Rectangle (_canvas_group); - rec_rect->set_x0 (xstart); - rec_rect->set_y0 (1); - rec_rect->set_x1 (xend); - rec_rect->set_y1 (child_height ()); - rec_rect->set_outline_what (0); - rec_rect->set_outline_color (ARDOUR_UI::config()->get_canvasvar_TimeAxisFrame()); - rec_rect->set_fill_color (fill_color); - rec_rect->lower_to_bottom(); - - RecBoxInfo recbox; - recbox.rectangle = rec_rect; - recbox.start = _trackview.session()->transport_frame(); - recbox.length = 0; + boost::shared_ptr at = _trackview.audio_track(); + samplepos_t const sample_pos = at->current_capture_start (); + double const width = ((at->mode() == Destructive) ? 2 : 0); - rec_rects.push_back (recbox); - - screen_update_connection.disconnect(); - screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect ( - sigc::mem_fun (*this, &AudioStreamView::update_rec_box)); - rec_updating = true; - rec_active = true; + create_rec_box(sample_pos, width); } else if (rec_active && - (_trackview.session()->record_status() != Session::Recording || - !_trackview.track()->record_enabled())) { + (_trackview.session()->record_status() != Session::Recording || + !_trackview.track()->rec_enable_control()->get_value())) { screen_update_connection.disconnect(); rec_active = false; rec_updating = false; @@ -357,7 +294,7 @@ AudioStreamView::setup_rec_box () } void -AudioStreamView::rec_peak_range_ready (framepos_t start, framecnt_t cnt, boost::weak_ptr weak_src) +AudioStreamView::rec_peak_range_ready (samplepos_t start, samplecnt_t cnt, boost::weak_ptr weak_src) { ENSURE_GUI_THREAD (*this, &AudioStreamView::rec_peak_range_ready, start, cnt, weak_src) @@ -369,8 +306,8 @@ AudioStreamView::rec_peak_range_ready (framepos_t start, framecnt_t cnt, boost:: // this is called from the peak building thread - if (rec_data_ready_map.size() == 0 || start + cnt > last_rec_data_frame) { - last_rec_data_frame = start + cnt; + if (rec_data_ready_map.size() == 0 || start + cnt > last_rec_data_sample) { + last_rec_data_sample = start + cnt; } rec_data_ready_map[src] = true; @@ -382,9 +319,9 @@ AudioStreamView::rec_peak_range_ready (framepos_t start, framecnt_t cnt, boost:: } void -AudioStreamView::update_rec_regions (framepos_t start, framecnt_t cnt) +AudioStreamView::update_rec_regions (samplepos_t start, samplecnt_t cnt) { - if (!Config->get_show_waveforms_while_recording ()) { + if (!UIConfiguration::instance().get_show_waveforms_while_recording ()) { return; } @@ -410,19 +347,20 @@ AudioStreamView::update_rec_regions (framepos_t start, framecnt_t cnt) continue; } - framecnt_t origlen = region->length(); + samplecnt_t origlen = region->length(); if (region == rec_regions.back().first && rec_active) { - if (last_rec_data_frame > region->start()) { + if (last_rec_data_sample > region->start()) { - framecnt_t nlen = last_rec_data_frame - region->start(); + samplecnt_t nlen = last_rec_data_sample - region->start(); if (nlen != region->length()) { region->suspend_property_changes (); - region->set_position (_trackview.track()->get_capture_start_frame(n)); - region->set_length (nlen); + /* set non-musical position / length */ + region->set_position (_trackview.track()->get_capture_start_sample(n)); + region->set_length (nlen, 0); region->resume_property_changes (); if (origlen == 1) { @@ -441,15 +379,15 @@ AudioStreamView::update_rec_regions (framepos_t start, framecnt_t cnt) } else { - framecnt_t nlen = _trackview.track()->get_captured_frames(n); + samplecnt_t nlen = _trackview.track()->get_captured_samples(n); if (nlen != region->length()) { if (region->source_length(0) >= region->start() + nlen) { region->suspend_property_changes (); - region->set_position (_trackview.track()->get_capture_start_frame(n)); - region->set_length (nlen); + region->set_position (_trackview.track()->get_capture_start_sample(n)); + region->set_length (nlen, 0); region->resume_property_changes (); if (origlen == 1) { @@ -501,11 +439,11 @@ AudioStreamView::hide_xfades_with (boost::shared_ptr ar) { list start_hidden; list end_hidden; - + for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { AudioRegionView* const arv = dynamic_cast(*i); if (arv) { - switch (arv->region()->coverage (ar->position(), ar->last_frame())) { + switch (arv->region()->coverage (ar->position(), ar->last_sample())) { case Evoral::OverlapNone: break; default: @@ -529,15 +467,22 @@ AudioStreamView::color_handler () { //case cAudioTrackBase: if (_trackview.is_track()) { - canvas_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_AudioTrackBase()); + canvas_rect->set_fill_color (UIConfiguration::instance().color_mod ("audio track base", "audio track base")); } //case cAudioBusBase: if (!_trackview.is_track()) { - if (Profile->get_sae() && _trackview.route()->is_master()) { - canvas_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_AudioMasterBusBase()); - } else { - canvas_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_AudioBusBase()); + canvas_rect->set_fill_color (UIConfiguration::instance().color_mod ("audio bus base", "audio bus base")); + } +} + +void +AudioStreamView::set_selected_points (PointSelection& points) +{ + for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { + AudioRegionView* const arv = dynamic_cast(*i); + if (arv && arv->get_gain_line ()) { + arv->get_gain_line ()->set_selected_points (points); } } }