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/track.h"
24 #include "ardour/midi_ring_buffer.h"
29 class InterThreadInfo;
36 class MidiTrack : public Track
39 MidiTrack (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal);
44 int roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& need_butler);
46 void realtime_handle_transport_stopped ();
47 void realtime_locate ();
49 boost::shared_ptr<Diskstream> create_diskstream ();
50 void set_diskstream (boost::shared_ptr<Diskstream>);
51 void set_record_enabled (bool yn, void *src);
53 DataType data_type () const {
54 return DataType::MIDI;
57 void freeze_me (InterThreadInfo&);
60 bool bounceable (boost::shared_ptr<Processor>, bool) const { return false; }
61 boost::shared_ptr<Region> bounce (InterThreadInfo&);
62 boost::shared_ptr<Region> bounce_range (framepos_t start,
65 boost::shared_ptr<Processor> endpoint,
66 bool include_endpoint);
68 int export_stuff (BufferSet& bufs,
69 framepos_t start_frame,
71 boost::shared_ptr<Processor> endpoint,
72 bool include_endpoint,
75 int set_state (const XMLNode&, int version);
77 void midi_panic(void);
78 bool write_immediate_event(size_t size, const uint8_t* buf);
80 /** A control that will send "immediate" events to a MIDI track when twiddled */
81 struct MidiControl : public AutomationControl {
82 MidiControl(MidiTrack* route, const Evoral::Parameter& param,
83 boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>())
84 : AutomationControl (route->session(), param, al)
88 void set_value (double val);
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<framepos_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);
105 void set_channel_mode (ChannelMode, uint16_t);
106 ChannelMode get_channel_mode ();
107 uint16_t get_channel_mask ();
108 boost::shared_ptr<MidiPlaylist> midi_playlist ();
110 PBD::Signal1<void, boost::weak_ptr<MidiSource> > DataRecorded;
111 boost::shared_ptr<MidiBuffer> get_gui_feed_buffer () const;
113 void set_monitoring (MonitorChoice);
114 MonitorState monitoring_state () const;
116 void set_input_active (bool);
117 bool input_active () const;
118 PBD::Signal0<void> InputActiveChanged;
121 XMLNode& state (bool full);
127 virtual boost::shared_ptr<Diskstream> diskstream_factory (XMLNode const &);
129 boost::shared_ptr<MidiDiskstream> midi_diskstream () const;
131 void write_out_of_band_data (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, framecnt_t nframes);
133 void set_state_part_two ();
134 void set_state_part_three ();
136 MidiRingBuffer<framepos_t> _immediate_events;
137 MidiRingBuffer<framepos_t> _step_edit_ring_buffer;
142 int no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool state_changing);
143 void push_midi_input_to_step_edit_ringbuffer (framecnt_t nframes);
145 void diskstream_data_recorded (boost::weak_ptr<MidiSource>);
146 PBD::ScopedConnection _diskstream_data_recorded_connection;
148 void track_input_active (IOChange, void*);
149 void map_input_active (bool);
152 } /* namespace ARDOUR*/
154 #endif /* __ardour_midi_track_h__ */