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>
34 #include <pbd/fastlog.h>
35 #include <pbd/ringbufferNPT.h>
38 #include <ardour/ardour.h>
39 #include <ardour/configuration.h>
40 #include <ardour/session.h>
41 #include <ardour/route_group.h>
42 #include <ardour/route.h>
43 #include <ardour/port.h>
44 #include <ardour/utils.h>
45 #include <ardour/diskstream.h>
46 #include <ardour/midi_playlist.h>
58 class MidiDiskstream : public Diskstream
61 MidiDiskstream (Session &, const string& name, Diskstream::Flag f = Recordable);
62 MidiDiskstream (Session &, const XMLNode&);
64 void set_io (ARDOUR::IO& io);
66 MidiDiskstream& ref() { _refcnt++; return *this; }
67 //void unref() { if (_refcnt) _refcnt--; if (_refcnt == 0) delete this; }
68 //uint32_t refcnt() const { return _refcnt; }
70 float playback_buffer_load() const;
71 float capture_buffer_load() const;
73 //void set_align_style (AlignStyle);
74 //void set_persistent_align_style (AlignStyle);
76 void set_record_enabled (bool yn, void *src);
77 //void set_speed (double);
79 int use_playlist (Playlist *);
80 int use_new_playlist ();
81 int use_copy_playlist ();
83 Playlist *playlist () { return _playlist; }
85 static sigc::signal<void,list<SMFSource*>*> DeleteSources;
89 XMLNode& get_state(void);
90 int set_state(const XMLNode& node);
92 void monitor_input (bool);
94 //void handle_input_change (IOChange, void *src);
99 /* the Session is the only point of access for these
100 because they require that the Session is "inactive"
101 while they are called.
104 void set_pending_overwrite(bool);
105 int overwrite_existing_buffers ();
106 void set_block_size (jack_nframes_t);
107 int internal_playback_seek (jack_nframes_t distance);
108 int can_internal_playback_seek (jack_nframes_t distance);
109 int rename_write_sources ();
110 void reset_write_sources (bool, bool force = false);
111 void non_realtime_input_change ();
113 uint32_t read_data_count() const { return _read_data_count; }
114 uint32_t write_data_count() const { return _write_data_count; }
117 friend class Auditioner;
118 int seek (jack_nframes_t which_sample, bool complete_refill = false);
121 friend class MidiTrack;
123 int process (jack_nframes_t transport_frame, jack_nframes_t nframes, jack_nframes_t offset, bool can_record, bool rec_monitors_input);
124 bool commit (jack_nframes_t nframes);
128 /* use unref() to destroy a diskstream */
131 MidiPlaylist* _playlist;
133 /*Tthe two central butler operations */
134 int do_flush (Session::RunContext context, bool force = false) { return 0; }
135 int do_refill () { return 0; }
137 int do_refill_with_alloc() { return 0; }
139 int read (RawMidi* buf, RawMidi* mixdown_buffer, char * workbuf, jack_nframes_t& start, jack_nframes_t cnt, bool reversed);
141 /* XXX fix this redundancy ... */
143 //void playlist_changed (Change);
144 //void playlist_modified ();
145 void playlist_deleted (Playlist*);
147 void finish_capture (bool rec_monitors_input);
148 void transport_stopped (struct tm&, time_t, bool abort);
155 void init (Diskstream::Flag);
157 int use_new_write_source (uint32_t n=0);
159 int find_and_use_playlist (const string&);
161 void allocate_temporary_buffers ();
163 //bool realtime_set_speed (double, bool global_change);
164 void non_realtime_set_speed ();
166 int use_pending_capture_data (XMLNode& node);
168 void get_input_sources ();
169 void check_record_status (jack_nframes_t transport_frame, jack_nframes_t nframes, bool can_record);
170 void set_align_style_from_io();
171 void setup_destructive_playlist ();
172 void use_destructive_playlist ();
174 std::list<Region*> _last_capture_regions;
175 std::vector<SMFSource*> _capturing_sources;
178 }; /* namespace ARDOUR */
180 #endif /* __ardour_midi_diskstream_h__ */