2 Copyright (C) 2006 Paul Davis
3 Written by Dave 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"
25 #include "ardour/midi_state_tracker.h"
36 class MidiTrack : public Track
39 MidiTrack (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal);
42 int roll (nframes_t nframes, framepos_t start_frame, framepos_t end_frame,
43 int declick, bool can_record, bool rec_monitors_input, bool& need_butler);
45 void handle_transport_stopped (bool abort, bool did_locate, bool flush_processors);
47 void use_new_diskstream ();
48 void set_diskstream (boost::shared_ptr<Diskstream>);
49 void set_record_enabled (bool yn, void *src);
51 DataType data_type () const {
52 return DataType::MIDI;
55 void set_latency_delay (nframes_t);
57 int export_stuff (BufferSet& bufs, nframes_t nframes, framepos_t end_frame);
59 void freeze_me (InterThreadInfo&);
62 boost::shared_ptr<Region> bounce (InterThreadInfo&);
63 boost::shared_ptr<Region> bounce_range (
64 nframes_t start, nframes_t end, InterThreadInfo&, bool enable_processing);
66 int set_state(const XMLNode&, int version);
68 void midi_panic(void);
69 bool write_immediate_event(size_t size, const uint8_t* buf);
71 /** A control that will send "immediate" events to a MIDI track when twiddled */
72 struct MidiControl : public AutomationControl {
73 MidiControl(MidiTrack* route, const Evoral::Parameter& param,
74 boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>())
75 : AutomationControl (route->session(), param, al)
79 void set_value (double val);
84 NoteMode note_mode() const { return _note_mode; }
85 void set_note_mode (NoteMode m);
87 bool step_editing() const { return _step_editing; }
88 void set_step_editing (bool yn);
89 MidiRingBuffer<nframes_t>& step_edit_ring_buffer() { return _step_edit_ring_buffer; }
91 PBD::Signal1<void,bool> StepEditStatusChange;
93 uint8_t default_channel() const { return _default_channel; }
94 void set_default_channel (uint8_t chn);
96 bool midi_thru() const { return _midi_thru; }
97 void set_midi_thru (bool yn);
99 boost::shared_ptr<SMFSource> write_source (uint32_t n = 0);
100 void set_channel_mode (ChannelMode, uint16_t);
101 ChannelMode get_channel_mode ();
102 uint16_t get_channel_mask ();
103 boost::shared_ptr<MidiPlaylist> midi_playlist ();
105 PBD::Signal2<void, boost::shared_ptr<MidiBuffer>, boost::weak_ptr<MidiSource> > DataRecorded;
108 XMLNode& state (bool full);
110 int _set_state (const XMLNode&, int, bool call_base);
113 boost::shared_ptr<MidiDiskstream> midi_diskstream () const;
115 void write_out_of_band_data (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, nframes_t nframes);
117 void set_state_part_two ();
118 void set_state_part_three ();
120 MidiRingBuffer<nframes_t> _immediate_events;
121 MidiRingBuffer<nframes_t> _step_edit_ring_buffer;
124 uint8_t _default_channel;
127 int no_roll (nframes_t nframes, framepos_t start_frame, framepos_t end_frame,
128 bool state_changing, bool can_record, bool rec_monitors_input);
129 void push_midi_input_to_step_edit_ringbuffer (nframes_t nframes);
131 void diskstream_data_recorded (boost::shared_ptr<MidiBuffer>, boost::weak_ptr<MidiSource>);
132 PBD::ScopedConnection _diskstream_data_recorded_connection;
135 } /* namespace ARDOUR*/
137 #endif /* __ardour_midi_track_h__ */