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_source_h__
22 #define __ardour_smf_source_h__
26 #include "evoral/SMF.hpp"
27 #include "ardour/midi_source.h"
28 #include "ardour/file_source.h"
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 FileSource, public Evoral::SMF {
39 /** Constructor for existing external-to-session files */
40 SMFSource (Session& session, const Glib::ustring& path, bool embedded,
41 Source::Flag flags = Source::Flag(0));
43 /** Constructor for existing in-session files */
44 SMFSource (Session& session, const XMLNode&, bool must_exist = false);
46 virtual ~SMFSource ();
48 bool safe_file_extension (const Glib::ustring& path) const {
49 return safe_midi_file_extension(path);
52 bool set_name (const std::string& newname) { return (set_source_name(newname, false) == 0); }
54 void append_event_unlocked_beats (const Evoral::Event<double>& ev);
55 void append_event_unlocked_frames (const Evoral::Event<nframes_t>& ev, sframes_t position);
57 void mark_streaming_midi_write_started (NoteMode mode, sframes_t start_time);
58 void mark_streaming_write_completed ();
60 XMLNode& get_state ();
61 int set_state (const XMLNode&);
63 void load_model (bool lock=true, bool force_reload=false);
64 void destroy_model ();
68 static void set_header_position_offset (nframes_t offset, bool negative);
70 static bool safe_midi_file_extension (const Glib::ustring& path);
73 nframes_t read_unlocked (MidiRingBuffer<nframes_t>& dst,
77 sframes_t stamp_offset,
78 sframes_t negative_stamp_offset) const;
80 nframes_t write_unlocked (MidiRingBuffer<nframes_t>& src,
84 void set_default_controls_interpolation ();
86 double _last_ev_time_beats;
87 sframes_t _last_ev_time_frames;
90 }; /* namespace ARDOUR */
92 #endif /* __ardour_smf_source_h__ */