2013-01-16 13:22:15 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2012 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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2010-08-15 12:39:51 -04:00
|
|
|
#include "ardour/midi_track.h"
|
|
|
|
#include "ardour/midi_region.h"
|
|
|
|
#include "ardour/tempo.h"
|
|
|
|
#include "ardour/types.h"
|
|
|
|
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "midi_region_view.h"
|
|
|
|
#include "public_editor.h"
|
|
|
|
#include "step_editor.h"
|
|
|
|
#include "step_entry.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
StepEditor::StepEditor (PublicEditor& e, boost::shared_ptr<MidiTrack> t, MidiTimeAxisView& mtv)
|
2015-01-07 20:12:14 -05:00
|
|
|
: _editor (e)
|
|
|
|
, _track (t)
|
|
|
|
, step_editor (0)
|
|
|
|
, _mtv (mtv)
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
|
|
|
step_edit_insert_position = 0;
|
2015-01-07 20:12:14 -05:00
|
|
|
_step_edit_triplet_countdown = 0;
|
|
|
|
_step_edit_within_chord = 0;
|
|
|
|
_step_edit_chord_duration = Evoral::Beats();
|
|
|
|
step_edit_region_view = 0;
|
|
|
|
|
|
|
|
_track->PlaylistChanged.connect (*this, invalidator (*this),
|
|
|
|
boost::bind (&StepEditor::playlist_changed, this),
|
|
|
|
gui_context());
|
|
|
|
playlist_changed ();
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
StepEditor::~StepEditor()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
delete step_editor;
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::start_step_editing ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
_step_edit_triplet_countdown = 0;
|
|
|
|
_step_edit_within_chord = 0;
|
|
|
|
_step_edit_chord_duration = Evoral::Beats();
|
|
|
|
step_edit_region.reset ();
|
|
|
|
step_edit_region_view = 0;
|
|
|
|
last_added_pitch = -1;
|
|
|
|
last_added_end = Evoral::Beats();
|
|
|
|
|
|
|
|
resync_step_edit_position ();
|
|
|
|
prepare_step_edit_region ();
|
|
|
|
reset_step_edit_beat_pos ();
|
|
|
|
|
|
|
|
assert (step_edit_region);
|
|
|
|
assert (step_edit_region_view);
|
|
|
|
|
|
|
|
if (step_editor == 0) {
|
|
|
|
step_editor = new StepEntry (*this);
|
|
|
|
step_editor->signal_delete_event().connect (sigc::mem_fun (*this, &StepEditor::step_editor_hidden));
|
|
|
|
step_editor->signal_hide().connect (sigc::mem_fun (*this, &StepEditor::step_editor_hide));
|
|
|
|
}
|
|
|
|
|
|
|
|
step_edit_region_view->show_step_edit_cursor (step_edit_beat_pos);
|
|
|
|
step_edit_region_view->set_step_edit_cursor_width (step_editor->note_length());
|
|
|
|
|
|
|
|
step_editor->present ();
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::resync_step_edit_position ()
|
|
|
|
{
|
2015-04-21 11:16:00 -04:00
|
|
|
step_edit_insert_position = _editor.get_preferred_edit_position (Editing::EDIT_IGNORE_NONE, false, true);
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::resync_step_edit_to_edit_point ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
resync_step_edit_position ();
|
|
|
|
if (step_edit_region) {
|
|
|
|
reset_step_edit_beat_pos ();
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::prepare_step_edit_region ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
boost::shared_ptr<Region> r = _track->playlist()->top_region_at (step_edit_insert_position);
|
2010-08-15 12:39:51 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (r) {
|
|
|
|
step_edit_region = boost::dynamic_pointer_cast<MidiRegion>(r);
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
|
|
|
|
if (step_edit_region) {
|
|
|
|
RegionView* rv = _mtv.midi_view()->find_view (step_edit_region);
|
|
|
|
step_edit_region_view = dynamic_cast<MidiRegionView*> (rv);
|
|
|
|
|
|
|
|
} else {
|
2010-08-20 08:01:13 -04:00
|
|
|
|
|
|
|
const Meter& m = _mtv.session()->tempo_map().meter_at (step_edit_insert_position);
|
|
|
|
const Tempo& t = _mtv.session()->tempo_map().tempo_at (step_edit_insert_position);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
step_edit_region = _mtv.add_region (step_edit_insert_position, floor (m.frames_per_bar (t, _mtv.session()->frame_rate())), true);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
RegionView* rv = _mtv.midi_view()->find_view (step_edit_region);
|
|
|
|
step_edit_region_view = dynamic_cast<MidiRegionView*>(rv);
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::reset_step_edit_beat_pos ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
assert (step_edit_region);
|
|
|
|
assert (step_edit_region_view);
|
2010-08-15 12:39:51 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
framecnt_t frames_from_start = _editor.get_preferred_edit_position() - step_edit_region->position();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (frames_from_start < 0) {
|
|
|
|
/* this can happen with snap enabled, and the edit point == Playhead. we snap the
|
|
|
|
position of the new region, and it can end up after the edit point.
|
|
|
|
*/
|
|
|
|
frames_from_start = 0;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
step_edit_beat_pos = step_edit_region_view->region_frames_to_region_beats (frames_from_start);
|
|
|
|
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
StepEditor::step_editor_hidden (GdkEventAny*)
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
step_editor_hide ();
|
|
|
|
return true; // XXX remember position ?!
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::step_editor_hide ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
/* everything else will follow the change in the model */
|
2010-08-15 12:39:51 -04:00
|
|
|
_track->set_step_editing (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::stop_step_editing ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
if (step_editor) {
|
|
|
|
step_editor->hide ();
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (step_edit_region_view) {
|
|
|
|
step_edit_region_view->hide_step_edit_cursor();
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
step_edit_region.reset ();
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::check_step_edit ()
|
|
|
|
{
|
2010-12-03 17:26:29 -05:00
|
|
|
MidiRingBuffer<framepos_t>& incoming (_track->step_edit_ring_buffer());
|
2010-08-15 12:39:51 -04:00
|
|
|
uint8_t* buf;
|
|
|
|
uint32_t bufsize = 32;
|
|
|
|
|
|
|
|
buf = new uint8_t[bufsize];
|
|
|
|
|
|
|
|
while (incoming.read_space()) {
|
2010-12-03 17:26:29 -05:00
|
|
|
framepos_t time;
|
2010-08-15 12:39:51 -04:00
|
|
|
Evoral::EventType type;
|
|
|
|
uint32_t size;
|
|
|
|
|
|
|
|
incoming.read_prefix (&time, &type, &size);
|
|
|
|
|
|
|
|
if (size > bufsize) {
|
|
|
|
delete [] buf;
|
|
|
|
bufsize = size;
|
|
|
|
buf = new uint8_t[bufsize];
|
|
|
|
}
|
|
|
|
|
|
|
|
incoming.read_contents (size, buf);
|
|
|
|
|
|
|
|
if ((buf[0] & 0xf0) == MIDI_CMD_NOTE_ON) {
|
2015-01-07 00:12:07 -05:00
|
|
|
step_add_note (buf[0] & 0xf, buf[1], buf[2], Evoral::Beats());
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-11-13 00:14:48 -05:00
|
|
|
StepEditor::step_add_bank_change (uint8_t /*channel*/, uint8_t /*bank*/)
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
return 0;
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-11-13 00:14:48 -05:00
|
|
|
StepEditor::step_add_program_change (uint8_t /*channel*/, uint8_t /*program*/)
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
return 0;
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-07 00:12:07 -05:00
|
|
|
StepEditor::step_edit_sustain (Evoral::Beats beats)
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
if (step_edit_region_view) {
|
|
|
|
step_edit_region_view->step_sustain (beats);
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-07 00:12:07 -05:00
|
|
|
StepEditor::move_step_edit_beat_pos (Evoral::Beats beats)
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
2015-07-04 06:33:10 -04:00
|
|
|
if (!step_edit_region_view) {
|
|
|
|
return;
|
|
|
|
}
|
2015-01-07 20:12:14 -05:00
|
|
|
if (beats > 0.0) {
|
|
|
|
step_edit_beat_pos = min (step_edit_beat_pos + beats,
|
|
|
|
step_edit_region_view->region_frames_to_region_beats (step_edit_region->length()));
|
|
|
|
} else if (beats < 0.0) {
|
|
|
|
if (-beats < step_edit_beat_pos) {
|
|
|
|
step_edit_beat_pos += beats; // its negative, remember
|
|
|
|
} else {
|
|
|
|
step_edit_beat_pos = Evoral::Beats();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2015-01-07 00:12:07 -05:00
|
|
|
StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evoral::Beats beat_duration)
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
/* do these things in case undo removed the step edit region
|
|
|
|
*/
|
|
|
|
if (!step_edit_region) {
|
|
|
|
resync_step_edit_position ();
|
|
|
|
prepare_step_edit_region ();
|
|
|
|
reset_step_edit_beat_pos ();
|
|
|
|
step_edit_region_view->show_step_edit_cursor (step_edit_beat_pos);
|
|
|
|
step_edit_region_view->set_step_edit_cursor_width (step_editor->note_length());
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
assert (step_edit_region);
|
|
|
|
assert (step_edit_region_view);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (beat_duration == 0.0 && step_editor) {
|
|
|
|
beat_duration = step_editor->note_length();
|
|
|
|
} else if (beat_duration == 0.0) {
|
|
|
|
bool success;
|
|
|
|
beat_duration = _editor.get_grid_type_as_beats (success, step_edit_insert_position);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (!success) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
MidiStreamView* msv = _mtv.midi_view();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
/* make sure its visible on the vertical axis */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (pitch < msv->lowest_note() || pitch > msv->highest_note()) {
|
|
|
|
msv->update_note_range (pitch);
|
|
|
|
msv->set_note_range (MidiStreamView::ContentsRange);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
/* make sure its visible on the horizontal axis */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
framepos_t fpos = step_edit_region_view->region_beats_to_absolute_frames (step_edit_beat_pos + beat_duration);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (fpos >= (_editor.leftmost_sample() + _editor.current_page_samples())) {
|
|
|
|
_editor.reset_x_origin (fpos - (_editor.current_page_samples()/4));
|
|
|
|
}
|
2010-08-15 17:18:00 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
Evoral::Beats at = step_edit_beat_pos;
|
|
|
|
Evoral::Beats len = beat_duration;
|
2010-08-15 17:18:00 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if ((last_added_pitch >= 0) && (pitch == last_added_pitch) && (last_added_end == step_edit_beat_pos)) {
|
2010-08-15 17:18:00 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
/* avoid any apparent note overlap - move the start of this note
|
|
|
|
up by 1 tick from where the last note ended
|
|
|
|
*/
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
at += Evoral::Beats::ticks(1);
|
|
|
|
len -= Evoral::Beats::ticks(1);
|
|
|
|
}
|
2010-08-15 17:18:00 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
step_edit_region_view->step_add_note (channel, pitch, velocity, at, len);
|
2010-08-15 17:18:00 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
last_added_pitch = pitch;
|
|
|
|
last_added_end = at+len;
|
2010-08-15 17:18:00 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (_step_edit_triplet_countdown > 0) {
|
|
|
|
_step_edit_triplet_countdown--;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (_step_edit_triplet_countdown == 0) {
|
|
|
|
_step_edit_triplet_countdown = 3;
|
|
|
|
}
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (!_step_edit_within_chord) {
|
|
|
|
step_edit_beat_pos += beat_duration;
|
|
|
|
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
|
|
|
|
} else {
|
|
|
|
step_edit_beat_pos += Evoral::Beats::ticks(1); // tiny, but no longer overlapping
|
|
|
|
_step_edit_chord_duration = max (_step_edit_chord_duration, beat_duration);
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
return 0;
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-07 00:12:07 -05:00
|
|
|
StepEditor::set_step_edit_cursor_width (Evoral::Beats beats)
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
if (step_edit_region_view) {
|
|
|
|
step_edit_region_view->set_step_edit_cursor_width (beats);
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
StepEditor::step_edit_within_triplet() const
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
return _step_edit_triplet_countdown > 0;
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
StepEditor::step_edit_within_chord() const
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
return _step_edit_within_chord;
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::step_edit_toggle_triplet ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
if (_step_edit_triplet_countdown == 0) {
|
|
|
|
_step_edit_within_chord = false;
|
|
|
|
_step_edit_triplet_countdown = 3;
|
|
|
|
} else {
|
|
|
|
_step_edit_triplet_countdown = 0;
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::step_edit_toggle_chord ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
if (_step_edit_within_chord) {
|
|
|
|
_step_edit_within_chord = false;
|
2015-07-04 06:33:10 -04:00
|
|
|
if (step_edit_region_view) {
|
|
|
|
step_edit_beat_pos += _step_edit_chord_duration;
|
|
|
|
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
|
|
|
|
}
|
2015-01-07 20:12:14 -05:00
|
|
|
} else {
|
|
|
|
_step_edit_triplet_countdown = 0;
|
|
|
|
_step_edit_within_chord = true;
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-07 00:12:07 -05:00
|
|
|
StepEditor::step_edit_rest (Evoral::Beats beats)
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
|
|
|
bool success;
|
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (beats == 0.0) {
|
|
|
|
beats = _editor.get_grid_type_as_beats (success, step_edit_insert_position);
|
|
|
|
} else {
|
|
|
|
success = true;
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
|
2015-07-04 06:33:10 -04:00
|
|
|
if (success && step_edit_region_view) {
|
2015-01-07 20:12:14 -05:00
|
|
|
step_edit_beat_pos += beats;
|
|
|
|
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
void
|
2010-08-15 12:39:51 -04:00
|
|
|
StepEditor::step_edit_beat_sync ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
step_edit_beat_pos = step_edit_beat_pos.round_up_to_beat();
|
2015-07-04 06:33:10 -04:00
|
|
|
if (step_edit_region_view) {
|
|
|
|
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
void
|
2010-08-15 12:39:51 -04:00
|
|
|
StepEditor::step_edit_bar_sync ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
Session* _session = _mtv.session ();
|
2010-08-15 12:39:51 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
if (!_session || !step_edit_region_view || !step_edit_region) {
|
|
|
|
return;
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
|
2015-01-07 20:12:14 -05:00
|
|
|
framepos_t fpos = step_edit_region_view->region_beats_to_absolute_frames (step_edit_beat_pos);
|
|
|
|
fpos = _session->tempo_map().round_to_bar (fpos, RoundUpAlways);
|
|
|
|
step_edit_beat_pos = step_edit_region_view->region_frames_to_region_beats (fpos - step_edit_region->position()).round_up_to_beat();
|
|
|
|
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::playlist_changed ()
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
step_edit_region_connection.disconnect ();
|
|
|
|
_track->playlist()->RegionRemoved.connect (step_edit_region_connection, invalidator (*this),
|
|
|
|
boost::bind (&StepEditor::region_removed, this, _1),
|
|
|
|
gui_context());
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepEditor::region_removed (boost::weak_ptr<Region> wr)
|
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
boost::shared_ptr<Region> r (wr.lock());
|
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (step_edit_region == r) {
|
|
|
|
step_edit_region.reset();
|
|
|
|
step_edit_region_view = 0;
|
|
|
|
// force a recompute of the insert position
|
|
|
|
step_edit_beat_pos = Evoral::Beats(-1);
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
string
|
2011-06-01 13:00:29 -04:00
|
|
|
StepEditor::name() const
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
2015-01-07 20:12:14 -05:00
|
|
|
return _track->name();
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|