Differentiate between pitch-shift (for audio) and transpose (for MIDI). Fixes #3940.
[ardour.git] / gtk2_ardour / transpose_dialog.cc
1 /*
2     Copyright (C) 2011 Paul Davis
3     Author: Carl Hetherington <cth@carlh.net>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #include <gtkmm/table.h>
22 #include <gtkmm/label.h>
23 #include <gtkmm/stock.h>
24 #include "transpose_dialog.h"
25
26 using namespace Gtk;
27
28 TransposeDialog::TransposeDialog ()
29         : ArdourDialog (_("Transpose MIDI"))
30         , _octaves_adjustment (0.0, -4.0, 4.0, 1, 2.0)
31         , _semitones_adjustment (0.0, -12.0, 12.0, 1.0, 4.0)
32         , _octaves_spinner (_octaves_adjustment)
33         , _semitones_spinner (_semitones_adjustment)
34 {
35         Table* t = manage (new Table (2, 2));
36         t->set_row_spacings (6);
37         t->set_col_spacings (6);
38
39         int r = 0;
40         Label* l = manage (new Label (_("Octaves:"), ALIGN_LEFT, ALIGN_CENTER, false));
41         t->attach (*l, 0, 1, r, r + 1, FILL, EXPAND, 0, 0);
42         t->attach (_octaves_spinner, 1, 2, r, r + 1, FILL, EXPAND & FILL, 0, 0);
43         ++r;
44
45         l = manage (new Label (_("Semitones:"), ALIGN_LEFT, ALIGN_CENTER, false));
46         t->attach (*l, 0, 1, r, r + 1, FILL, EXPAND, 0, 0);
47         t->attach (_semitones_spinner, 1, 2, r, r + 1, FILL, EXPAND & FILL, 0, 0);
48         ++r;
49
50         get_vbox()->set_spacing (6);
51         get_vbox()->pack_start (*t, false, false);
52
53         add_button (Stock::CANCEL, RESPONSE_CANCEL);
54         add_button (_("Transpose"), RESPONSE_ACCEPT);
55
56         show_all_children ();
57 }
58
59 int
60 TransposeDialog::semitones () const
61 {
62         return _octaves_spinner.get_value () * 12 + _semitones_spinner.get_value ();
63 }