2 Copyright (C) 2006 Paul Davis
3 Written by Dave Robillard, 2006
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __ardour_smf_filesource_h__
22 #define __ardour_smf_filesource_h__
27 #include <ardour/midi_source.h>
28 #include <evoral/SMF.hpp>
30 namespace Evoral { template<typename T> class Event; }
34 template<typename T> class MidiRingBuffer;
36 /** Standard Midi File (Type 0) Source */
37 class SMFSource : public MidiSource, public Evoral::SMF<double> {
44 RemovableIfEmpty = 0x10,
45 RemoveAtDestroy = 0x20,
49 /** Constructor for existing external-to-session files */
50 SMFSource (Session& session, std::string path, Flag flags = Flag(0));
52 /* Constructor for existing in-session files */
53 SMFSource (Session& session, const XMLNode&);
55 virtual ~SMFSource ();
57 /* this block of methods do nothing for regular file sources, but are significant
58 for files used in destructive recording.
60 // FIXME and thus are useless for MIDI.. but make MidiDiskstream compile easier! :)
62 virtual nframes_t last_capture_start_frame() const { return 0; }
63 virtual void mark_capture_start (nframes_t) {}
64 virtual void mark_capture_end () {}
65 virtual void clear_capture_marks() {}
67 bool set_name (const std::string& newname) { return (set_source_name(newname, false) == 0); }
68 int set_source_name (string newname, bool destructive);
70 static bool safe_file_extension (const Glib::ustring& path);
72 Glib::ustring path() const { return _path; }
74 void set_allow_remove_if_empty (bool yn);
75 void mark_for_remove();
77 void append_event_unlocked(EventTimeUnit unit, const Evoral::Event<double>& ev);
79 int move_to_trash (const string trash_dir_name);
81 void mark_streaming_midi_write_started (NoteMode mode, nframes_t start_time);
82 void mark_streaming_write_completed ();
84 void mark_take (string);
85 string take_id() const { return _take_id; }
87 static void set_search_path (string);
88 static void set_header_position_offset (nframes_t offset, bool negative);
90 XMLNode& get_state ();
91 int set_state (const XMLNode&);
93 void load_model(bool lock=true, bool force_reload=false);
100 int init (string idstr, bool must_exist);
102 nframes_t read_unlocked (
103 MidiRingBuffer<double>& dst,
106 nframes_t stamp_offset,
107 nframes_t negative_stamp_offset) const;
109 nframes_t write_unlocked (
110 MidiRingBuffer<double>& src,
113 bool find (std::string path, bool must_exist, bool& is_new);
114 bool removable() const;
115 bool writable() const { return _flags & Writable; }
117 void make_sure_controls_have_the_right_interpolation();
122 bool _allow_remove_if_empty;
124 static string _search_path;
127 }; /* namespace ARDOUR */
129 #endif /* __ardour_smf_filesource_h__ */