fix compilation
[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                         if (yn) {
351                                 (*x)->set_color_rgba (UIConfiguration::instance().color ("location marker"));
352                         } else {
353                                 (*x)->set_color_rgba (UIConfiguration::instance().color ("tempo curve"));
354                         }
355                         break;
356                 }
357         }
358 }
359
360 /* computes a grid starting a beat before and ending a beat after leftmost and rightmost respectively */
361 void
362 Editor::compute_current_bbt_points (std::vector<TempoMap::BBTPoint>& grid, framepos_t leftmost, framepos_t rightmost)
363 {
364         if (!_session) {
365                 return;
366         }
367
368         /* prevent negative values of leftmost from creeping into tempomap
369          */
370         const double lower_beat = floor (max (0.0, _session->tempo_map().beat_at_frame (leftmost))) - 1.0;
371         switch (bbt_ruler_scale) {
372
373         case bbt_show_beats:
374         case bbt_show_ticks:
375         case bbt_show_ticks_detail:
376         case bbt_show_ticks_super_detail:
377                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost);
378                 break;
379
380         case bbt_show_1:
381                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost, 1);
382                 break;
383
384         case bbt_show_4:
385                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost, 4);
386                 break;
387
388         case bbt_show_16:
389                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost, 16);
390                 break;
391
392         case bbt_show_64:
393                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost, 64);
394                 break;
395
396         default:
397                 /* bbt_show_many */
398                 _session->tempo_map().get_grid (grid, max (_session->tempo_map().frame_at_beat (lower_beat), (framepos_t) 0), rightmost, 128);
399                 break;
400         }
401 }
402
403 void
404 Editor::hide_measures ()
405 {
406         if (tempo_lines) {
407                 tempo_lines->hide();
408         }
409 }
410
411 void
412 Editor::draw_measures (std::vector<ARDOUR::TempoMap::BBTPoint>& grid)
413 {
414         if (_session == 0 || _show_measures == false || distance (grid.begin(), grid.end()) == 0) {
415                 return;
416         }
417
418         if (tempo_lines == 0) {
419                 tempo_lines = new TempoLines (time_line_group, ArdourCanvas::LineSet::Vertical);
420         }
421
422         const unsigned divisions = get_grid_beat_divisions(leftmost_frame);
423         tempo_lines->draw (grid, divisions, leftmost_frame, _session->frame_rate());
424 }
425
426 void
427 Editor::mouse_add_new_tempo_event (framepos_t frame)
428 {
429         if (_session == 0) {
430                 return;
431         }
432
433         TempoMap& map(_session->tempo_map());
434
435         begin_reversible_command (_("add tempo mark"));
436         const double pulse = map.exact_qn_at_frame (frame, get_grid_music_divisions (0)) / 4.0;
437
438         if (pulse > 0.0) {
439                 XMLNode &before = map.get_state();
440                 /* add music-locked ramped (?) tempo using the bpm/note type at frame*/
441                 map.add_tempo (map.tempo_at_frame (frame), pulse, 0, MusicTime);
442
443                 XMLNode &after = map.get_state();
444                 _session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
445                 commit_reversible_command ();
446         }
447
448         //map.dump (cerr);
449 }
450
451 void
452 Editor::mouse_add_new_meter_event (framepos_t frame)
453 {
454         if (_session == 0) {
455                 return;
456         }
457
458
459         TempoMap& map(_session->tempo_map());
460         MeterDialog meter_dialog (map, frame, _("add"));
461
462         switch (meter_dialog.run ()) {
463         case RESPONSE_ACCEPT:
464                 break;
465         default:
466                 return;
467         }
468
469         double bpb = meter_dialog.get_bpb ();
470         bpb = max (1.0, bpb); // XXX is this a reasonable limit?
471
472         double note_type = meter_dialog.get_note_type ();
473
474         Timecode::BBT_Time requested;
475         meter_dialog.get_bbt_time (requested);
476
477         const double beat = map.beat_at_bbt (requested);
478         const double al_frame = map.frame_at_beat (beat);
479         begin_reversible_command (_("add meter mark"));
480         XMLNode &before = map.get_state();
481
482         if (meter_dialog.get_lock_style() == MusicTime) {
483                 map.add_meter (Meter (bpb, note_type), beat, requested, 0, MusicTime);
484         } else {
485                 map.add_meter (Meter (bpb, note_type), beat, requested, al_frame, AudioTime);
486         }
487
488         _session->add_command(new MementoCommand<TempoMap>(map, &before, &map.get_state()));
489         commit_reversible_command ();
490
491         //map.dump (cerr);
492 }
493
494 void
495 Editor::remove_tempo_marker (ArdourCanvas::Item* item)
496 {
497         ArdourMarker* marker;
498         TempoMarker* tempo_marker;
499
500         if ((marker = reinterpret_cast<ArdourMarker *> (item->get_data ("marker"))) == 0) {
501                 fatal << _("programming error: tempo marker canvas item has no marker object pointer!") << endmsg;
502                 abort(); /*NOTREACHED*/
503         }
504
505         if ((tempo_marker = dynamic_cast<TempoMarker*> (marker)) == 0) {
506                 fatal << _("programming error: marker for tempo is not a tempo marker!") << endmsg;
507                 abort(); /*NOTREACHED*/
508         }
509
510         if (!tempo_marker->tempo().locked_to_meter() && tempo_marker->tempo().active()) {
511                 Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::real_remove_tempo_marker), &tempo_marker->tempo()));
512         }
513 }
514
515 void
516 Editor::edit_meter_section (MeterSection* section)
517 {
518         MeterDialog meter_dialog (_session->tempo_map(), *section, _("done"));
519
520         switch (meter_dialog.run()) {
521         case RESPONSE_ACCEPT:
522                 break;
523         default:
524                 return;
525         }
526
527         double bpb = meter_dialog.get_bpb ();
528         bpb = max (1.0, bpb); // XXX is this a reasonable limit?
529
530         double const note_type = meter_dialog.get_note_type ();
531         const Meter meter (bpb, note_type);
532
533         Timecode::BBT_Time when;
534         meter_dialog.get_bbt_time (when);
535         const framepos_t frame = _session->tempo_map().frame_at_bbt (when);
536         const PositionLockStyle pls = (meter_dialog.get_lock_style() == AudioTime) ? AudioTime : MusicTime;
537
538         begin_reversible_command (_("replace meter mark"));
539         XMLNode &before = _session->tempo_map().get_state();
540
541         _session->tempo_map().replace_meter (*section, meter, when, frame, pls);
542
543         XMLNode &after = _session->tempo_map().get_state();
544         _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
545         commit_reversible_command ();
546 }
547
548 void
549 Editor::edit_tempo_section (TempoSection* section)
550 {
551         TempoDialog tempo_dialog (_session->tempo_map(), *section, _("done"));
552
553         switch (tempo_dialog.run ()) {
554         case RESPONSE_ACCEPT:
555                 break;
556         default:
557                 return;
558         }
559
560         double bpm = tempo_dialog.get_bpm ();
561         double nt = tempo_dialog.get_note_type ();
562         bpm = max (0.01, bpm);
563         const Tempo tempo (bpm, nt);
564
565         Timecode::BBT_Time when;
566         tempo_dialog.get_bbt_time (when);
567
568         begin_reversible_command (_("replace tempo mark"));
569         XMLNode &before = _session->tempo_map().get_state();
570
571         if (tempo_dialog.get_lock_style() == AudioTime) {
572                 framepos_t const f = _session->tempo_map().predict_tempo_position (section, when).second;
573                 _session->tempo_map().replace_tempo (*section, tempo, 0.0, f, AudioTime);
574         } else {
575                 double const p = _session->tempo_map().predict_tempo_position (section, when).first;
576                 _session->tempo_map().replace_tempo (*section, tempo, p, 0, MusicTime);
577         }
578
579         XMLNode &after = _session->tempo_map().get_state();
580         _session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
581         commit_reversible_command ();
582 }
583
584 void
585 Editor::edit_tempo_marker (TempoMarker& tm)
586 {
587         edit_tempo_section (&tm.tempo());
588 }
589
590 void
591 Editor::edit_meter_marker (MeterMarker& mm)
592 {
593         edit_meter_section (&mm.meter());
594 }
595
596 gint
597 Editor::real_remove_tempo_marker (TempoSection *section)
598 {
599         begin_reversible_command (_("remove tempo mark"));
600         XMLNode &before = _session->tempo_map().get_state();
601         _session->tempo_map().remove_tempo (*section, true);
602         XMLNode &after = _session->tempo_map().get_state();
603         _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
604         commit_reversible_command ();
605
606         return FALSE;
607 }
608
609 void
610 Editor::remove_meter_marker (ArdourCanvas::Item* item)
611 {
612         ArdourMarker* marker;
613         MeterMarker* meter_marker;
614
615         if ((marker = reinterpret_cast<ArdourMarker *> (item->get_data ("marker"))) == 0) {
616                 fatal << _("programming error: meter marker canvas item has no marker object pointer!") << endmsg;
617                 abort(); /*NOTREACHED*/
618         }
619
620         if ((meter_marker = dynamic_cast<MeterMarker*> (marker)) == 0) {
621                 fatal << _("programming error: marker for meter is not a meter marker!") << endmsg;
622                 abort(); /*NOTREACHED*/
623         }
624
625         if (!meter_marker->meter().initial()) {
626           Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::real_remove_meter_marker), &meter_marker->meter()));
627         }
628 }
629
630 gint
631 Editor::real_remove_meter_marker (MeterSection *section)
632 {
633         begin_reversible_command (_("remove tempo mark"));
634         XMLNode &before = _session->tempo_map().get_state();
635         _session->tempo_map().remove_meter (*section, true);
636         XMLNode &after = _session->tempo_map().get_state();
637         _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
638         commit_reversible_command ();
639
640         return FALSE;
641 }