2006-07-23 08:03:19 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2001-2007 Paul Davis
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <cassert>
|
2007-05-31 17:37:20 -04:00
|
|
|
#include <utility>
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
#include <gtkmm.h>
|
|
|
|
|
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/midi_diskstream.h"
|
|
|
|
#include "ardour/midi_playlist.h"
|
|
|
|
#include "ardour/midi_region.h"
|
|
|
|
#include "ardour/midi_source.h"
|
|
|
|
#include "ardour/midi_track.h"
|
|
|
|
#include "ardour/region_factory.h"
|
|
|
|
#include "ardour/smf_source.h"
|
2009-10-30 11:30:22 -04:00
|
|
|
#include "ardour/session.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-02-15 14:44:27 -05:00
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "canvas-simplerect.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "lineset.h"
|
2006-08-14 04:44:14 -04:00
|
|
|
#include "midi_region_view.h"
|
2009-02-15 14:44:27 -05:00
|
|
|
#include "midi_streamview.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "midi_time_axis.h"
|
2009-02-15 14:44:27 -05:00
|
|
|
#include "midi_util.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "public_editor.h"
|
2009-02-15 14:44:27 -05:00
|
|
|
#include "region_selection.h"
|
|
|
|
#include "region_view.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "rgb_macros.h"
|
2009-02-15 14:44:27 -05:00
|
|
|
#include "selection.h"
|
2007-06-01 19:27:29 -04:00
|
|
|
#include "simplerect.h"
|
2009-02-15 14:44:27 -05:00
|
|
|
#include "utils.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
using namespace std;
|
2006-07-23 08:03:19 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Editing;
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
MidiStreamView::MidiStreamView (MidiTimeAxisView& tv)
|
2006-07-23 08:03:19 -04:00
|
|
|
: StreamView (tv)
|
2008-01-13 12:45:17 -05:00
|
|
|
, note_range_adjustment(0.0f, 0.0f, 0.0f)
|
2008-09-22 22:40:29 -04:00
|
|
|
, _range_dirty(false)
|
2008-01-13 12:45:17 -05:00
|
|
|
, _range_sum_cache(-1.0)
|
2007-07-14 21:56:11 -04:00
|
|
|
, _lowest_note(60)
|
2008-09-22 22:40:29 -04:00
|
|
|
, _highest_note(71)
|
|
|
|
, _data_note_min(60)
|
|
|
|
, _data_note_max(71)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2009-07-09 13:58:13 -04:00
|
|
|
if (tv.is_track()) {
|
2007-06-29 13:13:09 -04:00
|
|
|
stream_base_color = ARDOUR_UI::config()->canvasvar_MidiTrackBase.get();
|
2009-02-15 14:44:27 -05:00
|
|
|
} else {
|
2007-06-29 13:13:09 -04:00
|
|
|
stream_base_color = ARDOUR_UI::config()->canvasvar_MidiBusBase.get();
|
2009-02-15 14:44:27 -05:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
use_rec_regions = tv.editor().show_waveforms_recording ();
|
2008-01-13 12:45:17 -05:00
|
|
|
|
2008-02-10 13:16:25 -05:00
|
|
|
/* use a group dedicated to MIDI underlays. Audio underlays are not in this group. */
|
|
|
|
midi_underlay_group = new ArdourCanvas::Group (*canvas_group);
|
|
|
|
midi_underlay_group->lower_to_bottom();
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
/* put the note lines in the timeaxisview's group, so it
|
2008-02-10 13:16:25 -05:00
|
|
|
can be put below ghost regions from MIDI underlays*/
|
2008-09-24 15:39:01 -04:00
|
|
|
_note_lines = new ArdourCanvas::LineSet(*canvas_group, ArdourCanvas::LineSet::Horizontal);
|
2008-01-13 12:45:17 -05:00
|
|
|
|
|
|
|
_note_lines->property_x1() = 0;
|
|
|
|
_note_lines->property_y1() = 0;
|
2009-07-09 13:58:13 -04:00
|
|
|
_note_lines->property_x2() = trackview().editor().frame_to_pixel (max_frames);
|
2008-01-13 12:45:17 -05:00
|
|
|
_note_lines->property_y2() = 0;
|
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
_note_lines->signal_event().connect(sigc::bind(
|
|
|
|
sigc::mem_fun(_trackview.editor(), &PublicEditor::canvas_stream_view_event),
|
2009-07-09 13:58:13 -04:00
|
|
|
_note_lines, &_trackview));
|
2009-02-15 14:44:27 -05:00
|
|
|
|
2008-02-10 13:16:25 -05:00
|
|
|
_note_lines->lower_to_bottom();
|
2008-01-13 12:45:17 -05:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
ColorsChanged.connect(sigc::mem_fun(*this, &MidiStreamView::draw_note_lines));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
note_range_adjustment.set_page_size(_highest_note - _lowest_note);
|
|
|
|
note_range_adjustment.set_value(_lowest_note);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-02-15 14:44:27 -05:00
|
|
|
note_range_adjustment.signal_value_changed().connect(
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::mem_fun(*this, &MidiStreamView::note_range_adjustment_changed));
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MidiStreamView::~MidiStreamView ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
static void
|
|
|
|
veto_note_range(uint8_t& min, uint8_t& max)
|
|
|
|
{
|
|
|
|
/* Legal notes, thanks */
|
2009-02-15 14:44:27 -05:00
|
|
|
clamp_to_0_127(min);
|
|
|
|
clamp_to_0_127(max);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
/* Always display at least one octave in [0, 127] */
|
|
|
|
if (max == 127) {
|
|
|
|
if (min > (127 - 11)) {
|
|
|
|
min = 127 - 11;
|
|
|
|
}
|
|
|
|
} else if (max < min + 11) {
|
|
|
|
uint8_t d = 11 - (max - min);
|
|
|
|
if (max + d/2 > 127) {
|
|
|
|
min -= d;
|
|
|
|
} else {
|
|
|
|
min -= d / 2;
|
|
|
|
max += d / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(max - min >= 11);
|
2009-02-19 13:10:50 -05:00
|
|
|
assert(max <= 127);
|
|
|
|
assert(min <= 127);
|
2008-09-22 22:40:29 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
RegionView*
|
2009-07-21 11:55:17 -04:00
|
|
|
MidiStreamView::create_region_view (boost::shared_ptr<Region> r, bool /*wfd*/, bool)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<MidiRegion> region = boost::dynamic_pointer_cast<MidiRegion> (r);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
if (region == 0) {
|
2009-06-08 15:28:51 -04:00
|
|
|
return 0;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
RegionView* region_view = new MidiRegionView (canvas_group, _trackview, region,
|
2009-06-08 15:28:51 -04:00
|
|
|
_samples_per_unit, region_color);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
region_view->init (region_color, false);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
return region_view;
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
RegionView*
|
|
|
|
MidiStreamView::add_region_view_internal (boost::shared_ptr<Region> r, bool wfd, bool recording)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<MidiRegion> region = boost::dynamic_pointer_cast<MidiRegion> (r);
|
|
|
|
|
|
|
|
if (region == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
if ((*i)->region() == r) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* great. we already have a MidiRegionView for this Region. use it again. */
|
|
|
|
|
|
|
|
(*i)->set_valid (true);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-08-02 17:08:18 -04:00
|
|
|
display_region(dynamic_cast<MidiRegionView*>(*i), wfd);
|
2007-07-05 03:02:24 -04:00
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
return 0;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
2009-06-08 15:28:51 -04:00
|
|
|
|
|
|
|
MidiRegionView* region_view = dynamic_cast<MidiRegionView*> (create_region_view (r, wfd, recording));
|
|
|
|
if (region_view == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
region_views.push_front (region_view);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-07-05 03:02:24 -04:00
|
|
|
/* display events and find note range */
|
2009-06-08 15:28:51 -04:00
|
|
|
display_region (region_view, wfd);
|
2007-07-05 03:02:24 -04:00
|
|
|
|
2007-06-01 19:27:29 -04:00
|
|
|
/* catch regionview going away */
|
2009-12-22 15:21:43 -05:00
|
|
|
region->DropReferences.connect (*this, boost::bind (&MidiStreamView::remove_region_view, this, region), gui_context());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionViewAdded (region_view);
|
2007-05-31 17:37:20 -04:00
|
|
|
|
|
|
|
return region_view;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2007-07-05 03:02:24 -04:00
|
|
|
void
|
2007-08-02 17:08:18 -04:00
|
|
|
MidiStreamView::display_region(MidiRegionView* region_view, bool load_model)
|
2007-07-05 03:02:24 -04:00
|
|
|
{
|
|
|
|
if ( ! region_view)
|
|
|
|
return;
|
2009-02-15 14:44:27 -05:00
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
region_view->enable_display(true);
|
2007-07-05 03:02:24 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<MidiSource> source(region_view->midi_region()->midi_source(0));
|
2007-08-02 17:08:18 -04:00
|
|
|
|
2009-01-27 23:55:31 -05:00
|
|
|
if (load_model) {
|
2007-08-02 17:08:18 -04:00
|
|
|
source->load_model();
|
2009-01-27 23:55:31 -05:00
|
|
|
}
|
2007-07-05 03:02:24 -04:00
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
_range_dirty = update_data_note_range(
|
|
|
|
source->model()->lowest_note(),
|
|
|
|
source->model()->highest_note());
|
|
|
|
|
2007-07-30 22:16:46 -04:00
|
|
|
// Display region contents
|
2009-02-15 14:44:27 -05:00
|
|
|
region_view->set_height(height);
|
2007-07-30 22:16:46 -04:00
|
|
|
region_view->display_model(source->model());
|
2007-07-05 03:02:24 -04:00
|
|
|
}
|
|
|
|
|
2007-08-04 00:18:34 -04:00
|
|
|
void
|
|
|
|
MidiStreamView::display_diskstream (boost::shared_ptr<Diskstream> ds)
|
|
|
|
{
|
|
|
|
StreamView::display_diskstream(ds);
|
2008-01-13 12:45:17 -05:00
|
|
|
draw_note_lines();
|
|
|
|
NoteRangeChanged();
|
2007-08-04 00:18:34 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-02-15 14:44:27 -05:00
|
|
|
void
|
|
|
|
MidiStreamView::update_contents_metrics(boost::shared_ptr<Region> r)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(r);
|
|
|
|
if (mr) {
|
|
|
|
mr->midi_source(0)->load_model();
|
|
|
|
_range_dirty = update_data_note_range(
|
|
|
|
mr->model()->lowest_note(),
|
|
|
|
mr->model()->highest_note());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
bool
|
|
|
|
MidiStreamView::update_data_note_range(uint8_t min, uint8_t max)
|
|
|
|
{
|
|
|
|
bool dirty = false;
|
|
|
|
if (min < _data_note_min) {
|
|
|
|
_data_note_min = min;
|
|
|
|
dirty = true;
|
|
|
|
}
|
|
|
|
if (max > _data_note_max) {
|
|
|
|
_data_note_max = max;
|
|
|
|
dirty = true;
|
|
|
|
}
|
|
|
|
return dirty;
|
|
|
|
}
|
2007-08-04 00:18:34 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
void
|
|
|
|
MidiStreamView::redisplay_diskstream ()
|
|
|
|
{
|
2009-07-09 13:58:13 -04:00
|
|
|
if (!_trackview.is_midi_track()) {
|
2009-02-15 14:44:27 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-15 15:31:05 -05:00
|
|
|
list<RegionView*>::iterator i;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-02-15 14:44:27 -05:00
|
|
|
// Load models if necessary, and find note range of all our contents
|
2008-09-22 22:40:29 -04:00
|
|
|
_range_dirty = false;
|
|
|
|
_data_note_min = 127;
|
|
|
|
_data_note_max = 0;
|
2009-07-09 13:58:13 -04:00
|
|
|
_trackview.get_diskstream()->playlist()->foreach_region(
|
2009-06-02 20:23:34 -04:00
|
|
|
sigc::mem_fun (*this, &StreamView::update_contents_metrics)
|
|
|
|
);
|
2008-09-22 22:40:29 -04:00
|
|
|
|
|
|
|
// No notes, use default range
|
|
|
|
if (!_range_dirty) {
|
|
|
|
_data_note_min = 60;
|
|
|
|
_data_note_max = 71;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
// Extend visible range to show newly recorded data, if necessary
|
2009-02-15 14:44:27 -05:00
|
|
|
_lowest_note = std::min(_lowest_note, _data_note_min);
|
|
|
|
_highest_note = std::max(_highest_note, _data_note_max);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
veto_note_range(_lowest_note, _highest_note);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-02-15 14:44:27 -05:00
|
|
|
// Flag region views as invalid and disable drawing
|
|
|
|
for (i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
(*i)->set_valid(false);
|
|
|
|
(*i)->enable_display(false);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2007-08-06 02:09:41 -04:00
|
|
|
|
2009-02-15 15:31:05 -05:00
|
|
|
// Add and display region views, and flag them as valid
|
2009-07-09 13:58:13 -04:00
|
|
|
_trackview.get_diskstream()->playlist()->foreach_region(
|
2009-06-08 15:28:51 -04:00
|
|
|
sigc::hide_return (sigc::mem_fun (*this, &StreamView::add_region_view))
|
2009-06-02 20:23:34 -04:00
|
|
|
);
|
2009-02-15 14:44:27 -05:00
|
|
|
|
2009-02-15 15:31:05 -05:00
|
|
|
// Stack regions by layer, and remove invalid regions
|
|
|
|
layer_regions();
|
2008-09-14 14:08:58 -04:00
|
|
|
|
2009-02-15 15:31:05 -05:00
|
|
|
// Update note range (not regions which are correct) and draw note lines
|
2009-02-15 14:44:27 -05:00
|
|
|
apply_note_range(_lowest_note, _highest_note, false);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2007-08-04 00:18:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
void
|
2008-09-19 15:32:10 -04:00
|
|
|
MidiStreamView::update_contents_height ()
|
2007-08-04 00:18:34 -04:00
|
|
|
{
|
2008-09-19 15:32:10 -04:00
|
|
|
StreamView::update_contents_height();
|
2008-01-13 12:45:17 -05:00
|
|
|
_note_lines->property_y2() = height;
|
|
|
|
draw_note_lines();
|
2007-08-04 00:18:34 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-08-04 00:18:34 -04:00
|
|
|
void
|
2008-01-13 12:45:17 -05:00
|
|
|
MidiStreamView::draw_note_lines()
|
2007-08-04 00:18:34 -04:00
|
|
|
{
|
2008-01-13 12:45:17 -05:00
|
|
|
double y;
|
|
|
|
double prev_y = contents_height();
|
|
|
|
uint32_t color;
|
|
|
|
|
|
|
|
_note_lines->clear();
|
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
for (int i = lowest_note(); i <= highest_note(); ++i) {
|
2008-01-13 12:45:17 -05:00
|
|
|
y = floor(note_to_y(i));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-13 12:45:17 -05:00
|
|
|
_note_lines->add_line(prev_y, 1.0, ARDOUR_UI::config()->canvasvar_PianoRollBlackOutline.get());
|
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
switch (i % 12) {
|
2008-01-13 12:45:17 -05:00
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
case 6:
|
|
|
|
case 8:
|
|
|
|
case 10:
|
|
|
|
color = ARDOUR_UI::config()->canvasvar_PianoRollBlack.get();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
color = ARDOUR_UI::config()->canvasvar_PianoRollWhite.get();
|
|
|
|
break;
|
2007-08-04 00:18:34 -04:00
|
|
|
}
|
2008-01-13 12:45:17 -05:00
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
if (i == highest_note()) {
|
2008-01-13 12:45:17 -05:00
|
|
|
_note_lines->add_line(y, prev_y - y, color);
|
2008-09-22 22:40:29 -04:00
|
|
|
} else {
|
2008-01-13 12:45:17 -05:00
|
|
|
_note_lines->add_line(y + 1.0, prev_y - y - 1.0, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
prev_y = y;
|
2007-08-04 00:18:34 -04:00
|
|
|
}
|
|
|
|
}
|
2007-08-06 02:09:41 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
MidiStreamView::set_note_range(VisibleNoteRange r)
|
|
|
|
{
|
|
|
|
if (r == FullRange) {
|
|
|
|
_lowest_note = 0;
|
|
|
|
_highest_note = 127;
|
|
|
|
} else {
|
2008-09-22 22:40:29 -04:00
|
|
|
_lowest_note = _data_note_min;
|
|
|
|
_highest_note = _data_note_max;
|
2007-08-06 02:09:41 -04:00
|
|
|
}
|
2008-09-22 22:40:29 -04:00
|
|
|
|
2009-02-15 14:44:27 -05:00
|
|
|
apply_note_range(_lowest_note, _highest_note, true);
|
2007-08-06 02:09:41 -04:00
|
|
|
}
|
2007-08-04 00:18:34 -04:00
|
|
|
|
2008-01-13 12:45:17 -05:00
|
|
|
void
|
2009-02-15 14:44:27 -05:00
|
|
|
MidiStreamView::apply_note_range(uint8_t lowest, uint8_t highest, bool to_region_views)
|
2008-09-22 22:40:29 -04:00
|
|
|
{
|
|
|
|
_highest_note = highest;
|
|
|
|
_lowest_note = lowest;
|
|
|
|
note_range_adjustment.set_page_size(_highest_note - _lowest_note);
|
|
|
|
note_range_adjustment.set_value(_lowest_note);
|
|
|
|
draw_note_lines();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-02-15 14:44:27 -05:00
|
|
|
if (to_region_views) {
|
|
|
|
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
((MidiRegionView*)(*i))->apply_note_range(lowest, highest);
|
|
|
|
}
|
2008-01-13 12:45:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
NoteRangeChanged();
|
|
|
|
}
|
2008-09-22 22:40:29 -04:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
void
|
2008-09-22 22:40:29 -04:00
|
|
|
MidiStreamView::update_note_range(uint8_t note_num)
|
2007-07-14 21:56:11 -04:00
|
|
|
{
|
2008-09-22 22:40:29 -04:00
|
|
|
assert(note_num <= 127);
|
|
|
|
_data_note_min = min(_data_note_min, note_num);
|
|
|
|
_data_note_max = max(_data_note_max, note_num);
|
2007-07-14 21:56:11 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
void
|
|
|
|
MidiStreamView::setup_rec_box ()
|
|
|
|
{
|
|
|
|
// cerr << _trackview.name() << " streamview SRB\n";
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_trackview.session()->transport_rolling()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
if (!rec_active &&
|
2009-12-17 13:24:23 -05:00
|
|
|
_trackview.session()->record_status() == Session::Recording &&
|
2009-07-09 13:58:13 -04:00
|
|
|
_trackview.get_diskstream()->record_enabled()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (use_rec_regions && rec_regions.size() == rec_rects.size()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
/* add a new region, but don't bother if they set use_rec_regions mid-record */
|
|
|
|
|
|
|
|
MidiRegion::SourceList sources;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
rec_data_ready_connections.drop_connections ();
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
boost::shared_ptr<MidiDiskstream> mds = _trackview.midi_track()->midi_diskstream();
|
2006-08-14 04:44:14 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
sources.push_back(mds->write_source());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-19 15:26:31 -05:00
|
|
|
mds->write_source()->ViewDataRangeReady.connect
|
2009-12-21 13:23:07 -05:00
|
|
|
(rec_data_ready_connections,
|
|
|
|
ui_bind (&MidiStreamView::rec_data_range_ready, this, _1, _2, boost::weak_ptr<Source>(mds->write_source())),
|
|
|
|
gui_context());
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
// handle multi
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
nframes_t start = 0;
|
2006-07-23 08:03:19 -04:00
|
|
|
if (rec_regions.size() > 0) {
|
2009-10-21 12:26:18 -04:00
|
|
|
start = rec_regions.back().first->start()
|
|
|
|
+ _trackview.get_diskstream()->get_captured_frames(rec_regions.size()-1);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2010-02-18 08:59:49 -05:00
|
|
|
|
|
|
|
PropertyList plist;
|
|
|
|
|
|
|
|
plist.add (ARDOUR::Properties::start, start);
|
|
|
|
plist.add (ARDOUR::Properties::length, 1);
|
|
|
|
plist.add (ARDOUR::Properties::name, string());
|
|
|
|
plist.add (ARDOUR::Properties::layer, 0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<MidiRegion> region (boost::dynamic_pointer_cast<MidiRegion>
|
2010-02-18 08:59:49 -05:00
|
|
|
(RegionFactory::create (sources, plist, false)));
|
2009-10-21 12:26:18 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
assert(region);
|
2009-06-16 10:58:33 -04:00
|
|
|
region->block_property_changes ();
|
2009-12-17 13:24:23 -05:00
|
|
|
region->set_position (_trackview.session()->transport_frame(), this);
|
2007-05-31 17:37:20 -04:00
|
|
|
rec_regions.push_back (make_pair(region, (RegionView*)0));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-09-18 23:29:16 -04:00
|
|
|
// rec regions are destroyed in setup_rec_box
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
/* we add the region later */
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* start a new rec box */
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
boost::shared_ptr<MidiTrack> mt = _trackview.midi_track(); /* we know what it is already */
|
2006-08-24 03:37:17 -04:00
|
|
|
boost::shared_ptr<MidiDiskstream> ds = mt->midi_diskstream();
|
2009-10-21 12:26:18 -04:00
|
|
|
nframes_t frame_pos = ds->current_capture_start ();
|
2009-07-09 13:58:13 -04:00
|
|
|
gdouble xstart = _trackview.editor().frame_to_pixel (frame_pos);
|
2006-07-23 08:03:19 -04:00
|
|
|
gdouble xend;
|
|
|
|
uint32_t fill_color;
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
assert(_trackview.midi_track()->mode() == Normal);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
xend = xstart;
|
2007-06-29 13:13:09 -04:00
|
|
|
fill_color = ARDOUR_UI::config()->canvasvar_RecordingRect.get();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
ArdourCanvas::SimpleRect * rec_rect = new Gnome::Canvas::SimpleRect (*canvas_group);
|
|
|
|
rec_rect->property_x1() = xstart;
|
|
|
|
rec_rect->property_y1() = 1.0;
|
|
|
|
rec_rect->property_x2() = xend;
|
2009-07-09 13:58:13 -04:00
|
|
|
rec_rect->property_y2() = (double) _trackview.current_height() - 1;
|
2007-06-29 13:13:09 -04:00
|
|
|
rec_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RecordingRect.get();
|
2006-07-23 08:03:19 -04:00
|
|
|
rec_rect->property_fill_color_rgba() = fill_color;
|
2007-05-31 17:37:20 -04:00
|
|
|
rec_rect->lower_to_bottom();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
RecBoxInfo recbox;
|
|
|
|
recbox.rectangle = rec_rect;
|
2009-12-17 13:24:23 -05:00
|
|
|
recbox.start = _trackview.session()->transport_frame();
|
2006-07-23 08:03:19 -04:00
|
|
|
recbox.length = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
rec_rects.push_back (recbox);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
screen_update_connection.disconnect();
|
2009-10-21 12:26:18 -04:00
|
|
|
screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::mem_fun (*this, &MidiStreamView::update_rec_box));
|
2006-07-23 08:03:19 -04:00
|
|
|
rec_updating = true;
|
|
|
|
rec_active = true;
|
|
|
|
|
|
|
|
} else if (rec_active &&
|
2009-12-17 13:24:23 -05:00
|
|
|
(_trackview.session()->record_status() != Session::Recording ||
|
2009-07-09 13:58:13 -04:00
|
|
|
!_trackview.get_diskstream()->record_enabled())) {
|
2006-07-23 08:03:19 -04:00
|
|
|
screen_update_connection.disconnect();
|
|
|
|
rec_active = false;
|
|
|
|
rec_updating = false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
} else {
|
|
|
|
|
2006-08-23 00:30:57 -04:00
|
|
|
// cerr << "\tNOT rolling, rec_rects = " << rec_rects.size() << " rec_regions = " << rec_regions.size() << endl;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
if (!rec_rects.empty() || !rec_regions.empty()) {
|
|
|
|
|
|
|
|
/* disconnect rapid update */
|
|
|
|
screen_update_connection.disconnect();
|
2009-12-17 13:24:23 -05:00
|
|
|
rec_data_ready_connections.drop_connections ();
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
rec_updating = false;
|
|
|
|
rec_active = false;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* remove temp regions */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
for (list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator iter = rec_regions.begin(); iter != rec_regions.end();) {
|
|
|
|
list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator tmp;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-09-18 23:29:16 -04:00
|
|
|
tmp = iter;
|
|
|
|
++tmp;
|
2007-05-31 17:37:20 -04:00
|
|
|
|
|
|
|
(*iter).first->drop_references ();
|
|
|
|
|
2006-09-18 23:29:16 -04:00
|
|
|
iter = tmp;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
rec_regions.clear();
|
|
|
|
|
|
|
|
// cerr << "\tclear " << rec_rects.size() << " rec rects\n";
|
|
|
|
|
|
|
|
/* transport stopped, clear boxes */
|
|
|
|
for (vector<RecBoxInfo>::iterator iter=rec_rects.begin(); iter != rec_rects.end(); ++iter) {
|
|
|
|
RecBoxInfo &rect = (*iter);
|
|
|
|
delete rect.rectangle;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
rec_rects.clear();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-08-15 21:25:58 -04:00
|
|
|
MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t start, nframes_t dur)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2009-12-11 18:29:48 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &MidiStreamView::update_rec_regions, data, start, dur)
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
if (use_rec_regions) {
|
2006-08-14 04:44:14 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
uint32_t n = 0;
|
2007-10-04 01:15:28 -04:00
|
|
|
bool update_range = false;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
for (list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator iter = rec_regions.begin();
|
|
|
|
iter != rec_regions.end(); n++) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator tmp = iter;
|
2006-07-23 08:03:19 -04:00
|
|
|
++tmp;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
if (!canvas_item_visible (rec_rects[n].rectangle)) {
|
|
|
|
/* rect already hidden, this region is done */
|
2006-07-23 08:03:19 -04:00
|
|
|
iter = tmp;
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
boost::shared_ptr<MidiRegion> region = boost::dynamic_pointer_cast<MidiRegion>(iter->first);
|
|
|
|
if (!region) {
|
2008-05-02 16:57:27 -04:00
|
|
|
iter = tmp;
|
2007-05-31 17:37:20 -04:00
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
nframes_t origlen = region->length();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
if (region == rec_regions.back().first && rec_active) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2007-10-07 03:20:09 -04:00
|
|
|
if (start >= region->midi_source(0)->timeline_position()) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-10-07 03:20:09 -04:00
|
|
|
nframes_t nlen = start + dur - region->position();
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
if (nlen != region->length()) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-03-02 13:05:26 -05:00
|
|
|
region->suspend_property_changes ();
|
2009-07-09 13:58:13 -04:00
|
|
|
region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this);
|
2007-10-07 03:20:09 -04:00
|
|
|
region->set_length (start + dur - region->position(), this);
|
2010-03-02 13:05:26 -05:00
|
|
|
region->resume_property_changes ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (origlen == 1) {
|
|
|
|
/* our special initial length */
|
2007-05-31 17:37:20 -04:00
|
|
|
iter->second = add_region_view_internal (region, false);
|
2007-06-01 19:27:29 -04:00
|
|
|
((MidiRegionView*)iter->second)->begin_write();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* also update rect */
|
|
|
|
ArdourCanvas::SimpleRect * rect = rec_rects[n].rectangle;
|
2009-07-09 13:58:13 -04:00
|
|
|
gdouble xend = _trackview.editor().frame_to_pixel (region->position() + region->length());
|
2006-07-23 08:03:19 -04:00
|
|
|
rect->property_x2() = xend;
|
2007-06-01 19:27:29 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
ARDOUR::BeatsFramesConverter tconv(_trackview.session()->tempo_map(), region->position());
|
2009-10-21 12:39:39 -04:00
|
|
|
const MidiModel::TimeType start_beats = tconv.from(start);
|
2009-10-21 12:26:18 -04:00
|
|
|
|
2007-06-01 19:27:29 -04:00
|
|
|
/* draw events */
|
|
|
|
MidiRegionView* mrv = (MidiRegionView*)iter->second;
|
2009-10-21 12:26:18 -04:00
|
|
|
|
2009-10-21 12:39:39 -04:00
|
|
|
for (MidiModel::Notes::const_iterator i = data->note_lower_bound(start_beats);
|
2009-10-19 11:23:42 -04:00
|
|
|
i != data->notes().end(); ++i) {
|
2007-10-07 03:20:09 -04:00
|
|
|
|
2009-10-19 11:23:42 -04:00
|
|
|
const boost::shared_ptr<MidiRegionView::NoteType>& note = *i;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
nframes_t note_start_frames = tconv.to(note->time());
|
|
|
|
nframes_t note_end_frames = tconv.to(note->end_time());
|
|
|
|
|
|
|
|
if (note->length() > 0 && note_end_frames + region->position() > start)
|
|
|
|
mrv->resolve_note(note->note(), note_end_frames);
|
2007-10-14 01:45:31 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
if (note_start_frames + region->position() < start) {
|
2007-10-07 03:20:09 -04:00
|
|
|
continue;
|
2009-10-21 12:26:18 -04:00
|
|
|
}
|
2007-10-07 03:20:09 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
if (note_start_frames + region->position() > start + dur) {
|
2007-08-15 21:25:58 -04:00
|
|
|
break;
|
2009-10-21 12:26:18 -04:00
|
|
|
}
|
2007-08-15 21:25:58 -04:00
|
|
|
|
2007-10-14 01:45:31 -04:00
|
|
|
if (note->note() < _lowest_note) {
|
|
|
|
_lowest_note = note->note();
|
2007-10-04 01:15:28 -04:00
|
|
|
update_range = true;
|
2007-10-14 01:45:31 -04:00
|
|
|
} else if (note->note() > _highest_note) {
|
|
|
|
_highest_note = note->note();
|
2007-10-04 01:15:28 -04:00
|
|
|
update_range = true;
|
|
|
|
}
|
2009-09-10 17:19:01 -04:00
|
|
|
|
|
|
|
mrv->add_note (note, !update_range);
|
2007-06-01 19:27:29 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-08-15 21:25:58 -04:00
|
|
|
mrv->extend_active_notes();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
nframes_t nlen = _trackview.get_diskstream()->get_captured_frames(n);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
if (nlen != region->length()) {
|
|
|
|
|
2009-02-19 19:30:42 -05:00
|
|
|
if (region->source_length(0) >= region->position() + nlen) {
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2010-03-02 13:05:26 -05:00
|
|
|
region->suspend_property_changes ();
|
2009-07-09 13:58:13 -04:00
|
|
|
region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this);
|
2006-07-23 08:03:19 -04:00
|
|
|
region->set_length (nlen, this);
|
2010-03-02 13:05:26 -05:00
|
|
|
region->resume_property_changes ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (origlen == 1) {
|
|
|
|
/* our special initial length */
|
2007-05-31 17:37:20 -04:00
|
|
|
iter->second = add_region_view_internal (region, false);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* also hide rect */
|
|
|
|
ArdourCanvas::Item * rect = rec_rects[n].rectangle;
|
|
|
|
rect->hide();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
iter = tmp;
|
|
|
|
}
|
2007-10-04 01:15:28 -04:00
|
|
|
|
|
|
|
if (update_range)
|
2008-09-19 15:32:10 -04:00
|
|
|
update_contents_height();
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2006-08-14 04:44:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-10-21 12:26:18 -04:00
|
|
|
MidiStreamView::rec_data_range_ready (nframes_t start, nframes_t cnt, boost::weak_ptr<Source> weak_src)
|
2006-08-14 04:44:14 -04:00
|
|
|
{
|
|
|
|
// this is called from the butler thread for now
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &MidiStreamView::rec_data_range_ready, start, cnt, weak_src)
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-05-31 17:37:20 -04:00
|
|
|
boost::shared_ptr<SMFSource> src (boost::dynamic_pointer_cast<SMFSource>(weak_src.lock()));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-10-21 12:26:18 -04:00
|
|
|
if (!src) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start + cnt > last_rec_data_frame) {
|
|
|
|
last_rec_data_frame = start + cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->update_rec_regions (src->model(), start, cnt);
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-15 18:08:27 -04:00
|
|
|
MidiStreamView::color_handler ()
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2007-06-15 18:08:27 -04:00
|
|
|
//case cMidiTrackBase:
|
2009-07-09 13:58:13 -04:00
|
|
|
if (_trackview.is_midi_track()) {
|
2008-01-13 12:45:17 -05:00
|
|
|
//canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiTrackBase.get();
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2007-06-15 18:08:27 -04:00
|
|
|
|
|
|
|
//case cMidiBusBase:
|
2009-07-09 13:58:13 -04:00
|
|
|
if (!_trackview.is_midi_track()) {
|
2008-01-13 12:45:17 -05:00
|
|
|
//canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiBusBase.get();;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
2007-06-15 18:08:27 -04:00
|
|
|
|
2008-01-13 12:45:17 -05:00
|
|
|
void
|
2008-09-22 22:40:29 -04:00
|
|
|
MidiStreamView::note_range_adjustment_changed()
|
|
|
|
{
|
2008-01-13 12:45:17 -05:00
|
|
|
double sum = note_range_adjustment.get_value() + note_range_adjustment.get_page_size();
|
|
|
|
int lowest = (int) floor(note_range_adjustment.get_value());
|
|
|
|
int highest;
|
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
if (sum == _range_sum_cache) {
|
2008-01-13 16:34:04 -05:00
|
|
|
//cerr << "cached" << endl;
|
2008-01-13 12:45:17 -05:00
|
|
|
highest = (int) floor(sum);
|
2008-09-22 22:40:29 -04:00
|
|
|
} else {
|
2008-01-13 16:34:04 -05:00
|
|
|
//cerr << "recalc" << endl;
|
2008-01-13 12:45:17 -05:00
|
|
|
highest = lowest + (int) floor(note_range_adjustment.get_page_size());
|
|
|
|
_range_sum_cache = sum;
|
|
|
|
}
|
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
if (lowest == _lowest_note && highest == _highest_note) {
|
2008-01-13 12:45:17 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
//cerr << "note range adjustment changed: " << lowest << " " << highest << endl;
|
2008-01-13 12:45:17 -05:00
|
|
|
//cerr << " val=" << v_zoom_adjustment.get_value() << " page=" << v_zoom_adjustment.get_page_size() << " sum=" << v_zoom_adjustment.get_value() + v_zoom_adjustment.get_page_size() << endl;
|
|
|
|
|
2008-09-22 22:40:29 -04:00
|
|
|
_lowest_note = lowest;
|
|
|
|
_highest_note = highest;
|
2009-02-15 14:44:27 -05:00
|
|
|
apply_note_range(lowest, highest, true);
|
2008-01-13 12:45:17 -05:00
|
|
|
}
|
2008-09-22 22:40:29 -04:00
|
|
|
|