From b0b584c2a595bfdf6bb4b980bd8d8fc7f3546fc5 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 3 Sep 2009 12:39:50 +0000 Subject: the basics of step editing, more details to follow git-svn-id: svn://localhost/ardour2/branches/3.0@5629 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/midi_track.h | 10 +++++++++ libs/ardour/ardour/tempo.h | 2 ++ libs/ardour/ardour/track.h | 4 ++-- libs/ardour/midi_track.cc | 48 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index 5c5ef5c26c..0030fdc520 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -77,6 +77,10 @@ public: NoteMode note_mode() const { return _note_mode; } void set_note_mode (NoteMode m); + + bool step_editing() const { return _step_editing; } + void set_step_editing (bool yn); + MidiRingBuffer& step_edit_ring_buffer() { return _step_edit_ring_buffer; } protected: XMLNode& state (bool full); @@ -93,7 +97,13 @@ private: void set_state_part_three (); MidiRingBuffer _immediate_events; + MidiRingBuffer _step_edit_ring_buffer; NoteMode _note_mode; + bool _step_editing; + + int no_roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, + bool state_changing, bool can_record, bool rec_monitors_input); + void push_midi_input_to_step_edit_ringbuffer (nframes_t nframes); }; } /* namespace ARDOUR*/ diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 843437dab7..49e370c7b4 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -179,6 +179,8 @@ class TempoMap : public PBD::StatefulDestructible nframes_t frame_time (const BBT_Time&) const; nframes_t bbt_duration_at (nframes_t, const BBT_Time&, int dir) const; + void bbt_time_add (nframes64_t origin, BBT_Time& start, const BBT_Time& shift); + static const Tempo& default_tempo() { return _default_tempo; } static const Meter& default_meter() { return _default_meter; } diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index c2f69f0b9b..cb2d05caa6 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -45,8 +45,8 @@ class Track : public Route virtual bool can_use_mode (TrackMode /*m*/, bool& /*bounce_required*/) { return false; } sigc::signal TrackModeChanged; - int no_roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, - bool state_changing, bool can_record, bool rec_monitors_input); + virtual int no_roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, + bool state_changing, bool can_record, bool rec_monitors_input); int silent_roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, bool can_record, bool rec_monitors_input); diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 4c575e8cc4..267cacf787 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -36,6 +36,7 @@ #include "ardour/midi_source.h" #include "ardour/midi_track.h" #include "ardour/panner.h" +#include "ardour/port.h" #include "ardour/processor.h" #include "ardour/route_group_specialized.h" #include "ardour/session.h" @@ -50,7 +51,9 @@ using namespace PBD; MidiTrack::MidiTrack (Session& sess, string name, Route::Flag flag, TrackMode mode) : Track (sess, name, flag, mode, DataType::MIDI) , _immediate_events(1024) // FIXME: size? + , _step_edit_ring_buffer(64) // FIXME: size? , _note_mode(Sustained) + , _step_editing (false) { use_new_diskstream (); @@ -63,7 +66,9 @@ MidiTrack::MidiTrack (Session& sess, string name, Route::Flag flag, TrackMode mo MidiTrack::MidiTrack (Session& sess, const XMLNode& node) : Track (sess, node, DataType::MIDI ) , _immediate_events(1024) // FIXME: size? + , _step_edit_ring_buffer(64) // FIXME: size? , _note_mode(Sustained) + , _step_editing (false) { _set_state(node, false); } @@ -276,6 +281,9 @@ MidiTrack::state(bool full_state) root.add_child_nocopy (_rec_enable_control->get_state()); + root.add_property ("step-editing", (_step_editing ? "yes" : "no")); + root.add_property ("note-mode", enum_2_string (_note_mode)); + return root; } @@ -449,6 +457,41 @@ MidiTrack::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, return 0; } +int +MidiTrack::no_roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, + bool state_changing, bool can_record, bool rec_monitors_input) +{ + int ret = Track::no_roll (nframes, start_frame, end_frame, state_changing, can_record, rec_monitors_input); + + if (ret == 0 && _step_editing) { + push_midi_input_to_step_edit_ringbuffer (nframes); + } + + return ret; +} + +void +MidiTrack::push_midi_input_to_step_edit_ringbuffer (nframes_t nframes) +{ + PortSet& ports (_input->ports()); + + for (PortSet::iterator p = ports.begin(DataType::MIDI); p != ports.end(DataType::MIDI); ++p) { + + Buffer& b (p->get_buffer (nframes)); + const MidiBuffer* const mb = dynamic_cast(&b); + assert (mb); + + for (MidiBuffer::const_iterator e = mb->begin(); e != mb->end(); ++e) { + + const Evoral::MIDIEvent ev(*e, false); + + /* we don't care about the time for this purpose */ + + _step_edit_ring_buffer.write (0, ev.type(), ev.size(), ev.buffer()); + } + } +} + void MidiTrack::write_out_of_band_data (BufferSet& bufs, sframes_t /*start*/, sframes_t /*end*/, nframes_t nframes) { @@ -594,3 +637,8 @@ MidiTrack::MidiControl::set_value(float val) AutomationControl::set_value(val); } +void +MidiTrack::set_step_editing (bool yn) +{ + _step_editing = yn; +} -- cgit v1.2.3