Ardour  9.0-pre0-582-g084a23a80d
midi_track.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2015 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #pragma once
23 
26 #include "ardour/track.h"
27 
28 namespace ARDOUR
29 {
30 
31 class InterThreadInfo;
32 class MidiPlaylist;
33 class RouteGroup;
34 class SMFSource;
35 class Session;
36 class VelocityControl;
37 
39 {
40 public:
41  MidiTrack (Session&, std::string name = "", TrackMode m = Normal);
43 
44  int init ();
45 
46  void realtime_locate (bool);
48 
51 
53  void unfreeze ();
54 
55  bool bounceable (std::shared_ptr<Processor>, bool include_endpoint) const;
56 
57  int export_stuff (BufferSet& bufs,
58  samplepos_t start_sample,
59  samplecnt_t end_sample,
60  std::shared_ptr<Processor> endpoint,
61  bool include_endpoint,
62  bool for_export,
63  bool for_freeze,
64  MidiNoteTracker& tracker);
65 
66  int set_state (const XMLNode&, int version);
67 
68  void midi_panic(void);
69  bool write_immediate_event (Evoral::EventType event_type, size_t size, const uint8_t* buf);
70  bool write_user_immediate_event (Evoral::EventType event_type, size_t size, const uint8_t* buf);
71 
72  std::shared_ptr<VelocityControl> velocity_control() const { return _velocity_control; }
73 
75  struct MidiControl : public AutomationControl {
76  MidiControl(MidiTrack* route, const Evoral::Parameter& param,
77  std::shared_ptr<AutomationList> al = std::shared_ptr<AutomationList>())
78  : AutomationControl (route->session(), param, ParameterDescriptor(param), al)
79  , _route (route)
80  {}
81 
82  bool writable() const { return true; }
83  void restore_value ();
84 
86 
87  private:
89  };
90 
92 
93  NoteMode note_mode() const { return _note_mode; }
95 
97 
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; }
101 
103 
104  std::shared_ptr<SMFSource> write_source (uint32_t n = 0);
105 
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);
111 
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(); }
116 
117  MidiChannelFilter& playback_filter() { return _playback_filter; }
118  MidiChannelFilter& capture_filter() { return _capture_filter; }
119 
120  virtual void filter_input (BufferSet& bufs);
121 
122  std::shared_ptr<MidiPlaylist> midi_playlist ();
123 
124  PBD::Signal<void(std::weak_ptr<MidiSource> )> DataRecorded;
125  std::shared_ptr<MidiBuffer> get_gui_feed_buffer () const;
126 
128  MonitorState get_input_monitoring_state (bool recording, bool talkback) const;
129 
130  MidiBuffer const& immediate_event_buffer () const { return _immediate_event_buffer; }
131  MidiBuffer const& user_immediate_event_buffer () const { return _user_immediate_event_buffer; }
132  MidiRingBuffer<samplepos_t>& immediate_events () { return _immediate_events; }
133  MidiRingBuffer<samplepos_t>& user_immediate_events () { return _user_immediate_events; }
134 
135  void set_input_active (bool);
136  bool input_active () const;
138 
139  void set_restore_pgm_on_load (bool yn);
140  bool restore_pgm_on_load () const;
141 
143  void region_edited (std::shared_ptr<Region>);
144 
145 protected:
146 
147  XMLNode& state (bool save_template) const;
148 
149  void act_on_mute ();
151 
153  void write_out_of_band_data (BufferSet& bufs, samplecnt_t /* nframes */) const;
154 
155 
156 private:
168 
169  std::shared_ptr<VelocityControl> _velocity_control;
170 
173 
174  int no_roll_unlocked (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool state_changing);
176 
178  void map_input_active (bool);
179 
180  void data_recorded (std::weak_ptr<MidiSource> src);
181 
183  void update_controls (BufferSet const& bufs);
185 
188 };
189 
190 } /* namespace ARDOUR*/
191 
MidiBuffer const & immediate_event_buffer() const
Definition: midi_track.h:130
NoteMode _note_mode
Definition: midi_track.h:162
void realtime_locate(bool)
std::shared_ptr< MidiPlaylist > midi_playlist()
void realtime_handle_transport_stopped()
void region_edited(std::shared_ptr< Region >)
void set_step_editing(bool yn)
MidiRingBuffer< samplepos_t > _immediate_events
Definition: midi_track.h:157
virtual void set_parameter_automation_state(Evoral::Parameter param, AutoState)
std::shared_ptr< VelocityControl > _velocity_control
Definition: midi_track.h:169
void set_state_part_two()
bool write_immediate_event(Evoral::EventType event_type, size_t size, const uint8_t *buf)
virtual void filter_input(BufferSet &bufs)
bool _restore_pgm_on_load
Definition: midi_track.h:165
MidiBuffer _immediate_event_buffer
Definition: midi_track.h:159
void freeze_me(InterThreadInfo &)
MidiChannelFilter _capture_filter
Definition: midi_track.h:167
void set_note_mode(NoteMode m)
MidiBuffer const & user_immediate_event_buffer() const
Definition: midi_track.h:131
PBD::Signal< void(bool)> StepEditStatusChange
Definition: midi_track.h:102
bool bounceable(std::shared_ptr< Processor >, bool include_endpoint) const
int no_roll_unlocked(pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool state_changing)
bool write_user_immediate_event(Evoral::EventType event_type, size_t size, const uint8_t *buf)
void midi_panic(void)
NoteMode note_mode() const
Definition: midi_track.h:93
uint16_t get_playback_channel_mask() const
Definition: midi_track.h:114
PBD::Signal< void()> InputActiveChanged
Definition: midi_track.h:137
MidiChannelFilter & capture_filter()
Definition: midi_track.h:118
void non_realtime_locate(samplepos_t)
MonitorState get_input_monitoring_state(bool recording, bool talkback) const
std::shared_ptr< MidiBuffer > get_gui_feed_buffer() const
void set_playback_channel_mode(ChannelMode mode, uint16_t mask)
void playlist_contents_changed()
ChannelMode get_playback_channel_mode() const
Definition: midi_track.h:112
PBD::Signal< void(std::weak_ptr< MidiSource >)> DataRecorded
Definition: midi_track.h:124
int export_stuff(BufferSet &bufs, samplepos_t start_sample, samplecnt_t end_sample, std::shared_ptr< Processor > endpoint, bool include_endpoint, bool for_export, bool for_freeze, MidiNoteTracker &tracker)
int set_state(const XMLNode &, int version)
void write_out_of_band_data(BufferSet &bufs, samplecnt_t) const
PBD::ScopedConnection playlist_content_change_connection
Definition: midi_track.h:187
bool can_be_record_enabled()
MonitorState monitoring_state() const
void map_input_active(bool)
bool can_be_record_safe()
std::shared_ptr< VelocityControl > velocity_control() const
Definition: midi_track.h:72
void snapshot_out_of_band_data(samplecnt_t nframes)
std::string describe_parameter(Evoral::Parameter param)
void push_midi_input_to_step_edit_ringbuffer(samplecnt_t nframes)
MidiRingBuffer< samplepos_t > _user_immediate_events
Definition: midi_track.h:158
void set_playback_channel_mask(uint16_t mask)
ChannelMode get_capture_channel_mode() const
Definition: midi_track.h:113
MidiChannelFilter _playback_filter
Definition: midi_track.h:166
MidiRingBuffer< samplepos_t > & immediate_events()
Definition: midi_track.h:132
bool step_editing() const
Definition: midi_track.h:98
void set_capture_channel_mask(uint16_t mask)
void set_state_part_three()
MidiChannelFilter & playback_filter()
Definition: midi_track.h:117
MidiRingBuffer< samplepos_t > _step_edit_ring_buffer
Definition: midi_track.h:161
void set_restore_pgm_on_load(bool yn)
MidiRingBuffer< samplepos_t > & user_immediate_events()
Definition: midi_track.h:133
void track_input_active(IOChange, void *)
MidiBuffer _user_immediate_event_buffer
Definition: midi_track.h:160
std::shared_ptr< SMFSource > write_source(uint32_t n=0)
MidiTrack(Session &, std::string name="", TrackMode m=Normal)
void data_recorded(std::weak_ptr< MidiSource > src)
void monitoring_changed(bool, PBD::Controllable::GroupControlDisposition)
void set_capture_channel_mode(ChannelMode mode, uint16_t mask)
void update_controls(BufferSet const &bufs)
void set_input_active(bool)
bool input_active() const
XMLNode & state(bool save_template) const
bool restore_pgm_on_load() const
uint16_t get_capture_channel_mask() const
Definition: midi_track.h:115
MidiRingBuffer< samplepos_t > & step_edit_ring_buffer()
Definition: midi_track.h:100
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
void session(lua_State *L)
uint32_t pframes_t
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
void actually_set_value(double val, PBD::Controllable::GroupControlDisposition group_override)
MidiControl(MidiTrack *route, const Evoral::Parameter &param, std::shared_ptr< AutomationList > al=std::shared_ptr< AutomationList >())
Definition: midi_track.h:76