Minor cleanup.
[ardour.git] / gtk2_ardour / step_editor.cc
index f94c4ca9895f2203e3d24df3a2c8086bb41f3813..079644eabc1d28e2b1caae93f7d830456575e65e 100644 (file)
@@ -96,7 +96,12 @@ StepEditor::prepare_step_edit_region ()
                step_edit_region_view = dynamic_cast<MidiRegionView*> (rv);
 
        } else {
-                step_edit_region = _mtv.add_region (step_edit_insert_position);
+
+               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);
+               
+                step_edit_region = _mtv.add_region (step_edit_insert_position, floor (m.frames_per_bar (t, _mtv.session()->frame_rate())), true);
+               
                 RegionView* rv = _mtv.midi_view()->find_view (step_edit_region);
                 step_edit_region_view = dynamic_cast<MidiRegionView*>(rv);
         }
@@ -153,14 +158,14 @@ StepEditor::stop_step_editing ()
 void
 StepEditor::check_step_edit ()
 {
-       MidiRingBuffer<nframes_t>& incoming (_track->step_edit_ring_buffer());
+       MidiRingBuffer<framepos_t>& incoming (_track->step_edit_ring_buffer());
        uint8_t* buf;
        uint32_t bufsize = 32;
 
        buf = new uint8_t[bufsize];
 
        while (incoming.read_space()) {
-               nframes_t time;
+               framepos_t time;
                Evoral::EventType type;
                uint32_t size;
 
@@ -181,13 +186,13 @@ StepEditor::check_step_edit ()
 }
 
 int
-StepEditor::step_add_bank_change (uint8_t channel, uint8_t bank)
+StepEditor::step_add_bank_change (uint8_t /*channel*/, uint8_t /*bank*/)
 {
         return 0;
 }
 
 int
-StepEditor::step_add_program_change (uint8_t channel, uint8_t program)
+StepEditor::step_add_program_change (uint8_t /*channel*/, uint8_t /*program*/)
 {
         return 0;
 }
@@ -268,8 +273,8 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
                    up by 1 tick from where the last note ended
                 */
                 
-                at += 1.0/Meter::ticks_per_beat;
-                len -= 1.0/Meter::ticks_per_beat;
+                at += 1.0/Timecode::BBT_Time::ticks_per_beat;
+                len -= 1.0/Timecode::BBT_Time::ticks_per_beat;
         }
 
         step_edit_region_view->step_add_note (channel, pitch, velocity, at, len);
@@ -289,7 +294,7 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
                 step_edit_beat_pos += beat_duration;
                 step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
         } else {
-                step_edit_beat_pos += 1.0/Meter::ticks_per_beat; // tiny, but no longer overlapping
+                step_edit_beat_pos += 1.0/Timecode::BBT_Time::ticks_per_beat; // tiny, but no longer overlapping
                 _step_edit_chord_duration = max (_step_edit_chord_duration, beat_duration);
         }