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;
36 class LIBARDOUR_API MidiTrack : public Track
39 MidiTrack (Session&, std::string name, TrackMode m = Normal);
44 void realtime_locate ();
45 void non_realtime_locate (samplepos_t);
47 bool can_be_record_enabled ();
48 bool can_be_record_safe ();
50 void freeze_me (InterThreadInfo&);
53 bool bounceable (boost::shared_ptr<Processor>, bool) const { return false; }
54 boost::shared_ptr<Region> bounce (InterThreadInfo&);
55 boost::shared_ptr<Region> bounce_range (samplepos_t start,
58 boost::shared_ptr<Processor> endpoint,
59 bool include_endpoint);
61 int export_stuff (BufferSet& bufs,
62 samplepos_t start_sample,
63 samplecnt_t end_sample,
64 boost::shared_ptr<Processor> endpoint,
65 bool include_endpoint,
69 int set_state (const XMLNode&, int version);
71 void midi_panic(void);
72 bool write_immediate_event(size_t size, const uint8_t* buf);
74 /** A control that will send "immediate" events to a MIDI track when twiddled */
75 struct MidiControl : public AutomationControl {
76 MidiControl(MidiTrack* route, const Evoral::Parameter& param,
77 boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>())
78 : AutomationControl (route->session(), param, ParameterDescriptor(param), al)
82 bool writable() const { return true; }
83 void restore_value ();
88 void actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
91 virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState);
93 NoteMode note_mode() const { return _note_mode; }
94 void set_note_mode (NoteMode m);
96 std::string describe_parameter (Evoral::Parameter param);
98 bool step_editing() const { return _step_editing; }
99 void set_step_editing (bool yn);
100 MidiRingBuffer<samplepos_t>& step_edit_ring_buffer() { return _step_edit_ring_buffer; }
102 PBD::Signal1<void,bool> StepEditStatusChange;
104 boost::shared_ptr<SMFSource> write_source (uint32_t n = 0);
106 /* Configure capture/playback channels (see MidiChannelFilter). */
107 void set_capture_channel_mode (ChannelMode mode, uint16_t mask);
108 void set_playback_channel_mode (ChannelMode mode, uint16_t mask);
109 void set_playback_channel_mask (uint16_t mask);
110 void set_capture_channel_mask (uint16_t mask);
112 ChannelMode get_playback_channel_mode() const { return _playback_filter.get_channel_mode(); }
113 ChannelMode get_capture_channel_mode() const { return _capture_filter.get_channel_mode(); }
114 uint16_t get_playback_channel_mask() const { return _playback_filter.get_channel_mask(); }
115 uint16_t get_capture_channel_mask() const { return _capture_filter.get_channel_mask(); }
117 MidiChannelFilter& playback_filter() { return _playback_filter; }
118 MidiChannelFilter& capture_filter() { return _capture_filter; }
120 virtual void filter_input (BufferSet& bufs);
122 boost::shared_ptr<MidiPlaylist> midi_playlist ();
124 PBD::Signal1<void, boost::weak_ptr<MidiSource> > DataRecorded;
125 boost::shared_ptr<MidiBuffer> get_gui_feed_buffer () const;
127 MonitorState monitoring_state () const;
128 MonitorState get_auto_monitoring_state () const;
130 MidiBuffer const& immediate_event_buffer () const { return _immediate_event_buffer; }
132 void set_input_active (bool);
133 bool input_active () const;
134 PBD::Signal0<void> InputActiveChanged;
138 XMLNode& state (bool save_template);
141 void monitoring_changed (bool, PBD::Controllable::GroupControlDisposition);
143 void snapshot_out_of_band_data (samplecnt_t nframes);
144 void write_out_of_band_data (BufferSet& bufs, samplecnt_t /* nframes */) const;
148 MidiRingBuffer<samplepos_t> _immediate_events;
149 MidiBuffer _immediate_event_buffer;
150 MidiRingBuffer<samplepos_t> _step_edit_ring_buffer;
154 MidiChannelFilter _playback_filter;
155 MidiChannelFilter _capture_filter;
157 void set_state_part_two ();
158 void set_state_part_three ();
160 int no_roll_unlocked (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool state_changing);
161 void push_midi_input_to_step_edit_ringbuffer (samplecnt_t nframes);
163 void track_input_active (IOChange, void*);
164 void map_input_active (bool);
166 void data_recorded (boost::weak_ptr<MidiSource> src);
168 /** Update automation controls to reflect any changes in buffers. */
169 void update_controls (BufferSet const& bufs);
170 void restore_controls ();
173 } /* namespace ARDOUR*/
175 #endif /* __ardour_midi_track_h__ */