2 Copyright (C) 2006 Paul Davis
3 Author: David Robillard
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.
20 #ifndef __ardour_midi_track_h__
21 #define __ardour_midi_track_h__
23 #include "ardour/midi_channel_filter.h"
24 #include "ardour/midi_ring_buffer.h"
25 #include "ardour/track.h"
30 class InterThreadInfo;
37 class LIBARDOUR_API MidiTrack : public Track
40 MidiTrack (Session&, std::string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal);
45 int roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& need_butler);
47 void realtime_handle_transport_stopped ();
48 void realtime_locate ();
49 void non_realtime_locate (framepos_t);
51 boost::shared_ptr<Diskstream> create_diskstream ();
52 void set_diskstream (boost::shared_ptr<Diskstream>);
53 void set_record_enabled (bool yn, void *src);
54 void set_record_safe (bool yn, void *src);
56 DataType data_type () const {
57 return DataType::MIDI;
60 void freeze_me (InterThreadInfo&);
63 bool bounceable (boost::shared_ptr<Processor>, bool) const { return false; }
64 boost::shared_ptr<Region> bounce (InterThreadInfo&);
65 boost::shared_ptr<Region> bounce_range (framepos_t start,
68 boost::shared_ptr<Processor> endpoint,
69 bool include_endpoint);
71 int export_stuff (BufferSet& bufs,
72 framepos_t start_frame,
74 boost::shared_ptr<Processor> endpoint,
75 bool include_endpoint,
79 int set_state (const XMLNode&, int version);
81 void midi_panic(void);
82 bool write_immediate_event(size_t size, const uint8_t* buf);
84 /** A control that will send "immediate" events to a MIDI track when twiddled */
85 struct MidiControl : public AutomationControl {
86 MidiControl(MidiTrack* route, const Evoral::Parameter& param,
87 boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>())
88 : AutomationControl (route->session(), param, ParameterDescriptor(param), al)
92 void set_value (double val);
97 virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState);
99 NoteMode note_mode() const { return _note_mode; }
100 void set_note_mode (NoteMode m);
102 std::string describe_parameter (Evoral::Parameter param);
104 bool step_editing() const { return _step_editing; }
105 void set_step_editing (bool yn);
106 MidiRingBuffer<framepos_t>& step_edit_ring_buffer() { return _step_edit_ring_buffer; }
108 PBD::Signal1<void,bool> StepEditStatusChange;
110 boost::shared_ptr<SMFSource> write_source (uint32_t n = 0);
112 /* Configure capture/playback channels (see MidiChannelFilter). */
113 void set_capture_channel_mode (ChannelMode mode, uint16_t mask);
114 void set_playback_channel_mode (ChannelMode mode, uint16_t mask);
115 void set_playback_channel_mask (uint16_t mask);
116 void set_capture_channel_mask (uint16_t mask);
118 ChannelMode get_playback_channel_mode() const { return _playback_filter.get_channel_mode(); }
119 ChannelMode get_capture_channel_mode() const { return _capture_filter.get_channel_mode(); }
120 uint16_t get_playback_channel_mask() const { return _playback_filter.get_channel_mask(); }
121 uint16_t get_capture_channel_mask() const { return _capture_filter.get_channel_mask(); }
123 MidiChannelFilter& playback_filter() { return _playback_filter; }
124 MidiChannelFilter& capture_filter() { return _capture_filter; }
126 boost::shared_ptr<MidiPlaylist> midi_playlist ();
128 PBD::Signal1<void, boost::weak_ptr<MidiSource> > DataRecorded;
129 boost::shared_ptr<MidiBuffer> get_gui_feed_buffer () const;
131 void set_monitoring (MonitorChoice);
132 MonitorState monitoring_state () const;
134 void set_input_active (bool);
135 bool input_active () const;
136 PBD::Signal0<void> InputActiveChanged;
139 XMLNode& state (bool full);
144 MidiRingBuffer<framepos_t> _immediate_events;
145 MidiRingBuffer<framepos_t> _step_edit_ring_buffer;
149 MidiChannelFilter _playback_filter;
150 MidiChannelFilter _capture_filter;
152 virtual boost::shared_ptr<Diskstream> diskstream_factory (XMLNode const &);
154 boost::shared_ptr<MidiDiskstream> midi_diskstream () const;
156 void write_out_of_band_data (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, framecnt_t nframes);
158 void set_state_part_two ();
159 void set_state_part_three ();
162 int no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool state_changing);
163 void push_midi_input_to_step_edit_ringbuffer (framecnt_t nframes);
165 void diskstream_data_recorded (boost::weak_ptr<MidiSource>);
166 PBD::ScopedConnection _diskstream_data_recorded_connection;
168 void track_input_active (IOChange, void*);
169 void map_input_active (bool);
171 /** Update automation controls to reflect any changes in buffers. */
172 void update_controls (const BufferSet& bufs);
175 } /* namespace ARDOUR*/
177 #endif /* __ardour_midi_track_h__ */