diff options
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/automatable.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_event.h | 5 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_model.h | 17 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_ring_buffer.h | 27 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_source.h | 13 | ||||
-rw-r--r-- | libs/ardour/ardour/session_object.h | 20 | ||||
-rw-r--r-- | libs/ardour/ardour/smf_source.h | 8 |
7 files changed, 69 insertions, 25 deletions
diff --git a/libs/ardour/ardour/automatable.h b/libs/ardour/ardour/automatable.h index a48029734a..0af996f6c0 100644 --- a/libs/ardour/ardour/automatable.h +++ b/libs/ardour/ardour/automatable.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000, 2007 Paul Davis + Copyright (C) 2000-2007 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -94,7 +94,7 @@ protected: mutable Glib::Mutex _automation_lock; - Controls _controls; + Controls _controls; std::set<Parameter> _visible_controls; std::set<Parameter> _can_automate_list; diff --git a/libs/ardour/ardour/midi_event.h b/libs/ardour/ardour/midi_event.h index 3a6b89f198..61e6b8af6e 100644 --- a/libs/ardour/ardour/midi_event.h +++ b/libs/ardour/ardour/midi_event.h @@ -112,11 +112,14 @@ struct MidiEvent { inline uint8_t channel() const { return (_buffer[0] & 0x0F); } inline bool is_note_on() const { return (type() == MIDI_CMD_NOTE_ON); } inline bool is_note_off() const { return (type() == MIDI_CMD_NOTE_OFF); } + inline bool is_cc() const { return (type() == MIDI_CMD_CONTROL); } inline bool is_note() const { return (is_note_on() || is_note_off()); } inline uint8_t note() const { return (_buffer[1]); } inline uint8_t velocity() const { return (_buffer[2]); } + inline uint8_t cc_number() const { return (_buffer[1]); } + inline uint8_t cc_value() const { return (_buffer[2]); } inline const Byte* buffer() const { return _buffer; } - inline Byte* buffer() { return _buffer; } + inline Byte*& buffer() { return _buffer; } private: double _time; /**< Sample index (or beat time) at which event is valid */ diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h index 63b87c9683..f688c0fe09 100644 --- a/libs/ardour/ardour/midi_model.h +++ b/libs/ardour/ardour/midi_model.h @@ -28,6 +28,7 @@ #include <ardour/types.h> #include <ardour/midi_buffer.h> #include <ardour/midi_ring_buffer.h> +#include <ardour/automatable.h> namespace ARDOUR { @@ -41,7 +42,7 @@ class MidiSource; * note on and off events (controller data is not here since it's represented * as an AutomationList) */ -class MidiModel : public boost::noncopyable { +class MidiModel : public boost::noncopyable, public Automatable { public: struct Note { Note(double time=0, double dur=0, uint8_t note=0, uint8_t vel=0x40); @@ -92,11 +93,13 @@ public: void append(const MidiBuffer& data); /** Resizes vector if necessary (NOT realtime safe) */ - void append(double time, size_t size, const Byte* in_buffer); + //void append(double time, size_t size, const Byte* in_buffer); + void append(const MidiEvent& ev); inline const Note& note_at(unsigned i) const { return _notes[i]; } inline size_t n_notes() const { return _notes.size(); } + inline bool empty() const { return _notes.size() == 0 && _controls.size() == 0; } typedef std::vector<Note> Notes; @@ -146,7 +149,12 @@ public: void apply_command(Command* cmd); bool edited() const { return _edited; } + void set_edited(bool yn) { _edited = yn; } bool write_to(boost::shared_ptr<MidiSource> source); + + // MidiModel doesn't use the normal AutomationList serialisation code, as CC data is in the .mid + XMLNode& get_state(); + int set_state(const XMLNode&) { return 0; } sigc::signal<void> ContentsChanged; @@ -155,12 +163,13 @@ private: void add_note_unlocked(const Note& note); void remove_note_unlocked(const Note& note); +#ifndef NDEBUG bool is_sorted() const; +#endif void append_note_on(double time, uint8_t note, uint8_t velocity); void append_note_off(double time, uint8_t note); - - Session& _session; + void append_cc(double time, uint8_t number, uint8_t value); Glib::RWLock _lock; diff --git a/libs/ardour/ardour/midi_ring_buffer.h b/libs/ardour/ardour/midi_ring_buffer.h index 21beebacd2..9389f962fc 100644 --- a/libs/ardour/ardour/midi_ring_buffer.h +++ b/libs/ardour/ardour/midi_ring_buffer.h @@ -233,6 +233,9 @@ public: size_t write(double time, size_t size, const Byte* buf); bool read(double* time, size_t* size, Byte* buf); + bool read_prefix(double* time, size_t* size); + bool read_contents(size_t size, Byte* buf); + size_t read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t offset=0); }; @@ -250,6 +253,30 @@ MidiRingBuffer::read(double* time, size_t* size, Byte* buf) } +/** Read the time and size of an event. This call MUST be immediately proceeded + * by a call to read_contents (or the read pointer will be garabage). + */ +inline bool +MidiRingBuffer::read_prefix(double* time, size_t* size) +{ + bool success = MidiRingBufferBase<Byte>::full_read(sizeof(double), (Byte*)time); + if (success) + success = MidiRingBufferBase<Byte>::full_read(sizeof(size_t), (Byte*)size); + + return success; +} + + +/** Read the contenst of an event. This call MUST be immediately preceeded + * by a call to read_prefix (or the returned even will be garabage). + */ +inline bool +MidiRingBuffer::read_contents(size_t size, Byte* buf) +{ + return MidiRingBufferBase<Byte>::full_read(size, buf); +} + + inline size_t MidiRingBuffer::write(double time, size_t size, const Byte* buf) { diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index 088175ab75..95d2a38c4e 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -53,8 +53,6 @@ class MidiSource : public Source 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 (); @@ -72,8 +70,8 @@ class MidiSource : public Source static sigc::signal<void,MidiSource*> MidiSourceCreated; - // The MIDI equivalent to "peaks" (but complete data) - mutable sigc::signal<void,boost::shared_ptr<MidiBuffer>,nframes_t,nframes_t> ViewDataRangeReady; + // Signal a range of recorded data is available for reading from model() + mutable sigc::signal<void,nframes_t,nframes_t> ViewDataRangeReady; XMLNode& get_state (); int set_state (const XMLNode&); @@ -82,12 +80,14 @@ class MidiSource : public Source virtual void destroy_model() = 0; void set_note_mode(NoteMode mode) { if (_model) _model->set_note_mode(mode); } - 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; } + void set_model(boost::shared_ptr<MidiModel> m) { _model = m; } protected: + virtual int flush_header() = 0; + virtual int flush_footer() = 0; + virtual nframes_t read_unlocked (MidiRingBuffer& dst, nframes_t start, nframes_t cnt, nframes_t stamp_offset) const = 0; virtual nframes_t write_unlocked (MidiRingBuffer& dst, nframes_t cnt) = 0; @@ -98,7 +98,6 @@ class MidiSource : public Source mutable uint32_t _write_data_count; ///< modified in write() boost::shared_ptr<MidiModel> _model; - bool _model_loaded; bool _writing; private: diff --git a/libs/ardour/ardour/session_object.h b/libs/ardour/ardour/session_object.h index 9d82b4bba0..bb726cb0d0 100644 --- a/libs/ardour/ardour/session_object.h +++ b/libs/ardour/ardour/session_object.h @@ -20,6 +20,7 @@ #ifndef __ardour_session_object_h__ #define __ardour_session_object_h__ +#include <string> #include <pbd/statefuldestructible.h> namespace ARDOUR { @@ -36,22 +37,27 @@ class Session; class SessionObject : public PBD::StatefulDestructible { public: - SessionObject(Session& session, const string& name) + SessionObject(Session& session, const std::string& name) : _session(session) , _name(name) {} - Session& session() const { return _session; } - const string& name() const { return _name; } + Session& session() const { return _session; } + const std::string& name() const { return _name; } - virtual bool set_name (const string& str) - { if (_name != str) { _name = str; NameChanged(); } return true; } + virtual bool set_name (const std::string& str) { + if (_name != str) { + _name = str; + NameChanged(); + } + return true; + } sigc::signal<void> NameChanged; protected: - Session& _session; - string _name; + Session& _session; + std::string _name; }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h index c852266e9c..bf5618d57a 100644 --- a/libs/ardour/ardour/smf_source.h +++ b/libs/ardour/ardour/smf_source.h @@ -74,8 +74,6 @@ class SMFSource : public MidiSource { int flush_header (); int flush_footer (); - void flush() { flush_header(); flush_footer(); } - int move_to_trash (const string trash_dir_name); bool is_empty () const; @@ -108,13 +106,15 @@ class SMFSource : public MidiSource { bool removable() const; bool writable() const { return _flags & Writable; } - int open(); + int open(); + void seek_to_end(); + void write_footer(); void write_chunk_header(char id[4], uint32_t length); void write_chunk(char id[4], uint32_t length, void* data); size_t write_var_len(uint32_t val); uint32_t read_var_len() const; - int read_event(jack_midi_event_t& ev) const; + int read_event(uint32_t* delta_t, uint32_t* size, Byte** buf) const; static const uint16_t _ppqn = 19200; |