Fix recording MIDI
authorRobin Gareus <robin@gareus.org>
Sun, 1 Oct 2017 01:03:44 +0000 (03:03 +0200)
committerRobin Gareus <robin@gareus.org>
Sun, 1 Oct 2017 01:03:44 +0000 (03:03 +0200)
- Fix API call to add region(midi_region) -- set count to "1"
- Forward DataRecorded() signal
- remove botched merge/rebase"
  a4a87f56 accidentally brought back code from old-destructive API
  which was removed in af103cf3 and 08c13007
  There is no per track NonLayered record mode anymore, it's session global.
- set can_record correctly to not accidentally clear last capture sources
  for cont'd recording (toggle track's rec-arm)

libs/ardour/ardour/disk_io.h
libs/ardour/ardour/disk_writer.h
libs/ardour/ardour/midi_track.h
libs/ardour/audio_track.cc
libs/ardour/disk_writer.cc
libs/ardour/midi_track.cc
libs/ardour/track.cc

index 63378c4cac7a463bbbbd5210827431ec2a367914..bb93e51298d4beb0bbaa7b6f00cd6e3279d55265 100644 (file)
@@ -50,7 +50,7 @@ class LIBARDOUR_API DiskIOProcessor : public Processor
                Recordable  = 0x1,
                Hidden      = 0x2,
                Destructive = 0x4,
-               NonLayered   = 0x8
+               NonLayered  = 0x8 // deprecated (kept only for enum compat)
        };
 
        static const std::string state_node_name;
@@ -77,7 +77,6 @@ class LIBARDOUR_API DiskIOProcessor : public Processor
 
        bool           hidden()      const { return _flags & Hidden; }
        bool           recordable()  const { return _flags & Recordable; }
-       bool           non_layered()  const { return _flags & NonLayered; }
 
        virtual void non_realtime_locate (samplepos_t);
 
index 343bf566ea3a20b20cf72a2223dca2aa95dca5ca..fba494d3836cc649848094ef63a0610e5e07110e 100644 (file)
@@ -97,9 +97,6 @@ public:
        virtual void set_record_safe (bool yn);
 
        bool destructive() const { return _flags & Destructive; }
-       int  set_destructive (bool yn);
-       int  set_non_layered (bool yn);
-       bool can_become_destructive (bool& requires_bounce) const;
 
        /** @return Start position of currently-running capture (in session samples) */
        samplepos_t current_capture_start() const { return capture_start_sample; }
index 93856282c4aa1cfdface62362049240e34831ff4..417d7688f60e560345ec391254f36f8eae0eea29 100644 (file)
@@ -161,6 +161,8 @@ private:
        void track_input_active (IOChange, void*);
        void map_input_active (bool);
 
+       void data_recorded (boost::weak_ptr<MidiSource> src);
+
        /** Update automation controls to reflect any changes in buffers. */
        void update_controls (BufferSet const& bufs);
        void restore_controls ();
index efce77f6d869dca27da35ffad99037c137093834..cfcb1fbf147088e439f3d44dde972dd42921f6c3 100644 (file)
@@ -64,48 +64,6 @@ AudioTrack::~AudioTrack ()
        }
 }
 
