#include "ardour/midi_diskstream.h"
#include "ardour/midi_model.h"
#include "ardour/midi_patch_manager.h"
+#include "ardour/session.h"
#include "evoral/Parameter.hpp"
#include "evoral/Control.hpp"
, _pressed_button(0)
, _sort_needed (true)
, _optimization_iterator (_events.end())
-
+
{
_note_group->raise_to_top();
}
UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
c.set_rgb_p (r/255.0, g/255.0, b/255.0);
-
+
init (c, false);
}
region_sync_changed ();
region_resized (BoundsChanged);
region_locked ();
-
+
reset_width_dependent_items (_pixel_width);
set_colors ();
midi_view()->signal_channel_mode_changed().connect(
mem_fun(this, &MidiRegionView::midi_channel_mode_changed));
-
+
midi_view()->signal_midi_patch_settings_changed().connect(
mem_fun(this, &MidiRegionView::midi_patch_settings_changed));
}
switch (ev->type) {
case GDK_SCROLL:
fine = Keyboard::modifier_state_equals (ev->scroll.state, Keyboard::Level4Modifier);
-
+
if (ev->scroll.direction == GDK_SCROLL_UP) {
change_velocities (true, fine, false);
return true;
bool end = (ev->key.keyval == GDK_period);
bool shorter = Keyboard::modifier_state_contains (ev->key.state, Keyboard::PrimaryModifier);
fine = Keyboard::modifier_state_contains (ev->key.state, Keyboard::SecondaryModifier);
-
+
change_note_lengths (fine, shorter, start, end);
return true;
return true;
} else if (ev->key.keyval == GDK_Down) {
-
+
bool allow_smush = Keyboard::modifier_state_contains (ev->key.state, Keyboard::SecondaryModifier);
fine = Keyboard::modifier_state_contains (ev->key.state, Keyboard::TertiaryModifier);
-
+
if (Keyboard::modifier_state_contains (ev->key.state, Keyboard::PrimaryModifier)) {
change_velocities (false, fine, allow_smush);
} else {
return true;
} else if (ev->key.keyval == GDK_Left) {
-
+
nudge_notes (false);
return true;
} else if (_pressed_button != 1) {
return false;
}
-
+
switch (_mouse_state) {
case Pressed: // Clicked
switch (editor.current_mouse_mode()) {
case MouseRange:
create_note_at(event_x, event_y, _default_note_length);
break;
- default:
+ default:
break;
}
_mouse_state = None;
const double x = drag_rect->property_x1();
const double length = trackview.editor().pixel_to_frame(
drag_rect->property_x2() - drag_rect->property_x1());
-
+
create_note_at(x, drag_rect->property_y1(), frames_to_beats(length));
}
drag_rect = 0;
default: break;
}
-
+
default: break;
}
{
_model = model;
content_connection.disconnect ();
- content_connection = _model->ContentsChanged.connect(sigc::mem_fun(this, &MidiRegionView::redisplay_model));
+ content_connection = _model->ContentsChanged.connect(
+ sigc::mem_fun(this, &MidiRegionView::redisplay_model));
clear_events ();
if (_enable_display) {
redisplay_model();
}
}
-
-
+
+
void
MidiRegionView::start_delta_command(string name)
{
}
void
-MidiRegionView::diff_add_change (ArdourCanvas::CanvasNoteEvent* ev,
+MidiRegionView::diff_add_change (ArdourCanvas::CanvasNoteEvent* ev,
MidiModel::DiffCommand::Property property,
uint8_t val)
{
}
void
-MidiRegionView::diff_add_change (ArdourCanvas::CanvasNoteEvent* ev,
+MidiRegionView::diff_add_change (ArdourCanvas::CanvasNoteEvent* ev,
MidiModel::DiffCommand::Property property,
Evoral::MusicalTime val)
{
_diff_command->change (ev->note(), property, val);
}
}
-
+
void
MidiRegionView::apply_delta()
{
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
_marked_for_selection.insert((*i)->note());
}
-
+
_model->apply_command(trackview.session(), _delta_command);
- _delta_command = 0;
+ _delta_command = 0;
midi_view()->midi_track()->diskstream()->playlist_modified();
_marked_for_selection.clear();
}
_model->apply_command(trackview.session(), _diff_command);
- _diff_command = 0;
+ _diff_command = 0;
midi_view()->midi_track()->diskstream()->playlist_modified();
_marked_for_velocity.clear();
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
_marked_for_selection.insert((*i)->note());
}
-
+
_model->apply_command_as_subcommand(trackview.session(), _delta_command);
- _delta_command = 0;
+ _delta_command = 0;
midi_view()->midi_track()->diskstream()->playlist_modified();
_marked_for_selection.clear();
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
_marked_for_selection.insert((*i)->note());
}
-
+
_model->apply_command_as_subcommand(trackview.session(), _diff_command);
- _diff_command = 0;
+ _diff_command = 0;
midi_view()->midi_track()->diskstream()->playlist_modified();
_marked_for_selection.clear();
if (_optimization_iterator != _events.end()) {
++_optimization_iterator;
}
-
+
if (_optimization_iterator != _events.end() && (*_optimization_iterator)->note() == note) {
return *_optimization_iterator;
- }
+ }
for (_optimization_iterator = _events.begin(); _optimization_iterator != _events.end(); ++_optimization_iterator) {
if ((*_optimization_iterator)->note() == note) {
for (Events::iterator i = _events.begin(); i != _events.end(); ++i) {
(*i)->invalidate ();
}
-
- _model->read_lock();
-
+
+ MidiModel::ReadLock lock(_model->read_lock());
+
MidiModel::Notes& notes (_model->notes());
_optimization_iterator = _events.begin();
-
+
for (MidiModel::Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
boost::shared_ptr<NoteType> note (*n);
bool visible;
if (note_in_region_range (note, visible)) {
-
+
if ((cne = find_canvas_note (note)) != 0) {
-
+
cne->validate ();
-
+
CanvasNote* cn;
CanvasHit* ch;
-
+
if ((cn = dynamic_cast<CanvasNote*>(cne)) != 0) {
update_note (cn);
} else if ((ch = dynamic_cast<CanvasHit*>(cne)) != 0) {
} else {
cne->hide ();
}
-
+
} else {
-
+
add_note (note, visible);
}
-
+
} else {
-
+
if ((cne = find_canvas_note (note)) != 0) {
cne->validate ();
cne->hide ();
}
}
}
-
+
/* remove note items that are no longer valid */
-
+
for (Events::iterator i = _events.begin(); i != _events.end(); ) {
if (!(*i)->valid ()) {
delete *i;
++i;
}
}
-
+
display_sysexes();
display_program_changes();
-
- _model->read_unlock();
-
+
_marked_for_selection.clear ();
_marked_for_velocity.clear ();
MIDI::Name::PatchPrimaryKey patch_key(msb, lsb, program_number);
- boost::shared_ptr<MIDI::Name::Patch> patch =
+ boost::shared_ptr<MIDI::Name::Patch> patch =
MIDI::Name::MidiPatchManager::instance().find_patch(
_model_name, _custom_device_mode, channel, patch_key);
}
}
-void
+void
MidiRegionView::display_sysexes()
{
for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) {
Evoral::MusicalTime time = (*i)->time();
assert(time >= 0);
-
+
ostringstream str;
str << hex;
for (uint32_t b = 0; b < (*i)->size(); ++b) {
}
}
string text = str.str();
-
+
ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group();
const double x = trackview.editor().frame_to_pixel(beats_to_frames(time));
-
+
double height = midi_stream_view()->contents_height();
-
+
boost::shared_ptr<CanvasSysEx> sysex = boost::shared_ptr<CanvasSysEx>(
new CanvasSysEx(*this, *group, text, height, x, 1.0));
-
+
// Show unless program change is beyond the region bounds
if (time - _region->start() >= _region->length() || time < _region->start()) {
sysex->hide();
} else {
sysex->show();
}
-
+
_sys_exes.push_back(sysex);
}
}
MidiRegionView::region_resized (Change what_changed)
{
RegionView::region_resized(what_changed);
-
+
if (what_changed & ARDOUR::PositionChanged) {
set_duration(_region->length(), 0);
if (_enable_display) {
redisplay_model();
}
- }
+ }
}
void
const double old_height = _height;
RegionView::set_height(height);
_height = height - FUDGE;
-
+
apply_note_range(midi_stream_view()->lowest_note(),
midi_stream_view()->highest_note(),
height != old_height + FUDGE);
-
+
if (name_pixbuf) {
name_pixbuf->raise_to_top();
}
CanvasNoteEvent* event = *i;
boost::shared_ptr<NoteType> note (event->note());
- if (note->note() < _current_range_min ||
+ if (note->note() < _current_range_min ||
note->note() > _current_range_max) {
event->hide();
} else {
event->show();
}
-
+
if (CanvasNote* cnote = dynamic_cast<CanvasNote*>(event)) {
const double y1 = midi_stream_view()->note_to_y(note->note());
const double y2 = y1 + floor(midi_stream_view()->note_height());
-
+
cnote->property_y1() = y1;
cnote->property_y2() = y2;
double x = trackview.editor().frame_to_pixel(
beats_to_frames(note->time()) - _region->start());
const double diamond_size = midi_stream_view()->note_height() / 2.0;
- double y = midi_stream_view()->note_to_y(event->note()->note())
+ double y = midi_stream_view()->note_to_y(event->note()->note())
+ ((diamond_size-2.0) / 4.0);
-
+
chit->set_height (diamond_size);
chit->move (x - chit->x1(), y - chit->y1());
chit->show ();
}
}
-void
+void
MidiRegionView::play_midi_note(boost::shared_ptr<NoteType> note)
{
if (!trackview.editor().sound_notes()) {
RouteUI* route_ui = dynamic_cast<RouteUI*> (&trackview);
assert(route_ui);
-
+
route_ui->midi_track()->write_immediate_event(
note->on_event().size(), note->on_event().buffer());
-
+
const double note_length_beats = (note->off_event().time() - note->on_event().time());
nframes_t note_length_ms = beats_to_frames(note_length_beats)
* (1000 / (double)route_ui->session().nominal_frame_rate());
{
RouteUI* route_ui = dynamic_cast<RouteUI*> (&trackview);
assert(route_ui);
-
+
route_ui->midi_track()->write_immediate_event(
note->off_event().size(), note->off_event().buffer());
{
const nframes64_t note_start_frames = beats_to_frames(note->time());
- bool outside = (note_start_frames - _region->start() >= _region->length()) ||
+ bool outside = (note_start_frames - _region->start() >= _region->length()) ||
(note_start_frames < _region->start());
visible = (note->note() >= midi_stream_view()->lowest_note()) &&
const nframes64_t note_end_frames = beats_to_frames(note->end_time());
const double x = trackview.editor().frame_to_pixel(note_start_frames - _region->start());
-
-
const double y1 = midi_stream_view()->note_to_y(note->note());
- const double note_endpixel =
+ const double note_endpixel =
trackview.editor().frame_to_pixel(note_end_frames - _region->start());
-
+
ev->property_x1() = x;
ev->property_y1() = y1;
if (note->length() > 0) {
ev->property_x2() = trackview.editor().frame_to_pixel(_region->length());
}
ev->property_y2() = y1 + floor(midi_stream_view()->note_height());
-
+
if (note->length() == 0) {
if (_active_notes) {
assert(note->note() < 128);
const double diamond_size = midi_stream_view()->note_height() / 2.0;
const double y = midi_stream_view()->note_to_y(note->note()) + ((diamond_size-2) / 4.0);
- ev->move(x, y);
+ ev->move_to (x, y);
}
/** Add a MIDI note to the view (with length).
MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible)
{
CanvasNoteEvent* event = 0;
-
+
assert(note->time() >= 0);
assert(midi_view()->note_mode() == Sustained || midi_view()->note_mode() == Percussive);
ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group();
if (midi_view()->note_mode() == Sustained) {
-
+
CanvasNote* ev_rect = new CanvasNote(*this, *group, note);
update_note (ev_rect);
if (event) {
if (_marked_for_selection.find(note) != _marked_for_selection.end()) {
note_selected(event, true);
- }
+ }
if (_marked_for_velocity.find(note) != _marked_for_velocity.end()) {
event->show_velocity();
}
void
-MidiRegionView::add_note (uint8_t channel, uint8_t number, uint8_t velocity,
+MidiRegionView::add_note (uint8_t channel, uint8_t number, uint8_t velocity,
Evoral::MusicalTime pos, Evoral::MusicalTime len)
{
boost::shared_ptr<NoteType> new_note (new NoteType (channel, pos, len, number, velocity));
-
+
start_delta_command (_("step add"));
delta_add_note (new_note, true, false);
apply_delta();
MidiRegionView::add_pgm_change(PCEvent& program, const string& displaytext)
{
assert(program.time >= 0);
-
+
ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group();
const double x = trackview.editor().frame_to_pixel(beats_to_frames(program.time));
-
+
double height = midi_stream_view()->contents_height();
-
+
boost::shared_ptr<CanvasProgramChange> pgm_change = boost::shared_ptr<CanvasProgramChange>(
new CanvasProgramChange(*this, *group,
- displaytext,
- height,
- x, 1.0,
- _model_name,
- _custom_device_mode,
+ displaytext,
+ height,
+ x, 1.0,
+ _model_name,
+ _custom_device_mode,
program.time, program.channel, program.value));
-
+
// Show unless program change is beyond the region bounds
if (program.time - _region->start() >= _region->length() || program.time < _region->start()) {
pgm_change->hide();
} else {
pgm_change->show();
}
-
+
_pgm_changes.push_back(pgm_change);
}
lsb = lsb_control->get_float(true, time);
cerr << " got lsb " << lsb;
}
-
+
Evoral::Parameter program_change(MidiPgmChangeAutomation, channel, 0);
boost::shared_ptr<Evoral::Control> program_control = _model->control(program_change);
float program_number = -1.0;
program_number = program_control->get_float(true, time);
cerr << " got program " << program_number << endl;
}
-
+
key.msb = (int) floor(msb + 0.5);
key.lsb = (int) floor(lsb + 0.5);
key.program_number = (int) floor(program_number + 0.5);
}
-void
+void
MidiRegionView::alter_program_change(PCEvent& old_program, const MIDI::Name::PatchPrimaryKey& new_patch)
{
// TODO: Get the real event here and alter them at the original times
if (lsb_control != 0) {
lsb_control->set_float(float(new_patch.lsb), true, old_program.time);
}
-
+
Evoral::Parameter program_change(MidiPgmChangeAutomation, old_program.channel, 0);
boost::shared_ptr<Evoral::Control> program_control = _model->control(program_change);
-
+
assert(program_control != 0);
program_control->set_float(float(new_patch.program_number), true, old_program.time);
-
+
redisplay_model();
}
alter_program_change(program_change_event, new_patch);
}
-void
+void
MidiRegionView::previous_program(CanvasProgramChange& program)
{
MIDI::Name::PatchPrimaryKey key;
get_patch_key_at(program.event_time(), program.channel(), key);
-
- boost::shared_ptr<MIDI::Name::Patch> patch =
+
+ boost::shared_ptr<MIDI::Name::Patch> patch =
MIDI::Name::MidiPatchManager::instance().previous_patch(
_model_name,
- _custom_device_mode,
- program.channel(),
+ _custom_device_mode,
+ program.channel(),
key);
-
+
PCEvent program_change_event(program.event_time(), program.program(), program.channel());
if (patch) {
alter_program_change(program_change_event, patch->patch_primary_key());
}
}
-void
+void
MidiRegionView::next_program(CanvasProgramChange& program)
{
MIDI::Name::PatchPrimaryKey key;
get_patch_key_at(program.event_time(), program.channel(), key);
-
- boost::shared_ptr<MIDI::Name::Patch> patch =
+
+ boost::shared_ptr<MIDI::Name::Patch> patch =
MIDI::Name::MidiPatchManager::instance().next_patch(
_model_name,
- _custom_device_mode,
- program.channel(),
- key);
+ _custom_device_mode,
+ program.channel(),
+ key);
PCEvent program_change_event(program.event_time(), program.program(), program.channel());
if (patch) {
MidiRegionView::unique_select(ArdourCanvas::CanvasNoteEvent* ev)
{
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ) {
+ if ((*i) != ev) {
- Selection::iterator tmp = i;
- ++tmp;
+ Selection::iterator tmp = i;
+ ++tmp;
- if ((*i) != ev) {
- remove_from_selection (*i);
- }
+ (*i)->selected (false);
+ _selection.erase (i);
- i = tmp;
+ i = tmp;
+
+ } else {
+ ++i;
+ }
}
+ /* don't bother with removing this regionview from the editor selection,
+ since we're about to add another note, and thus put/keep this
+ regionview in the editor selection.
+ */
+
if (!ev->selected()) {
add_to_selection (ev);
}
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
if ((*i)->note()->end_time() > latest) {
latest = (*i)->note()->end_time();
- }
+ }
if ((*i)->note()->time() < earliest) {
earliest = (*i)->note()->time();
}
if (ev->note()->time() < earliest) {
earliest = ev->note()->time();
}
-
- for (Events::iterator i = _events.begin(); i != _events.end(); ++i) {
-
+
+ for (Events::iterator i = _events.begin(); i != _events.end(); ++i) {
+
/* find notes entirely within OR spanning the earliest..latest range */
-
+
if (((*i)->note()->time() >= earliest && (*i)->note()->end_time() <= latest) ||
((*i)->note()->time() <= earliest && (*i)->note()->end_time() >= latest)) {
add_to_selection (*i);
- }
+ }
#if 0
/* if events were guaranteed to be time sorted, we could do this.
but as of sept 10th 2009, they no longer are.
*/
-
+
if ((*i)->note()->time() > latest) {
break;
}
for (Events::iterator i = _events.begin(); i != _events.end(); ++i) {
/* check if any corner of the note is inside the rect
-
+
Notes:
1) this is computing "touched by", not "contained by" the rect.
2) this does not require that events be sorted in time.
ev->selected (false);
ev->hide_velocity ();
-
+
if (_selection.empty()) {
PublicEditor& editor (trackview.editor());
editor.get_selection().remove (this);
}
void
-MidiRegionView::note_dropped(CanvasNoteEvent* ev, double dt, uint8_t dnote)
+MidiRegionView::note_dropped(CanvasNoteEvent *, double dt, int8_t dnote)
{
- // TODO: This would be faster/nicer with a MoveCommand that doesn't need to copy...
- if (_selection.find(ev) == _selection.end()) {
- return;
- }
+ assert (!_selection.empty());
- uint8_t lowest_note_in_selection = midi_stream_view()->lowest_note();
- uint8_t highest_note_in_selection = midi_stream_view()->highest_note();
+ uint8_t lowest_note_in_selection = 127;
+ uint8_t highest_note_in_selection = 0;
uint8_t highest_note_difference = 0;
// find highest and lowest notes first
+
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
uint8_t pitch = (*i)->note()->note();
lowest_note_in_selection = std::min(lowest_note_in_selection, pitch);
highest_note_in_selection = std::max(highest_note_in_selection, pitch);
}
-
+
/*
cerr << "dnote: " << (int) dnote << endl;
- cerr << "lowest note (streamview): " << int(midi_stream_view()->lowest_note())
+ cerr << "lowest note (streamview): " << int(midi_stream_view()->lowest_note())
<< " highest note (streamview): " << int(midi_stream_view()->highest_note()) << endl;
- cerr << "lowest note (selection): " << int(lowest_note_in_selection) << " highest note(selection): "
+ cerr << "lowest note (selection): " << int(lowest_note_in_selection) << " highest note(selection): "
<< int(highest_note_in_selection) << endl;
cerr << "selection size: " << _selection.size() << endl;
cerr << "Highest note in selection: " << (int) highest_note_in_selection << endl;
*/
-
+
// Make sure the note pitch does not exceed the MIDI standard range
- if (dnote <= 127 && (highest_note_in_selection + dnote > 127)) {
+ if (highest_note_in_selection + dnote > 127) {
highest_note_difference = highest_note_in_selection - 127;
}
-
+
start_diff_command(_("move notes"));
for (Selection::iterator i = _selection.begin(); i != _selection.end() ; ++i) {
uint8_t original_pitch = (*i)->note()->note();
uint8_t new_pitch = original_pitch + dnote - highest_note_difference;
-
+
// keep notes in standard midi range
clamp_to_0_127(new_pitch);
-
+
// keep original pitch if note is dragged outside valid midi range
if ((original_pitch != 0 && new_pitch == 0)
|| (original_pitch != 127 && new_pitch == 127)) {
}
apply_diff();
-
+
// care about notes being moved beyond the upper/lower bounds on the canvas
if (lowest_note_in_selection < midi_stream_view()->lowest_note() ||
- highest_note_in_selection > midi_stream_view()->highest_note()) {
+ highest_note_in_selection > midi_stream_view()->highest_note()) {
midi_stream_view()->set_note_range(MidiStreamView::ContentsRange);
}
}
}
void
-MidiRegionView::begin_resizing(bool at_front)
+MidiRegionView::begin_resizing (bool /*at_front*/)
{
_resize_data.clear();
current_x = delta_x - get_end_position_pixels ();
}
}
-
+
if (at_front) {
resize_rect->property_x1() = snap_to_pixel(current_x);
resize_rect->property_x2() = canvas_note->x2();
current_x = region_start + delta_x;
}
}
-
+
current_x = snap_pixel_to_frame (current_x);
current_x = frames_to_beats (current_x);
if (at_front && current_x < canvas_note->note()->end_time()) {
diff_add_change (canvas_note, MidiModel::DiffCommand::StartTime, current_x);
+
+ double len = canvas_note->note()->time() - current_x;
+ len += canvas_note->note()->length();
+
+ if (len > 0) {
+ /* XXX convert to beats */
+ diff_add_change (canvas_note, MidiModel::DiffCommand::Length, len);
+ }
}
if (!at_front) {
} else {
Evoral::MusicalTime new_pos = event->note()->time() + front_delta;
-
+
if (new_pos < event->note()->end_time()) {
new_start = event->note()->time() + front_delta;
/* start moved toward the end, so move the end point back to where it used to be */
- new_length = event->note()->length() - front_delta;
+ new_length = event->note()->length() - front_delta;
change_start = true;
change_length = true;
}
if (event->note()->length() < -end_delta) {
can_change = false;
}
- }
+ }
if (can_change) {
new_length = event->note()->length() + end_delta;
new_time = 0;
} else {
new_time = event->note()->time() + delta;
- }
+ }
} else {
new_time = event->note()->time() + delta;
}
}
start_diff_command(_("change velocities"));
-
+
for (Selection::iterator i = _selection.begin(); i != _selection.end();) {
Selection::iterator next = i;
++next;
change_note_velocity (*i, delta, true);
i = next;
}
-
+
apply_diff();
}
}
int8_t delta;
-
+
if (fine) {
delta = 1;
} else {
if (shorter) {
delta = -delta;
}
-
+
start_diff_command (_("change note lengths"));
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ) {
Selection::iterator next = i;
++next;
-
+
/* note the negation of the delta for start */
trim_note (*i, (start ? -delta : 0), (end ? delta : 0));
return;
}
- /* pick a note as the point along the timeline to get the nudge distance.
- its not necessarily the earliest note, so we may want to pull the notes out
+ /* pick a note as the point along the timeline to get the nudge distance.
+ its not necessarily the earliest note, so we may want to pull the notes out
into a vector and sort before using the first one.
*/
nframes64_t unused;
nframes64_t distance;
- if ((distance = trackview.editor().get_nudge_distance (ref_point, unused)) == 0) {
+ if (trackview.editor().snap_mode() == Editing::SnapOff) {
+
+ /* grid is off - use nudge distance */
+
+ distance = trackview.editor().get_nudge_distance (ref_point, unused);
+
+ } else {
- /* no nudge distance set - use grid */
+ /* use grid */
nframes64_t next_pos = ref_point;
-
+
if (forward) {
/* XXX need check on max_frames, but that needs max_frames64 or something */
next_pos += 1;
- } else {
+ } else {
if (next_pos == 0) {
return;
}
next_pos -= 1;
}
-
+
cerr << "ref point was " << ref_point << " next was " << next_pos;
trackview.editor().snap_to (next_pos, (forward ? 1 : -1), false);
distance = ref_point - next_pos;
cerr << " final is " << next_pos << " distance = " << distance << endl;
- }
-
+ }
+
if (distance == 0) {
return;
}
note_selected(ev, true);
}
- PublicEditor& editor (trackview.editor());
- editor.show_verbose_canvas_cursor_with (Evoral::midi_note_name (ev->note()->note()));
+ char buf[4];
+ snprintf (buf, sizeof (buf), "%d", (int) ev->note()->note());
+ // This causes an infinite loop on note add sometimes
+ //PublicEditor& editor (trackview.editor());
+ //editor.show_verbose_canvas_cursor_with (Evoral::midi_note_name (ev->note()->note()));
+ //editor.show_verbose_canvas_cursor_with (buf);
}
void
-MidiRegionView::note_left (ArdourCanvas::CanvasNoteEvent* ev)
+MidiRegionView::note_left (ArdourCanvas::CanvasNoteEvent*)
{
PublicEditor& editor (trackview.editor());
editor.hide_verbose_canvas_cursor ();
}
-
+
void
MidiRegionView::switch_source(boost::shared_ptr<Source> src)
}
}
-void
+void
MidiRegionView::midi_channel_mode_changed(ChannelMode mode, uint16_t mask)
{
switch (mode) {
_last_channel_selection = mask;
}
-void
+void
MidiRegionView::midi_patch_settings_changed(std::string model, std::string custom_device_mode)
{
_model_name = model;
default:
break;
}
-
+
start_delta_command();
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
MidiCutBuffer*
MidiRegionView::selection_as_cut_buffer () const
{
- NoteList notes;
+ Notes notes;
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
- notes.push_back (boost::shared_ptr<NoteType> (new NoteType (*((*i)->note().get()))));
+ notes.insert (boost::shared_ptr<NoteType> (new NoteType (*((*i)->note().get()))));
}
- /* sort them into time order */
-
- Evoral::Sequence<Evoral::MusicalTime>::LaterNoteComparator cmp;
- sort (notes.begin(), notes.end(), cmp);
-
MidiCutBuffer* cb = new MidiCutBuffer (trackview.session());
cb->set (notes);
-
+
return cb;
}
Evoral::MusicalTime duration;
Evoral::MusicalTime end_point;
- duration = mcb.notes().back()->end_time() - mcb.notes().front()->time();
+ duration = (*mcb.notes().rbegin())->end_time() - (*mcb.notes().begin())->time();
paste_pos_beats = frames_to_beats (pos - _region->position());
- beat_delta = mcb.notes().front()->time() - paste_pos_beats;
+ beat_delta = (*mcb.notes().begin())->time() - paste_pos_beats;
paste_pos_beats = 0;
_selection.clear ();
for (int n = 0; n < (int) times; ++n) {
- for (NoteList::const_iterator i = mcb.notes().begin(); i != mcb.notes().end(); ++i) {
-
+ for (Notes::const_iterator i = mcb.notes().begin(); i != mcb.notes().end(); ++i) {
+
boost::shared_ptr<NoteType> copied_note (new NoteType (*((*i).get())));
copied_note->set_time (paste_pos_beats + copied_note->time() - beat_delta);
_region->set_length (end_frame, this);
trackview.session().add_command (new MementoCommand<Region>(*_region, &before, &_region->get_state()));
}
-
+
apply_delta ();
}
/* use the first one */
unique_select (_events.front());
-
+
}
void
}
void
-MidiRegionView::selection_as_notelist (NoteList& selected)
+MidiRegionView::selection_as_notelist (Notes& selected)
{
time_sort_events ();
for (Events::iterator i = _events.begin(); i != _events.end(); ++i) {
if ((*i)->selected()) {
- selected.push_back ((*i)->note());
+ selected.insert ((*i)->note());
}
}
}
-
-