2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 $Id: diskstream.h 579 2006-06-12 19:56:37Z essej $
21 #ifndef __ardour_midi_diskstream_h__
22 #define __ardour_midi_diskstream_h__
24 #include <sigc++/signal.h>
35 #include <pbd/fastlog.h>
36 #include <pbd/ringbufferNPT.h>
39 #include <ardour/ardour.h>
40 #include <ardour/configuration.h>
41 #include <ardour/session.h>
42 #include <ardour/route_group.h>
43 #include <ardour/route.h>
44 #include <ardour/port.h>
45 #include <ardour/utils.h>
46 #include <ardour/diskstream.h>
47 #include <ardour/midi_playlist.h>
48 #include <ardour/midi_ring_buffer.h>
61 class MidiDiskstream : public Diskstream
64 MidiDiskstream (Session &, const string& name, Diskstream::Flag f = Recordable);
65 MidiDiskstream (Session &, const XMLNode&);
68 float playback_buffer_load() const;
69 float capture_buffer_load() const;
71 void get_playback(MidiBuffer& dst, nframes_t start, nframes_t end);
73 void set_record_enabled (bool yn);
75 boost::shared_ptr<MidiPlaylist> midi_playlist () { return boost::dynamic_pointer_cast<MidiPlaylist>(_playlist); }
77 int use_playlist (boost::shared_ptr<Playlist>);
78 int use_new_playlist ();
79 int use_copy_playlist ();
83 XMLNode& get_state(void);
84 int set_state(const XMLNode& node);
86 void monitor_input (bool);
88 boost::shared_ptr<SMFSource> write_source () { return _write_source; }
90 int set_destructive (bool yn); // doom!
95 /* the Session is the only point of access for these
96 because they require that the Session is "inactive"
97 while they are called.
100 void set_pending_overwrite(bool);
101 int overwrite_existing_buffers ();
102 void set_block_size (nframes_t);
103 int internal_playback_seek (nframes_t distance);
104 int can_internal_playback_seek (nframes_t distance);
105 int rename_write_sources ();
106 void reset_write_sources (bool, bool force = false);
107 void non_realtime_input_change ();
110 int seek (nframes_t which_sample, bool complete_refill = false);
113 friend class MidiTrack;
115 int process (nframes_t transport_frame, nframes_t nframes, nframes_t offset, bool can_record, bool rec_monitors_input);
116 bool commit (nframes_t nframes);
120 /* The two central butler operations */
121 int do_flush (Session::RunContext context, bool force = false);
124 int do_refill_with_alloc();
126 int read (nframes_t& start, nframes_t cnt, bool reversed);
128 void finish_capture (bool rec_monitors_input);
129 void transport_stopped (struct tm&, time_t, bool abort);
131 void init (Diskstream::Flag);
133 int use_new_write_source (uint32_t n=0);
135 int find_and_use_playlist (const string&);
137 void allocate_temporary_buffers ();
139 int use_pending_capture_data (XMLNode& node);
141 void get_input_sources ();
142 void check_record_status (nframes_t transport_frame, nframes_t nframes, bool can_record);
143 void set_align_style_from_io();
145 void engage_record_enable ();
146 void disengage_record_enable ();
148 MidiRingBuffer* _playback_buf;
149 MidiRingBuffer* _capture_buf;
150 MidiPort* _source_port;
151 boost::shared_ptr<SMFSource> _write_source;
152 RingBufferNPT<CaptureTransition>* _capture_transition_buf;
153 nframes_t _last_flush_frame;
156 }; /* namespace ARDOUR */
158 #endif /* __ardour_midi_diskstream_h__ */