summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_track.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2017-03-31 17:28:14 +0200
committerPaul Davis <paul@linuxaudiosystems.com>2017-09-18 11:40:52 -0400
commita4a87f56e9dc8e2351101439aeea7a87064fa146 (patch)
tree940715c29eb1fcdd478b1998a9e0caad5032c9df /libs/ardour/midi_track.cc
parent94604c6979be790a072c9d76566250a3aadf6e79 (diff)
mega-commit to save state of first "it compilesand links" state for separated disk i/o changes.
THIS WILL NOT RUN. THIS REQUIRES MANY CHANGES
Diffstat (limited to 'libs/ardour/midi_track.cc')
-rw-r--r--libs/ardour/midi_track.cc129
1 files changed, 22 insertions, 107 deletions
diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc
index 5d315c52a7..6cbf700f03 100644
--- a/libs/ardour/midi_track.cc
+++ b/libs/ardour/midi_track.cc
@@ -33,10 +33,13 @@
#include "pbd/types_convert.h"
#include "evoral/midi_util.h"
+#include "ardour/amp.h"
#include "ardour/beats_frames_converter.h"
#include "ardour/buffer_set.h"
#include "ardour/debug.h"
#include "ardour/delivery.h"
+#include "ardour/disk_reader.h"
+#include "ardour/disk_writer.h"
#include "ardour/event_type_map.h"
#include "ardour/meter.h"
#include "ardour/midi_diskstream.h"
@@ -72,11 +75,15 @@ MidiTrack::MidiTrack (Session& sess, string name, TrackMode mode)
: Track (sess, name, PresentationInfo::MidiTrack, mode, DataType::MIDI)
, _immediate_events(6096) // FIXME: size?
, _step_edit_ring_buffer(64) // FIXME: size?
- , _note_mode(Sustained)
+ , _note_mode (Sustained)
, _step_editing (false)
, _input_active (true)
{
_session.SessionLoaded.connect_same_thread (*this, boost::bind (&MidiTrack::restore_controls, this));
+
+ _disk_writer->set_note_mode (_note_mode);
+ _disk_reader->reset_tracker ();
+
}
MidiTrack::~MidiTrack ()
@@ -126,36 +133,6 @@ MidiTrack::can_be_record_enabled ()
return Track::can_be_record_enabled ();
}
-void
-MidiTrack::set_diskstream (boost::shared_ptr<Diskstream> ds)
-{
- /* We have to do this here, as Track::set_diskstream will cause a buffer refill,
- and the diskstream must be set up to fill its buffers using the correct _note_mode.
- */
- boost::shared_ptr<MidiDiskstream> mds = boost::dynamic_pointer_cast<MidiDiskstream> (ds);
- mds->set_note_mode (_note_mode);
-
- Track::set_diskstream (ds);
-
- mds->reset_tracker ();
-
- _diskstream->set_track (this);
- _diskstream->set_record_enabled (false);
-
- _diskstream_data_recorded_connection.disconnect ();
- mds->DataRecorded.connect_same_thread (
- _diskstream_data_recorded_connection,
- boost::bind (&MidiTrack::diskstream_data_recorded, this, _1));
-
- DiskstreamChanged (); /* EMIT SIGNAL */
-}
-
-boost::shared_ptr<MidiDiskstream>
-MidiTrack::midi_diskstream() const
-{
- return boost::dynamic_pointer_cast<MidiDiskstream>(_diskstream);
-}
-
int
MidiTrack::set_state (const XMLNode& node, int version)
{
@@ -323,10 +300,6 @@ MidiTrack::set_state_part_two ()
}
}
- if (midi_diskstream ()) {
- midi_diskstream()->set_block_size (_session.get_block_size ());
- }
-
return;
}
@@ -364,18 +337,11 @@ int
MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& need_butler)
{
Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
+
if (!lm.locked()) {
- boost::shared_ptr<MidiDiskstream> diskstream = midi_diskstream();
- framecnt_t playback_distance = diskstream->calculate_playback_distance(nframes);
- if (can_internal_playback_seek(::llabs(playback_distance))) {
- /* TODO should declick, and/or note-off */
- internal_playback_seek(playback_distance);
- }
return 0;
}
- boost::shared_ptr<MidiDiskstream> diskstream = midi_diskstream();
-
if (n_outputs().n_total() == 0 && _processors.empty()) {
return 0;
}
@@ -388,22 +354,8 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame
return 0;
}
- framepos_t transport_frame = _session.transport_frame();
-
- int dret;
- framecnt_t playback_distance;
-
- if ((nframes = check_initial_delay (nframes, transport_frame)) == 0) {
- /* need to do this so that the diskstream sets its
- playback distance to zero, thus causing diskstream::commit
- to do nothing.
- */
- BufferSet bufs; /* empty set - is OK, since nothing will happen */
-
- dret = diskstream->process (bufs, transport_frame, 0, playback_distance, false);
- need_butler = diskstream->commit (playback_distance);
- return dret;
- }
+ _silent = false;
+ _amp->apply_gain_automation (false);
BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
@@ -416,47 +368,16 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame
_meter->run (bufs, start_frame, end_frame, 1.0 /*speed()*/, nframes, true);
}
-
- _silent = false;
-
- if ((dret = diskstream->process (bufs, transport_frame, nframes, playback_distance, (monitoring_state() == MonitoringDisk))) != 0) {
- need_butler = diskstream->commit (playback_distance);
- silence (nframes);
- return dret;
- }
-
- /* note diskstream uses our filter to filter/map playback channels appropriately. */
-
- if (monitoring_state() == MonitoringInput) {
-
- /* not actually recording, but we want to hear the input material anyway,
- at least potentially (depending on monitoring options)
- */
-
- /* because the playback buffer is event based and not a
- * continuous stream, we need to make sure that we empty
- * it of events every cycle to avoid it filling up with events
- * read from disk, while we are actually monitoring input
- */
-
- diskstream->flush_playback (start_frame, end_frame);
-
- }
-
-
/* append immediate messages to the first MIDI buffer (thus sending it to the first output port) */
write_out_of_band_data (bufs, start_frame, end_frame, nframes);
/* final argument: don't waste time with automation if we're not recording or rolling */
- process_output_buffers (bufs, start_frame, end_frame, nframes,
- declick, (!diskstream->record_enabled() && !_session.transport_stopped()));
+ process_output_buffers (bufs, start_frame, end_frame, nframes, declick, (!_disk_writer->record_enabled() && !_session.transport_stopped()));
flush_processor_buffers_locked (nframes);
- need_butler = diskstream->commit (playback_distance);
-
return 0;
}
@@ -485,7 +406,7 @@ MidiTrack::realtime_locate ()
(*i)->realtime_locate ();
}
- midi_diskstream()->reset_tracker ();
+ _disk_reader->reset_tracker ();
}
void
@@ -507,7 +428,7 @@ MidiTrack::non_realtime_locate (framepos_t pos)
{
Track::non_realtime_locate(pos);
- boost::shared_ptr<MidiPlaylist> playlist = midi_diskstream()->midi_playlist();
+ boost::shared_ptr<MidiPlaylist> playlist = _disk_writer->midi_playlist();
if (!playlist) {
return;
}
@@ -612,11 +533,9 @@ MidiTrack::export_stuff (BufferSet& buffers,
return -1;
}
- boost::shared_ptr<MidiDiskstream> diskstream = midi_diskstream();
-
Glib::Threads::RWLock::ReaderLock rlock (_processor_lock);
- boost::shared_ptr<MidiPlaylist> mpl = boost::dynamic_pointer_cast<MidiPlaylist>(diskstream->playlist());
+ boost::shared_ptr<MidiPlaylist> mpl = _disk_writer->midi_playlist();
if (!mpl) {
return -2;
}
@@ -665,7 +584,7 @@ void
MidiTrack::set_note_mode (NoteMode m)
{
_note_mode = m;
- midi_diskstream()->set_note_mode(m);
+ _disk_writer->set_note_mode(m);
}
std::string
@@ -809,7 +728,7 @@ MidiTrack::set_step_editing (bool yn)
boost::shared_ptr<SMFSource>
MidiTrack::write_source (uint32_t)
{
- return midi_diskstream()->write_source ();
+ return _disk_writer->midi_write_source ();
}
void
@@ -847,7 +766,7 @@ MidiTrack::set_capture_channel_mask (uint16_t mask)
boost::shared_ptr<MidiPlaylist>
MidiTrack::midi_playlist ()
{
- return midi_diskstream()->midi_playlist ();
+ return boost::dynamic_pointer_cast<MidiPlaylist> (_playlists[DataType::MIDI]);
}
void
@@ -906,7 +825,7 @@ MidiTrack::diskstream_factory (XMLNode const & node)
boost::shared_ptr<MidiBuffer>
MidiTrack::get_gui_feed_buffer () const
{
- return midi_diskstream()->get_gui_feed_buffer ();
+ return _disk_reader->get_gui_feed_buffer ();
}
void
@@ -922,7 +841,7 @@ MidiTrack::act_on_mute ()
/* If we haven't got a diskstream yet, there's nothing to worry about,
and we can't call get_channel_mask() anyway.
*/
- if (!midi_diskstream()) {
+ if (!_disk_writer) {
return;
}
@@ -945,7 +864,7 @@ MidiTrack::act_on_mute ()
}
/* Resolve active notes. */
- midi_diskstream()->resolve_tracker(_immediate_events, Port::port_offset());
+ _disk_reader->resolve_tracker(_immediate_events, Port::port_offset());
}
}
@@ -967,11 +886,7 @@ MidiTrack::monitoring_changed (bool self, Controllable::GroupControlDisposition
}
}
- boost::shared_ptr<MidiDiskstream> md (midi_diskstream());
-
- if (md) {
- md->reset_tracker ();
- }
+ _disk_reader->reset_tracker ();
}
MonitorState