2 Copyright (C) 2010 Paul Davis
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.
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.
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.
20 #include "midi_time_axis.h"
21 #include "step_entry.h"
29 _note_off_event_handler (GtkWidget* widget, int note, gpointer arg)
31 ((StepEntry*)arg)->note_off_event_handler (note);
35 StepEntry::StepEntry (MidiTimeAxisView& mtv)
36 : ArdourDialog (_("Step Entry Editor"))
37 , triplet_button ("3")
38 , sustain_button ("sustain")
39 , rest_button ("rest")
40 , channel_adjustment (0, 15, 0, 1, 4)
41 , channel_spinner (channel_adjustment)
46 RadioButtonGroup length_group = length_1_button.get_group();
47 length_2_button.set_group (length_group);
48 length_4_button.set_group (length_group);
49 length_8_button.set_group (length_group);
50 length_12_button.set_group (length_group);
51 length_16_button.set_group (length_group);
52 length_32_button.set_group (length_group);
53 length_64_button.set_group (length_group);
57 w = manage (new Image (::get_icon (X_("wholenote"))));
59 length_1_button.add (*w);
60 w = manage (new Image (::get_icon (X_("halfnote"))));
62 length_2_button.add (*w);
63 w = manage (new Image (::get_icon (X_("quarternote"))));
65 length_4_button.add (*w);
66 w = manage (new Image (::get_icon (X_("eighthnote"))));
68 length_8_button.add (*w);
69 w = manage (new Image (::get_icon (X_("sixteenthnote"))));
71 length_16_button.add (*w);
72 w = manage (new Image (::get_icon (X_("thirtysecondnote"))));
74 length_32_button.add (*w);
75 w = manage (new Image (::get_icon (X_("sixtyfourthnote"))));
77 length_64_button.add (*w);
79 length_1_button.property_draw_indicator() = false;
80 length_2_button.property_draw_indicator() = false;
81 length_4_button.property_draw_indicator() = false;
82 length_8_button.property_draw_indicator() = false;
83 length_16_button.property_draw_indicator() = false;
84 length_32_button.property_draw_indicator() = false;
85 length_64_button.property_draw_indicator() = false;
87 note_length_box.pack_start (length_1_button, false, false);
88 note_length_box.pack_start (length_2_button, false, false);
89 note_length_box.pack_start (length_4_button, false, false);
90 note_length_box.pack_start (length_8_button, false, false);
91 note_length_box.pack_start (length_16_button, false, false);
92 note_length_box.pack_start (length_32_button, false, false);
93 note_length_box.pack_start (length_64_button, false, false);
95 RadioButtonGroup velocity_group = velocity_ppp_button.get_group();
96 velocity_pp_button.set_group (velocity_group);
97 velocity_p_button.set_group (velocity_group);
98 velocity_mp_button.set_group (velocity_group);
99 velocity_mf_button.set_group (velocity_group);
100 velocity_f_button.set_group (velocity_group);
101 velocity_ff_button.set_group (velocity_group);
102 velocity_fff_button.set_group (velocity_group);
104 w = manage (new Image (::get_icon (X_("pianississimo"))));
106 velocity_ppp_button.add (*w);
107 w = manage (new Image (::get_icon (X_("pianissimo"))));
109 velocity_pp_button.add (*w);
110 w = manage (new Image (::get_icon (X_("piano"))));
112 velocity_p_button.add (*w);
113 w = manage (new Image (::get_icon (X_("mezzopiano"))));
115 velocity_mp_button.add (*w);
116 w = manage (new Image (::get_icon (X_("mezzoforte"))));
118 velocity_mf_button.add (*w);
119 w = manage (new Image (::get_icon (X_("forte"))));
121 velocity_f_button.add (*w);
122 w = manage (new Image (::get_icon (X_("fortissimo"))));
124 velocity_ff_button.add (*w);
125 w = manage (new Image (::get_icon (X_("fortississimo"))));
127 velocity_fff_button.add (*w);
129 velocity_ppp_button.property_draw_indicator() = false;
130 velocity_pp_button.property_draw_indicator() = false;
131 velocity_p_button.property_draw_indicator() = false;
132 velocity_mp_button.property_draw_indicator() = false;
133 velocity_mf_button.property_draw_indicator() = false;
134 velocity_f_button.property_draw_indicator() = false;
135 velocity_ff_button.property_draw_indicator() = false;
136 velocity_fff_button.property_draw_indicator() = false;
138 note_velocity_box.pack_start (velocity_ppp_button, false, false);
139 note_velocity_box.pack_start (velocity_pp_button, false, false);
140 note_velocity_box.pack_start (velocity_p_button, false, false);
141 note_velocity_box.pack_start (velocity_mp_button, false, false);
142 note_velocity_box.pack_start (velocity_mf_button, false, false);
143 note_velocity_box.pack_start (velocity_f_button, false, false);
144 note_velocity_box.pack_start (velocity_ff_button, false, false);
145 note_velocity_box.pack_start (velocity_fff_button, false, false);
147 Label* l = manage (new Label);
148 l->set_markup ("<b><big>.</big></b>");
152 w = manage (new Image (::get_icon (X_("chord"))));
154 chord_button.add (*w);
156 upper_box.set_spacing (6);
157 upper_box.pack_start (chord_button, false, false);
158 upper_box.pack_start (note_length_box, false, false, 12);
159 upper_box.pack_start (triplet_button, false, false);
160 upper_box.pack_start (dot_button, false, false);
161 upper_box.pack_start (sustain_button, false, false);
162 upper_box.pack_start (rest_button, false, false);
163 upper_box.pack_start (note_velocity_box, false, false, 12);
164 upper_box.pack_start (channel_spinner, false, false);
166 _piano = (PianoKeyboard*) piano_keyboard_new ();
167 piano = Glib::wrap ((GtkWidget*) _piano);
169 g_signal_connect(G_OBJECT(_piano), "note-off", G_CALLBACK(_note_off_event_handler), this);
171 rest_button.signal_clicked().connect (sigc::mem_fun (*this, &StepEntry::rest_click));
173 packer.set_spacing (6);
174 packer.pack_start (upper_box, false, false);
175 packer.pack_start (*piano, false, false);
178 get_vbox()->add (packer);
181 StepEntry::~StepEntry()
186 StepEntry::note_off_event_handler (int note)
188 Evoral::MusicalTime length = 1.0;
189 uint8_t velocity = 64;
191 if (length_64_button.get_active()) {
193 } else if (length_32_button.get_active()) {
195 } else if (length_16_button.get_active()) {
197 } else if (length_8_button.get_active()) {
199 } else if (length_4_button.get_active()) {
201 } else if (length_2_button.get_active()) {
203 } else if (length_1_button.get_active()) {
207 if (dot_button.get_active()) {
211 if (velocity_ppp_button.get_active()) {
213 } else if (velocity_pp_button.get_active()) {
215 } else if (velocity_p_button.get_active()) {
217 } else if (velocity_mp_button.get_active()) {
219 } else if (velocity_mf_button.get_active()) {
221 } else if (velocity_f_button.get_active()) {
223 } else if (velocity_ff_button.get_active()) {
225 } else if (velocity_fff_button.get_active()) {
229 if (!triplet_button.get_active()) {
230 _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
233 _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
234 _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
235 _mtv->step_add_note (channel_adjustment.get_value(), note, velocity, length);
240 StepEntry::rest_click ()
242 _mtv->step_edit_rest ();