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 void start_scrub (jack_nframes_t where) {} // FIXME?
84 void end_scrub () {} // FIXME?
86 Playlist *playlist () { return _playlist; }
88 static sigc::signal<void,list<SMFSource*>*> DeleteSources;
92 XMLNode& get_state(void);
93 int set_state(const XMLNode& node);
95 void monitor_input (bool);
97 //void handle_input_change (IOChange, void *src);
100 friend class Session;
102 /* the Session is the only point of access for these
103 because they require that the Session is "inactive"
104 while they are called.
107 void set_pending_overwrite(bool);
108 int overwrite_existing_buffers ();
109 void reverse_scrub_buffer (bool to_forward) {} // FIXME?
110 void set_block_size (jack_nframes_t);
111 int internal_playback_seek (jack_nframes_t distance);
112 int can_internal_playback_seek (jack_nframes_t distance);
113 int rename_write_sources ();
114 void reset_write_sources (bool, bool force = false);
115 void non_realtime_input_change ();
117 uint32_t read_data_count() const { return _read_data_count; }
118 uint32_t write_data_count() const { return _write_data_count; }
121 friend class Auditioner;
122 int seek (jack_nframes_t which_sample, bool complete_refill = false);
125 friend class MidiTrack;
127 int process (jack_nframes_t transport_frame, jack_nframes_t nframes, jack_nframes_t offset, bool can_record, bool rec_monitors_input);
128 bool commit (jack_nframes_t nframes);
132 /* use unref() to destroy a diskstream */
135 MidiPlaylist* _playlist;
137 /* the two central butler operations */
139 int do_flush (char * workbuf, bool force = false);
140 int do_refill (RawMidi *mixdown_buffer, float *gain_buffer, char *workbuf);
142 virtual int non_realtime_do_refill() { return do_refill(0, 0, 0); }
144 int read (RawMidi* buf, RawMidi* mixdown_buffer, char * workbuf, jack_nframes_t& start, jack_nframes_t cnt, bool reversed);
146 /* XXX fix this redundancy ... */
148 //void playlist_changed (Change);
149 //void playlist_modified ();
150 void playlist_deleted (Playlist*);
151 void session_controls_changed (Session::ControlType) {} // FIXME?
153 void finish_capture (bool rec_monitors_input);
154 void clean_up_capture (struct tm&, time_t, bool abort) {} // FIXME?
155 void transport_stopped (struct tm&, time_t, bool abort);
162 void init (Diskstream::Flag);
164 int use_new_write_source (uint32_t n=0);
165 int use_new_fade_source (uint32_t n=0) { return 0; } // FIXME?
167 int find_and_use_playlist (const string&);
169 void allocate_temporary_buffers ();
171 int create_input_port () { return 0; } // FIXME?
172 int connect_input_port () { return 0; } // FIXME?
173 int seek_unlocked (jack_nframes_t which_sample) { return 0; } // FIXME?
175 int ports_created () { return 0; } // FIXME?
177 //bool realtime_set_speed (double, bool global_change);
178 void non_realtime_set_speed ();
180 int use_pending_capture_data (XMLNode& node);
182 void get_input_sources ();
183 void check_record_status (jack_nframes_t transport_frame, jack_nframes_t nframes, bool can_record);
184 void set_align_style_from_io();
185 void setup_destructive_playlist ();
186 void use_destructive_playlist ();
188 std::list<Region*> _last_capture_regions;
189 std::vector<SMFSource*> _capturing_sources;
192 }; /* namespace ARDOUR */
194 #endif /* __ardour_midi_diskstream_h__ */