#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"
#include "ardour/midi_playlist.h"
#include "ardour/midi_port.h"
#include "ardour/midi_region.h"
: 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)
{
_input->changed.connect_same_thread (*this, boost::bind (&MidiTrack::track_input_active, this, _1, _2));
- return 0;
-}
-
-boost::shared_ptr<Diskstream>
-MidiTrack::create_diskstream ()
-{
- MidiDiskstream::Flag dflags = MidiDiskstream::Flag (MidiDiskstream::Recordable);
-
- assert(_mode != Destructive);
+ _disk_writer->set_note_mode (_note_mode);
+ _disk_reader->reset_tracker ();
- return boost::shared_ptr<Diskstream> (new MidiDiskstream (_session, name(), dflags));
+ return 0;
}
-
bool
MidiTrack::can_be_record_safe ()
{
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)
{
}
}
- if (midi_diskstream ()) {
- midi_diskstream()->set_block_size (_session.get_block_size ());
- }
-
return;
}
for (MidiBuffer::const_iterator e = buf.begin(); e != buf.end(); ++e) {
const Evoral::Event<framepos_t>& ev = *e;
const Evoral::Parameter param = midi_parameter(ev.buffer(), ev.size());
- const boost::shared_ptr<Evoral::Control> control = this->control(param);
+ const boost::shared_ptr<AutomationControl> control = automation_control (param);
if (control) {
control->set_double(ev.value(), _session.transport_frame(), false);
+ control->Changed (false, Controllable::NoGroup);
}
}
}
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;
}
if (!_active) {
silence (nframes);
- if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _diskstream->record_enabled())) {
+ if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _disk_writer->record_enabled())) {
_meter->reset();
}
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());
/* filter captured data before meter sees it */
_capture_filter.filter (bufs);
- if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _diskstream->record_enabled())) {
+ if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _disk_writer->record_enabled())) {
_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;
}
(*i)->realtime_locate ();
}
- midi_diskstream()->reset_tracker ();
-}
-
-void
-MidiTrack::realtime_handle_transport_stopped ()
-{
- Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
-
- if (!lm.locked ()) {
- return;
- }
-
- for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
- (*i)->realtime_handle_transport_stopped ();
- }
+ _disk_reader->reset_tracker ();
}
void
{
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;
}
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;
}
MidiTrack::set_note_mode (NoteMode m)
{
_note_mode = m;
- midi_diskstream()->set_note_mode(m);
+ _disk_writer->set_note_mode(m);
}
std::string
boost::shared_ptr<SMFSource>
MidiTrack::write_source (uint32_t)
{
- return midi_diskstream()->write_source ();
+ return _disk_writer->midi_write_source ();
}
void
boost::shared_ptr<MidiPlaylist>
MidiTrack::midi_playlist ()
{
- return midi_diskstream()->midi_playlist ();
-}
-
-void
-MidiTrack::diskstream_data_recorded (boost::weak_ptr<MidiSource> src)
-{
- DataRecorded (src); /* EMIT SIGNAL */
+ return boost::dynamic_pointer_cast<MidiPlaylist> (_playlists[DataType::MIDI]);
}
bool
}
}
-boost::shared_ptr<Diskstream>
-MidiTrack::diskstream_factory (XMLNode const & node)
-{
- return boost::shared_ptr<Diskstream> (new MidiDiskstream (_session, 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
/* 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;
}
}
/* Resolve active notes. */
- midi_diskstream()->resolve_tracker(_immediate_events, Port::port_offset());
+ _disk_reader->resolve_tracker(_immediate_events, Port::port_offset());
}
}
}
}
- boost::shared_ptr<MidiDiskstream> md (midi_diskstream());
-
- if (md) {
- md->reset_tracker ();
- }
+ _disk_reader->reset_tracker ();
}
MonitorState