-#ifdef XXX_OLD_DESTRUCTIVE_API_XXX
-int
-AudioTrack::set_mode (TrackMode m)
-{
-       if (m != _mode) {
-
-               if (!Profile->get_trx() && _diskstream->set_destructive (m == Destructive)) {
-                       return -1;
-               }
-
-               _diskstream->set_non_layered (m == NonLayered);
-               _mode = m;
-
-               TrackModeChanged (); /* EMIT SIGNAL */
-       }
-
-       return 0;
-}
-
-bool
-AudioTrack::can_use_mode (TrackMode m, bool& bounce_required)
-{
-       switch (m) {
-       case NonLayered:
-       case Normal:
-               bounce_required = false;
-               return true;
-
-       case Destructive:
-               if (Profile->get_trx()) {
-                       return false;
-               } else {
-                       return _diskstream->can_become_destructive (bounce_required);
-               }
-               break;
-
-       default:
-               return false;
-       }
-}
-#endif
-
 int
 AudioTrack::set_state (const XMLNode& node, int version)
 {
index 06218d1ff140337706e4cbca59e5f15ebbb8ae91..8fec82fa2afabafd0ec71ec3690e3bbb3723d8eb 100644 (file)
@@ -359,7 +359,7 @@ DiskWriter::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
        bool re = record_enabled ();
        bool punch_in = _session.config.get_punch_in () && _session.locations()->auto_punch_location ();
        bool can_record = _session.actively_recording ();
-       can_record |= _session.get_record_enabled () && punch_in && _session.transport_sample () <= _session.locations()->auto_punch_location ()->start ();
+       can_record |= speed != 0 && _session.get_record_enabled () && punch_in && _session.transport_sample () <= _session.locations()->auto_punch_location ()->start ();
 
        _need_butler = false;
 
@@ -1371,14 +1371,8 @@ DiskWriter::use_destructive_playlist ()
                assert((*chan)->write_source);
                (*chan)->write_source->set_allow_remove_if_empty (false);
 
-               /* this might be false if we switched modes, so force it */
-
-#ifdef XXX_OLD_DESTRUCTIVE_API_XXX
-               (*chan)->write_source->set_destructive (true);
-#else
                // should be set when creating the source or loading the state
                assert ((*chan)->write_source->destructive());
-#endif
        }
 
        /* the source list will never be reset for a destructive track */
index 20faa80bc80f9a4e5985a59969b04428e87170bb..e6734ed08c196738071a379d386c222bbba7143a 100644 (file)
@@ -98,9 +98,17 @@ MidiTrack::init ()
        _disk_writer->set_note_mode (_note_mode);
        _disk_reader->reset_tracker ();
 
+       _disk_writer->DataRecorded.connect_same_thread (*this, boost::bind (&MidiTrack::data_recorded, this, _1));
+
        return 0;
 }
 
+void
+MidiTrack::data_recorded (boost::weak_ptr<MidiSource> src)
+{
+       DataRecorded (src); /* EMIT SIGNAL */
+}
+
 bool
 MidiTrack::can_be_record_safe ()
 {
index 45e4bce9b09886bedd55c19ece87e4aaf89ac628..de1cc56bf661696ea9e218fc9261f4771db00bed 100644 (file)
@@ -91,8 +91,6 @@ Track::init ()
 
        if (_mode == Destructive && !Profile->get_trx()) {
                dflags = DiskIOProcessor::Flag (dflags | DiskIOProcessor::Destructive);
-       } else if (_mode == NonLayered){
-               dflags = DiskIOProcessor::Flag(dflags | DiskIOProcessor::NonLayered);
        }
 
        _disk_reader.reset (new DiskReader (_session, name(), dflags));
@@ -1035,9 +1033,9 @@ Track::use_captured_midi_sources (SourceList& srcs, CaptureInfos const & capture
                        continue; /* XXX is this OK? */
                }
 
-               // cerr << "add new region, buffer position = " << buffer_position << " @ " << (*ci)->start << endl;
+               cerr << "add new region, len = " << (*ci)->samples << " @ " << (*ci)->start << endl;
 
-               pl->add_region (midi_region, (*ci)->start + preroll_off, _disk_writer->non_layered());
+               pl->add_region (midi_region, (*ci)->start + preroll_off, 1, _session.config.get_layered_record_mode ());
        }
 
        pl->thaw ();
@@ -1139,7 +1137,7 @@ Track::use_captured_audio_sources (SourceList& srcs, CaptureInfos const & captur
                        continue; /* XXX is this OK? */
                }
 
-               pl->add_region (region, (*ci)->start + preroll_off, 1, _disk_writer->non_layered());
+               pl->add_region (region, (*ci)->start + preroll_off, 1, _session.config.get_layered_record_mode());
                pl->set_layer (region, DBL_MAX);
 
                buffer_position += (*ci)->samples;