*/
-#ifndef __ardour_smf_filesource_h__
-#define __ardour_smf_filesource_h__
+#ifndef __ardour_smf_source_h__
+#define __ardour_smf_source_h__
+#include <cstdio>
#include <time.h>
+#include "evoral/SMF.hpp"
+#include "ardour/midi_source.h"
+#include "ardour/file_source.h"
-#include <ardour/midi_source.h>
+namespace Evoral { template<typename T> class Event; }
namespace ARDOUR {
+template<typename T> class MidiRingBuffer;
+
/** Standard Midi File (Type 0) Source */
-class SMFSource : public MidiSource {
- public:
- enum Flag {
- Writable = 0x1,
- CanRename = 0x2,
- Broadcast = 0x4,
- Removable = 0x8,
- RemovableIfEmpty = 0x10,
- RemoveAtDestroy = 0x20,
- BuildPeaks = 0x40
- };
-
+class SMFSource : public MidiSource, public FileSource, public Evoral::SMF {
+public:
/** Constructor for existing external-to-session files */
- SMFSource (std::string path, Flag flags);
+ SMFSource (Session& session, const Glib::ustring& path, bool embedded,
+ Source::Flag flags = Source::Flag(0));
- /* Constructor for existing in-session files */
- SMFSource (const XMLNode&);
+ /** Constructor for existing in-session files */
+ SMFSource (Session& session, const XMLNode&, bool must_exist = false);
virtual ~SMFSource ();
- int set_name (string newname, bool destructive);
+ bool safe_file_extension (const Glib::ustring& path) const {
+ return safe_midi_file_extension(path);
+ }
- string path() const { return _path; }
+ bool set_name (const std::string& newname) { return (set_source_name(newname, false) == 0); }
- void set_allow_remove_if_empty (bool yn);
- void mark_for_remove();
+ void append_event_unlocked_beats (const Evoral::Event<Evoral::MusicalTime>& ev);
+ void append_event_unlocked_frames (const Evoral::Event<nframes_t>& ev, sframes_t source_start);
- virtual int update_header (jack_nframes_t when, struct tm&, time_t) = 0;
- virtual int flush_header () = 0;
+ void mark_streaming_midi_write_started (NoteMode mode, sframes_t start_time);
+ void mark_streaming_write_completed ();
- int move_to_trash (const string trash_dir_name);
+ XMLNode& get_state ();
+ int set_state (const XMLNode&, int version = 3000);
- static bool is_empty (string path);
- void mark_streaming_write_completed ();
+ void load_model (bool lock=true, bool force_reload=false);
+ void destroy_model ();
- void mark_take (string);
- string take_id() const { return _take_id; }
+ void flush_midi ();
- static void set_search_path (string);
- static void set_header_position_offset (jack_nframes_t offset, bool negative);
+ static void set_header_position_offset (nframes_t offset, bool negative);
- XMLNode& get_state ();
- int set_state (const XMLNode&);
+ static bool safe_midi_file_extension (const Glib::ustring& path);
- protected:
+private:
+ nframes_t read_unlocked (MidiRingBuffer<nframes_t>& dst,
+ sframes_t position,
+ sframes_t start,
+ nframes_t cnt,
+ sframes_t stamp_offset,
+ sframes_t negative_stamp_offset) const;
- int init (string idstr, bool must_exist);
+ nframes_t write_unlocked (MidiRingBuffer<nframes_t>& src,
+ sframes_t position,
+ nframes_t cnt);
- bool find (std::string path, bool must_exist, bool& is_new);
- bool removable() const;
- bool writable() const { return _flags & Writable; }
-
- uint16_t _channel;
- string _path;
- Flag _flags;
- string _take_id;
- bool _allow_remove_if_empty;
- uint64_t _timeline_position;
+ void set_default_controls_interpolation ();
- static string _search_path;
+ double _last_ev_time_beats;
+ sframes_t _last_ev_time_frames;
+ mutable sframes_t _smf_last_read_end;
};
}; /* namespace ARDOUR */
-#endif /* __ardour_smf_filesource_h__ */
+#endif /* __ardour_smf_source_h__ */