poor man's display of end tempo for ramps.
[ardour.git] / gtk2_ardour / editor_tempodisplay.cc
1 /*
2     Copyright (C) 2002 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifdef WAF_BUILD
21 #include "gtk2ardour-config.h"
22 #endif
23
24 #include <cstdio> // for sprintf, grrr
25 #include <cstdlib>
26 #include <cmath>
27 #include <string>
28 #include <climits>
29
30 #include "pbd/error.h"
31 #include "pbd/memento_command.h"
32
33 #include <gtkmm2ext/utils.h>
34 #include <gtkmm2ext/gtk_ui.h>
35
36 #include "ardour/session.h"
37 #include "ardour/tempo.h"
38 #include <gtkmm2ext/doi.h>
39 #include <gtkmm2ext/utils.h>
40
41 #include "canvas/canvas.h"
42 #include "canvas/item.h"
43 #include "canvas/line_set.h"
44
45 #include "editor.h"
46 #include "marker.h"
47 #include "tempo_dialog.h"
48 #include "rgb_macros.h"
49 #include "gui_thread.h"
50 #include "time_axis_view.h"
51 #include "tempo_lines.h"
52 #include "ui_config.h"
53
54 #include "pbd/i18n.h"
55
56 using namespace std;
57 using namespace ARDOUR;
58 using namespace PBD;
59 using namespace Gtk;
60 using namespace Gtkmm2ext;
61 using namespace Editing;
62
63 void
64 Editor::remove_metric_marks ()
65 {
66         /* don't delete these while handling events, just punt till the GUI is idle */
67
68         for (Marks::iterator x = metric_marks.begin(); x != metric_marks.end(); ++x) {
69                 delete_when_idle (*x);
70         }
71         metric_marks.clear ();
72
73         for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ++x) {
74                 delete (*x);
75         }
76         tempo_curves.clear ();
77 }
78 struct CurveComparator {
79         bool operator() (TempoCurve const * a, TempoCurve const * b) {
80                 return a->tempo().frame() < b->tempo().frame();
81         }
82 };
83 void
84 Editor::draw_metric_marks (const Metrics& metrics)
85 {
86         char buf[64];
87         TempoSection* prev_ts = 0;
88         double max_tempo = 0.0;
89         double min_tempo = DBL_MAX;
90
91         remove_metric_marks (); // also clears tempo curves
92
93         for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
94                 const MeterSection *ms;
95                 TempoSection *ts;
96
97                 if ((ms = dynamic_cast<const MeterSection*>(*i)) != 0) {
98                         snprintf (buf, sizeof(buf), "%g/%g", ms->divisions_per_bar(), ms->note_divisor ());
99                         if (ms->position_lock_style() == MusicTime) {
100                                 metric_marks.push_back (new MeterMarker (*this, *meter_group, UIConfiguration::instance().color ("meter marker music"), buf,
101                                                                          *(const_cast<MeterSection*>(ms))));
102                         } else {
103                                 metric_marks.push_back (new MeterMarker (*this, *meter_group, UIConfiguration::instance().color ("meter marker"), buf,
104                                                                          *(const_cast<MeterSection*>(ms))));
105                         }
106                 } else if ((ts = dynamic_cast<TempoSection*>(*i)) != 0) {
107
108                         if (ts->type() == TempoSection::Constant) {
109                                 if (ts->note_type() != 4.0) {
110                                         snprintf (buf, sizeof (buf), "%.3f/%.0f", ts->note_types_per_minute(), ts->note_type());
111                                 } else {
112                                         snprintf (buf, sizeof (buf), "%.3f", ts->note_types_per_minute());
113                                 }
114                         } else {
115                                 if (ts->note_type() != 4.0) {
116                                         snprintf (buf, sizeof (buf), "%.3f/%.0f>%.3f", ts->note_types_per_minute(), ts->note_type(), ts->end_note_types_per_minute());
117                                 } else {
118                                         snprintf (buf, sizeof (buf), "%.3f>%.3f", ts->note_types_per_minute(), ts->end_note_types_per_minute());
119                                 }
120                         }
121                         max_tempo = max (max_tempo, ts->note_types_per_minute());
122                         max_tempo = max (max_tempo, ts->end_note_types_per_minute());
123                         min_tempo = min (min_tempo, ts->note_types_per_minute());
124                         min_tempo = min (min_tempo, ts->end_note_types_per_minute());
125                         uint32_t const tc_color = UIConfiguration::instance().color ("tempo curve");
126
127                         tempo_curves.push_back (new TempoCurve (*this, *tempo_group, tc_color,
128                                                                 *(const_cast<TempoSection*>(ts)), ts->frame(), false));
129
130                         if (ts->position_lock_style() == MusicTime) {
131                                 metric_marks.push_back (new TempoMarker (*this, *tempo_group, UIConfiguration::instance().color ("tempo marker music"), buf,
132                                                                  *(const_cast<TempoSection*>(ts))));
133                         } else {
134                                 metric_marks.push_back (new TempoMarker (*this, *tempo_group, UIConfiguration::instance().color ("tempo marker"), buf,
135                                                                  *(const_cast<TempoSection*>(ts))));
136                         }
137                         if (prev_ts && abs (prev_ts->end_note_types_per_minute() - ts->note_types_per_minute()) < 1.0) {
138                                 metric_marks.back()->set_points_color (UIConfiguration::instance().color ("tempo marker music"));
139                         } else {
140                                 metric_marks.back()->set_points_color (UIConfiguration::instance().color ("tempo marker"));
141                         }
142                         prev_ts = ts;
143                 }
144
145         }
146         tempo_curves.sort (CurveComparator());
147
148         const double min_tempo_range = 5.0;
149         const double tempo_delta = fabs (max_tempo - min_tempo);
150
151         if (tempo_delta < min_tempo_range) {
152                 max_tempo += min_tempo_range - tempo_delta;
153                 min_tempo += tempo_delta - min_tempo_range;
154         }
155
156         for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ) {
157                 Curves::iterator tmp = x;
158                 (*x)->set_max_tempo (max_tempo);
159                 (*x)->set_min_tempo (min_tempo);
160                 ++tmp;
161                 if (tmp != tempo_curves.end()) {
162                         (*x)->set_position ((*x)->tempo().frame(), (*tmp)->tempo().frame());
163                 } else {
164                         (*x)->set_position ((*x)->tempo().frame(), UINT32_MAX);
165                 }
166
167                 if (!(*x)->tempo().active()) {
168                         (*x)->hide();
169                 } else {
170                         (*x)->show();
171                 }
172
173                 ++x;
174         }
175
176         for (Marks::iterator x = metric_marks.begin(); x != metric_marks.end(); ++x) {
177                 TempoMarker* tempo_marker;
178
179                 if ((tempo_marker = dynamic_cast<TempoMarker*> (*x)) != 0) {
180                         tempo_marker->update_height_mark ((tempo_marker->tempo().note_types_per_minute() - min_tempo) / max (10.0, max_tempo - min_tempo));
181                 }
182         }
183 }
184
185
186 void
187 Editor::tempo_map_changed (const PropertyChange& /*ignored*/)
188 {
189         if (!_session) {
190                 return;
191         }
192
193         ENSURE_GUI_THREAD (*this, &Editor::tempo_map_changed, ignored);
194
195         if (tempo_lines) {
196                 tempo_lines->tempo_map_changed();
197         }
198
199         compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_samples());
200         std::vector<TempoMap::BBTPoint> grid;
201         if (bbt_ruler_scale != bbt_show_many) {
202                 compute_current_bbt_points (grid, leftmost_frame, leftmost_frame + current_page_samples());
203         }
204         _session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); // redraw metric markers
205         draw_measures (grid);
206         update_tempo_based_rulers ();
207 }
208
209 void
210 Editor::tempometric_position_changed (const PropertyChange& /*ignored*/)
211 {
212         if (!_session) {
213                 return;
214         }
215
216         ENSURE_GUI_THREAD (*this, &Editor::tempo_map_changed);
217
218         if (tempo_lines) {
219                 tempo_lines->tempo_map_changed();
220         }
221
222         TempoSection* prev_ts = 0;
223         double max_tempo = 0.0;
224         double min_tempo = DBL_MAX;
225
226         for (Marks::iterator x = metric_marks.begin(); x != metric_marks.end(); ++x) {
227                 TempoMarker* tempo_marker;
228                 MeterMarker* meter_marker;
229                 TempoSection *ts;
230                 const MeterSection *ms;
231
232                 if ((tempo_marker = dynamic_cast<TempoMarker*> (*x)) != 0) {
233                         if ((ts = &tempo_marker->tempo()) != 0) {
234
235                                 tempo_marker->set_position (ts->frame ());
236                                 char buf[64];
237
238                                 if (prev_ts && abs (prev_ts->end_note_types_per_minute() - ts->note_types_per_minute()) < 1.0) {
239                                         tempo_marker->set_points_color (UIConfiguration::instance().color ("tempo marker music"));
240                                 } else {
241                                         tempo_marker->set_points_color (UIConfiguration::instance().color ("tempo marker"));
242                                 }
243
244                                 if (ts->type() == TempoSection::Constant) {
245                                         if (ts->note_type() != 4.0) {
246                                                 snprintf (buf, sizeof (buf), "%.3f/%.0f", ts->note_types_per_minute(), ts->note_type());
247                                         } else {
248                                                 snprintf (buf, sizeof (buf), "%.3f", ts->note_types_per_minute());
249                                         }
250                                 } else {
251                                         if (ts->note_type() != 4.0) {
252                                                 snprintf (buf, sizeof (buf), "%.3f/%.0f>%.3f", ts->note_types_per_minute(), ts->note_type(), ts->end_note_types_per_minute());
253                                         } else {
254                                                 snprintf (buf, sizeof (buf), "%.3f>%.3f", ts->note_types_per_minute(), ts->end_note_types_per_minute());
255                                         }
256                                 }
257
258                                 tempo_marker->set_name (buf);
259
260                                 max_tempo = max (max_tempo, ts->note_types_per_minute());
261                                 max_tempo = max (max_tempo, ts->end_note_types_per_minute());
262                                 min_tempo = min (min_tempo, ts->note_types_per_minute());
263                                 min_tempo = min (min_tempo, ts->end_note_types_per_minute());
264
265                                 prev_ts = ts;
266                         }
267                 }
268                 if ((meter_marker = dynamic_cast<MeterMarker*> (*x)) != 0) {
269                         if ((ms = &meter_marker->meter()) != 0) {
270                                 meter_marker->set_position (ms->frame ());
271                         }
272                 }
273         }
274
275         tempo_curves.sort (CurveComparator());
276
277         const double min_tempo_range = 5.0;
278         const double tempo_delta = fabs (max_tempo - min_tempo);
279
280         if (tempo_delta < min_tempo_range) {
281                 max_tempo += min_tempo_range - tempo_delta;
282                 min_tempo += tempo_delta - min_tempo_range;
283         }
284
285         for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ) {
286                 Curves::iterator tmp = x;
287                 (*x)->set_max_tempo (max_tempo);
288                 (*x)->set_min_tempo (min_tempo);
289                 ++tmp;
290                 if (tmp != tempo_curves.end()) {
291                         (*x)->set_position ((*x)->tempo().frame(), (*tmp)->tempo().frame());
292                 } else {
293                         (*x)->set_position ((*x)->tempo().frame(), UINT32_MAX);
294                 }
295
296                 if (!(*x)->tempo().active()) {
297                         (*x)->hide();
298                 } else {
299                         (*x)->show();
300                 }
301
302                 ++x;
303         }
304
305         for (Marks::iterator x = metric_marks.begin(); x != metric_marks.end(); ++x) {
306                 TempoMarker* tempo_marker;
307                 if ((tempo_marker = dynamic_cast<TempoMarker*> (*x)) != 0) {
308                         tempo_marker->update_height_mark ((tempo_marker->tempo().note_types_per_minute() - min_tempo) / max (max_tempo - min_tempo, 10.0));
309                 }
310         }
311
312         compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_samples());
313         std::vector<TempoMap::BBTPoint> grid;
314
315         if (bbt_ruler_scale != bbt_show_many) {
316                 compute_current_bbt_points (grid, leftmost_frame, leftmost_frame + current_page_samples());
317         }
318
319         draw_measures (grid);
320         update_tempo_based_rulers ();
321 }
322
323 void
324 Editor::redisplay_tempo (bool immediate_redraw)
325 {
326         if (!_session) {
327                 return;
328         }
329
330         if (immediate_redraw) {
331                 compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_samples());
332                 std::vector<TempoMap::BBTPoint> grid;
333
334                 if (bbt_ruler_scale != bbt_show_many) {
335                         compute_current_bbt_points (grid, leftmost_frame, leftmost_frame + current_page_samples());
336                 }
337
338                 draw_measures (grid);
339                 update_tempo_based_rulers (); // redraw rulers and measure lines
340
341         } else {
342                 Glib::signal_idle().connect (sigc::bind_return (sigc::bind (sigc::mem_fun (*this, &Editor::redisplay_tempo), true), false));
343         }
344 }
345 void
346 Editor::tempo_curve_selected (TempoSection* ts, bool yn)
347 {
348         for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ++x) {
349                 if (&(*x)->tempo() == ts) {
350                         (*x)->set_selected (yn);
351                         if (yn) {
352                                 (*x)->set_color_rgba (UIConfiguration::instance().color ("location marker"));
353                         } else {
354                                 (*x)->set_color_rgba (UIConfiguration::instance().color ("tempo curve"));
355                         }
356                         break;
357                 }
358         }
359 }
360
361 /* computes a grid starting a beat before and ending a beat after leftmost and rightmost respectively */
362 void
363 Editor::compute_current_bbt_points (std::vector<TempoMap::BBTPoint>& grid, framepos_t leftmost, framepos_t rightmost)
364 {
365         if (!_session) {
366                 return;
367         }
368
369         /* prevent negative values of leftmost from creeping into tempomap
370          */
371         const double lower_beat = floor (max (0.0, _session->tempo_map().beat_at_frame (leftmost))) - 1.0;
372         switch (bbt_ruler_scale) {
373
374         case bbt_show_beats:
375         case bbt_show_ticks:
376         case bbt_show_ticks_detail:
377         case bbt_show_ticks_super_detail:
378                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost);
379                 break;
380
381         case bbt_show_1:
382                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost, 1);
383                 break;
384
385         case bbt_show_4:
386                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost, 4);
387                 break;
388
389         case bbt_show_16:
390                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost, 16);
391                 break;
392
393         case bbt_show_64:
394                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost, 64);
395                 break;
396
397         default:
398                 /* bbt_show_many */
399                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost, 128);
400                 break;
401         }
402 }
403
404 void
405 Editor::hide_measures ()
406 {
407         if (tempo_lines) {
408                 tempo_lines->hide();
409         }
410 }
411
412 void
413 Editor::draw_measures (std::vector<ARDOUR::TempoMap::BBTPoint>& grid)
414 {
415         if (_session == 0 || _show_measures == false || distance (grid.begin(), grid.end()) == 0) {
416                 return;
417         }
418
419         if (tempo_lines == 0) {
420                 tempo_lines = new TempoLines (time_line_group, ArdourCanvas::LineSet::Vertical);
421         }
422
423         const unsigned divisions = get_grid_beat_divisions(leftmost_frame);
424         tempo_lines->draw (grid, divisions, leftmost_frame, _session->frame_rate());
425 }
426
427 void
428 Editor::mouse_add_new_tempo_event (framepos_t frame)
429 {
430         if (_session == 0) {
431                 return;
432         }
433
434         TempoMap& map(_session->tempo_map());
435
436         begin_reversible_command (_("add tempo mark"));
437         const double pulse = map.exact_qn_at_frame (frame, get_grid_music_divisions (0)) / 4.0;
438
439         if (pulse > 0.0) {
440                 XMLNode &before = map.get_state();
441                 /* add music-locked ramped (?) tempo using the bpm/note type at frame*/
442                 map.add_tempo (map.tempo_at_frame (frame), pulse, 0, MusicTime);
443
444                 XMLNode &after = map.get_state();
445                 _session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
446                 commit_reversible_command ();
447         }
448
449         //map.dump (cerr);
450 }
451
452 void
453 Editor::mouse_add_new_meter_event (framepos_t frame)
454 {
455         if (_session == 0) {
456                 return;
457         }
458
459
460         TempoMap& map(_session->tempo_map());
461         MeterDialog meter_dialog (map, frame, _("add"));
462
463         switch (meter_dialog.run ()) {
464         case RESPONSE_ACCEPT:
465                 break;
466         default:
467                 return;
468         }
469
470         double bpb = meter_dialog.get_bpb ();
471         bpb = max (1.0, bpb); // XXX is this a reasonable limit?
472
473         double note_type = meter_dialog.get_note_type ();
474
475         Timecode::BBT_Time requested;
476         meter_dialog.get_bbt_time (requested);
477
478         const double beat = map.beat_at_bbt (requested);
479         const double al_frame = map.frame_at_beat (beat);
480         begin_reversible_command (_("add meter mark"));
481         XMLNode &before = map.get_state();
482
483         if (meter_dialog.get_lock_style() == MusicTime) {
484                 map.add_meter (Meter (bpb, note_type), beat, requested, 0, MusicTime);
485         } else {
486                 map.add_meter (Meter (bpb, note_type), beat, requested, al_frame, AudioTime);
487         }
488
489         _session->add_command(new MementoCommand<TempoMap>(map, &before, &map.get_state()));
490         commit_reversible_command ();
491
492         //map.dump (cerr);
493 }
494
495 void
496 Editor::remove_tempo_marker (ArdourCanvas::Item* item)
497 {
498         ArdourMarker* marker;
499         TempoMarker* tempo_marker;
500
501         if ((marker = reinterpret_cast<ArdourMarker *> (item->get_data ("marker"))) == 0) {
502                 fatal << _("programming error: tempo marker canvas item has no marker object pointer!") << endmsg;
503                 abort(); /*NOTREACHED*/
504         }
505
506         if ((tempo_marker = dynamic_cast<TempoMarker*> (marker)) == 0) {
507                 fatal << _("programming error: marker for tempo is not a tempo marker!") << endmsg;
508                 abort(); /*NOTREACHED*/
509         }
510
511         if (!tempo_marker->tempo().locked_to_meter() && tempo_marker->tempo().active()) {
512                 Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::real_remove_tempo_marker), &tempo_marker->tempo()));
513         }
514 }
515
516 void
517 Editor::edit_meter_section (MeterSection* section)
518 {
519         MeterDialog meter_dialog (_session->tempo_map(), *section, _("done"));
520
521         switch (meter_dialog.run()) {
522         case RESPONSE_ACCEPT:
523                 break;
524         default:
525                 return;
526         }
527
528         double bpb = meter_dialog.get_bpb ();
529         bpb = max (1.0, bpb); // XXX is this a reasonable limit?
530
531         double const note_type = meter_dialog.get_note_type ();
532         const Meter meter (bpb, note_type);
533
534         Timecode::BBT_Time when;
535         meter_dialog.get_bbt_time (when);
536         const framepos_t frame = _session->tempo_map().frame_at_bbt (when);
537         const PositionLockStyle pls = (meter_dialog.get_lock_style() == AudioTime) ? AudioTime : MusicTime;
538
539         begin_reversible_command (_("replace meter mark"));
540         XMLNode &before = _session->tempo_map().get_state();
541
542         _session->tempo_map().replace_meter (*section, meter, when, frame, pls);
543
544         XMLNode &after = _session->tempo_map().get_state();
545         _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
546         commit_reversible_command ();
547 }
548
549 void
550 Editor::edit_tempo_section (TempoSection* section)
551 {
552         TempoDialog tempo_dialog (_session->tempo_map(), *section, _("done"));
553
554         switch (tempo_dialog.run ()) {
555         case RESPONSE_ACCEPT:
556                 break;
557         default:
558                 return;
559         }
560
561         double bpm = tempo_dialog.get_bpm ();
562         double nt = tempo_dialog.get_note_type ();
563         bpm = max (0.01, bpm);
564         const Tempo tempo (bpm, nt);
565
566         Timecode::BBT_Time when;
567         tempo_dialog.get_bbt_time (when);
568
569         begin_reversible_command (_("replace tempo mark"));
570         XMLNode &before = _session->tempo_map().get_state();
571
572         if (tempo_dialog.get_lock_style() == AudioTime) {
573                 framepos_t const f = _session->tempo_map().predict_tempo_position (section, when).second;
574                 _session->tempo_map().replace_tempo (*section, tempo, 0.0, f, AudioTime);
575         } else {
576                 double const p = _session->tempo_map().predict_tempo_position (section, when).first;
577                 _session->tempo_map().replace_tempo (*section, tempo, p, 0, MusicTime);
578         }
579
580         XMLNode &after = _session->tempo_map().get_state();
581         _session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
582         commit_reversible_command ();
583 }
584
585 void
586 Editor::edit_tempo_marker (TempoMarker& tm)
587 {
588         edit_tempo_section (&tm.tempo());
589 }
590
591 void
592 Editor::edit_meter_marker (MeterMarker& mm)
593 {
594         edit_meter_section (&mm.meter());
595 }
596
597 gint
598 Editor::real_remove_tempo_marker (TempoSection *section)
599 {
600         begin_reversible_command (_("remove tempo mark"));
601         XMLNode &before = _session->tempo_map().get_state();
602         _session->tempo_map().remove_tempo (*section, true);
603         XMLNode &after = _session->tempo_map().get_state();
604         _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
605         commit_reversible_command ();
606
607         return FALSE;
608 }
609
610 void
611 Editor::remove_meter_marker (ArdourCanvas::Item* item)
612 {
613         ArdourMarker* marker;
614         MeterMarker* meter_marker;
615
616         if ((marker = reinterpret_cast<ArdourMarker *> (item->get_data ("marker"))) == 0) {
617                 fatal << _("programming error: meter marker canvas item has no marker object pointer!") << endmsg;
618                 abort(); /*NOTREACHED*/
619         }
620
621         if ((meter_marker = dynamic_cast<MeterMarker*> (marker)) == 0) {
622                 fatal << _("programming error: marker for meter is not a meter marker!") << endmsg;
623                 abort(); /*NOTREACHED*/
624         }
625
626         if (!meter_marker->meter().initial()) {
627           Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::real_remove_meter_marker), &meter_marker->meter()));
628         }
629 }
630
631 gint
632 Editor::real_remove_meter_marker (MeterSection *section)
633 {
634         begin_reversible_command (_("remove tempo mark"));
635         XMLNode &before = _session->tempo_map().get_state();
636         _session->tempo_map().remove_meter (*section, true);
637         XMLNode &after = _session->tempo_map().get_state();
638         _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
639         commit_reversible_command ();
640
641         return FALSE;
642 }