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, TrackMode m = Normal);
45 int roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, int declick, bool& need_butler);
47 void realtime_locate ();
48 void non_realtime_locate (samplepos_t);
50 bool can_be_record_enabled ();
51 bool can_be_record_safe ();
53 void freeze_me (InterThreadInfo&);
56 bool bounceable (boost::shared_ptr<Processor>, bool) const { return false; }
57 boost::shared_ptr<Region> bounce (InterThreadInfo&);
58 boost::shared_ptr<Region> bounce_range (samplepos_t start,
61 boost::shared_ptr<Processor> endpoint,
62 bool include_endpoint);
64 int export_stuff (BufferSet& bufs,
65 samplepos_t start_sample,
66 samplecnt_t end_sample,
67 boost::shared_ptr<Processor> endpoint,
68 bool include_endpoint,
72 int set_state (const XMLNode&, int version);
74 void midi_panic(void);
75 bool write_immediate_event(size_t size, const uint8_t* buf);
77 /** A control that will send "immediate" events to a MIDI track when twiddled */
78 struct MidiControl : public AutomationControl {
79 MidiControl(MidiTrack* route, const Evoral::Parameter& param,
80 boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>())
81 : AutomationControl (route->session(), param, ParameterDescriptor(param), al)
85 bool writable() const { return true; }
86 void restore_value ();
91 void actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
94 virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState);
96 NoteMode note_mode() const { return _note_mode; }
97 void set_note_mode (NoteMode m);
99 std::string describe_parameter (Evoral::Parameter param);
101 bool step_editing() const { return _step_editing; }
102 void set_step_editing (bool yn);
103 MidiRingBuffer<samplepos_t>& step_edit_ring_buffer() { return _step_edit_ring_buffer; }
105 PBD::Signal1<void,bool> StepEditStatusChange;
107 boost::shared_ptr<SMFSource> write_source (uint32_t n = 0);
109 /* Configure capture/playback channels (see MidiChannelFilter). */
110 void set_capture_channel_mode (ChannelMode mode, uint16_t mask);
111 void set_playback_channel_mode (ChannelMode mode, uint16_t mask);
112 void set_playback_channel_mask (uint16_t mask);
113 void set_capture_channel_mask (uint16_t mask);
115 ChannelMode get_playback_channel_mode() const { return _playback_filter.get_channel_mode(); }
116 ChannelMode get_capture_channel_mode() const { return _capture_filter.get_channel_mode(); }
117 uint16_t get_playback_channel_mask() const { return _playback_filter.get_channel_mask(); }
118 uint16_t get_capture_channel_mask() const { return _capture_filter.get_channel_mask(); }
120 MidiChannelFilter& playback_filter() { return _playback_filter; }
121 MidiChannelFilter& capture_filter() { return _capture_filter; }
123 boost::shared_ptr<MidiPlaylist> midi_playlist ();
125 PBD::Signal1<void, boost::weak_ptr<MidiSource> > DataRecorded;
126 boost::shared_ptr<MidiBuffer> get_gui_feed_buffer () const;
128 MonitorState monitoring_state () const;
130 void set_input_active (bool);
131 bool input_active () const;
132 PBD::Signal0<void> InputActiveChanged;
135 XMLNode& state (bool full);
138 void monitoring_changed (bool, PBD::Controllable::GroupControlDisposition);
141 MidiRingBuffer<samplepos_t> _immediate_events;
142 MidiRingBuffer<samplepos_t> _step_edit_ring_buffer;
146 MidiChannelFilter _playback_filter;
147 MidiChannelFilter _capture_filter;
149 void write_out_of_band_data (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, samplecnt_t nframes);
151 void set_state_part_two ();
152 void set_state_part_three ();
154 int no_roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool state_changing);
155 void push_midi_input_to_step_edit_ringbuffer (samplecnt_t nframes);
157 void track_input_active (IOChange, void*);
158 void map_input_active (bool);
160 /** Update automation controls to reflect any changes in buffers. */
161 void update_controls (const BufferSet& bufs);
162 void restore_controls ();
165 } /* namespace ARDOUR*/
167 #endif /* __ardour_midi_track_h__ */