summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-08-11 06:17:42 +0000
committerDavid Robillard <d@drobilla.net>2007-08-11 06:17:42 +0000
commit5156998e6e2536c9c713974d3ae719a5d2ef5c7f (patch)
tree6223846321fe3f611b952b2c2e77c349d0b7072f /libs/ardour/ardour
parent861181d7421012486e36327c464b957ec08e396b (diff)
Saving of edited MIDI data to disk (on session save).
Seems to be a pretty random problem with note duration restoring though... git-svn-id: svn://localhost/ardour2/trunk@2290 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r--libs/ardour/ardour/midi_model.h12
-rw-r--r--libs/ardour/ardour/midi_region.h2
-rw-r--r--libs/ardour/ardour/midi_source.h7
-rw-r--r--libs/ardour/ardour/region.h11
-rw-r--r--libs/ardour/ardour/smf_source.h12
-rw-r--r--libs/ardour/ardour/source.h4
6 files changed, 33 insertions, 15 deletions
diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h
index f1fcabfb1f..63b87c9683 100644
--- a/libs/ardour/ardour/midi_model.h
+++ b/libs/ardour/ardour/midi_model.h
@@ -23,6 +23,7 @@
#include <queue>
#include <boost/utility.hpp>
+#include <glibmm/thread.h>
#include <pbd/command.h>
#include <ardour/types.h>
#include <ardour/midi_buffer.h>
@@ -31,6 +32,7 @@
namespace ARDOUR {
class Session;
+class MidiSource;
/** This is a slightly higher level (than MidiBuffer) model of MIDI note data.
@@ -143,14 +145,15 @@ public:
MidiModel::DeltaCommand* new_delta_command(const std::string name="midi edit");
void apply_command(Command* cmd);
- bool write_new_source(const std::string& path);
+ bool edited() const { return _edited; }
+ bool write_to(boost::shared_ptr<MidiSource> source);
sigc::signal<void> ContentsChanged;
private:
friend class DeltaCommand;
- void add_note(const Note& note);
- void remove_note(const Note& note);
+ void add_note_unlocked(const Note& note);
+ void remove_note_unlocked(const Note& note);
bool is_sorted() const;
@@ -159,12 +162,15 @@ private:
Session& _session;
+ Glib::RWLock _lock;
+
Notes _notes;
NoteMode _note_mode;
typedef std::vector<size_t> WriteNotes;
WriteNotes _write_notes;
bool _writing;
+ bool _edited;
// note state for read():
diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h
index ade839ab3e..294c2d3291 100644
--- a/libs/ardour/ardour/midi_region.h
+++ b/libs/ardour/ardour/midi_region.h
@@ -90,6 +90,8 @@ class MidiRegion : public Region
void recompute_at_start ();
void recompute_at_end ();
+ void switch_source(boost::shared_ptr<Source> source);
+
protected:
int set_live_state (const XMLNode&, Change&, bool send);
diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h
index 2de31f879e..088175ab75 100644
--- a/libs/ardour/ardour/midi_source.h
+++ b/libs/ardour/ardour/midi_source.h
@@ -51,12 +51,17 @@ class MidiSource : public Source
virtual nframes_t read (MidiRingBuffer& dst, nframes_t start, nframes_t cnt, nframes_t stamp_offset) const;
virtual nframes_t write (MidiRingBuffer& src, nframes_t cnt);
+ virtual void append_event_unlocked(const MidiEvent& ev) = 0;
+
+ virtual void flush() {}
virtual void mark_for_remove() = 0;
virtual void mark_streaming_midi_write_started (NoteMode mode);
virtual void mark_streaming_write_started ();
virtual void mark_streaming_write_completed ();
+ void set_timeline_position (nframes_t when) { _timeline_position = when; }
+
virtual void session_saved();
string captured_for() const { return _captured_for; }
@@ -80,6 +85,7 @@ class MidiSource : public Source
virtual bool model_loaded() const { return _model_loaded; }
boost::shared_ptr<MidiModel> model() { return _model; }
+ void set_model(boost::shared_ptr<MidiModel> m) { _model = m; _model_loaded = true; }
protected:
virtual nframes_t read_unlocked (MidiRingBuffer& dst, nframes_t start, nframes_t cnt, nframes_t stamp_offset) const = 0;
@@ -87,6 +93,7 @@ class MidiSource : public Source
mutable Glib::Mutex _lock;
string _captured_for;
+ uint64_t _timeline_position;
mutable uint32_t _read_data_count; ///< modified in read()
mutable uint32_t _write_data_count; ///< modified in write()
diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h
index e6b799fdcf..496dc7874e 100644
--- a/libs/ardour/ardour/region.h
+++ b/libs/ardour/ardour/region.h
@@ -237,10 +237,10 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro
string _name;
DataType _type;
Flag _flags;
- nframes_t _start;
- nframes_t _length;
- nframes_t _position;
- nframes_t _sync_position;
+ nframes_t _start;
+ nframes_t _length;
+ nframes_t _position;
+ nframes_t _sync_position;
layer_t _layer;
mutable RegionEditState _first_edit;
int _frozen;
@@ -248,10 +248,11 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro
Change _pending_changed;
uint64_t _last_layer_op; ///< timestamp
Glib::Mutex _lock;
- boost::weak_ptr<ARDOUR::Playlist> _playlist;
SourceList _sources;
/** Used when timefx are applied, so we can always use the original source */
SourceList _master_sources;
+
+ boost::weak_ptr<ARDOUR::Playlist> _playlist;
};
} /* namespace ARDOUR */
diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h
index fde91ed946..c852266e9c 100644
--- a/libs/ardour/ardour/smf_source.h
+++ b/libs/ardour/ardour/smf_source.h
@@ -57,9 +57,9 @@ class SMFSource : public MidiSource {
// FIXME and thus are useless for MIDI.. but make MidiDiskstream compile easier! :)
virtual nframes_t last_capture_start_frame() const { return 0; }
- virtual void mark_capture_start (nframes_t) {}
- virtual void mark_capture_end () {}
- virtual void clear_capture_marks() {}
+ virtual void mark_capture_start (nframes_t) {}
+ virtual void mark_capture_end () {}
+ virtual void clear_capture_marks() {}
bool set_name (const std::string& newname) { return (set_source_name(newname, false) == 0); }
int set_source_name (string newname, bool destructive);
@@ -69,9 +69,12 @@ class SMFSource : public MidiSource {
void set_allow_remove_if_empty (bool yn);
void mark_for_remove();
- int update_header (nframes_t when, struct tm&, time_t);
+ void append_event_unlocked(const MidiEvent& ev);
+
int flush_header ();
int flush_footer ();
+
+ void flush() { flush_header(); flush_footer(); }
int move_to_trash (const string trash_dir_name);
@@ -120,7 +123,6 @@ class SMFSource : public MidiSource {
Flag _flags;
string _take_id;
bool _allow_remove_if_empty;
- uint64_t _timeline_position;
FILE* _fd;
double _last_ev_time; // last frame time written, relative to source start
uint32_t _track_size;
diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h
index bbb7d798b2..6f323dd878 100644
--- a/libs/ardour/ardour/source.h
+++ b/libs/ardour/ardour/source.h
@@ -71,8 +71,8 @@ class Source : public SessionObject
uint32_t used() const;
-
- static sigc::signal<void,Source*> SourceCreated;
+ static sigc::signal<void,Source*> SourceCreated;
+ sigc::signal<void,boost::shared_ptr<Source> > Switched;
protected:
void update_length (nframes_t pos, nframes_t cnt);