Ardour  9.0-pre0-582-g084a23a80d
midi_region.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2016 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) 2016-2017 Nick Mainsbridge <mainsbridge@gmail.com>
6  * Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #pragma once
24 
25 #include <vector>
26 
27 #include "temporal/beats.h"
28 #include "temporal/range.h"
29 
30 #include "pbd/string_convert.h"
31 
32 #include "ardour/ardour.h"
33 #include "ardour/midi_cursor.h"
34 #include "ardour/region.h"
35 
36 class XMLNode;
37 
38 namespace Evoral {
39 template<typename Time> class EventSink;
40 }
41 
42 namespace ARDOUR {
43 
44 class MidiChannelFilter;
45 class MidiFilter;
46 class MidiModel;
47 class MidiSource;
48 class MidiNoteTracker;
49 class Playlist;
50 class Route;
51 class Session;
52 class ThawList;
53 
54 template<typename T> class MidiRingBuffer;
55 
57 {
58  public:
60 
61  std::shared_ptr<MidiRegion> clone (std::string path = std::string()) const;
62  std::shared_ptr<MidiRegion> clone (std::shared_ptr<MidiSource>, ThawList* tl = 0) const;
63 
64  std::shared_ptr<MidiSource> midi_source (uint32_t n=0) const;
65 
67  timepos_t const & position,
68  timecnt_t const & dur,
69  Temporal::Range* loop_range,
70  MidiCursor& cursor,
71  uint32_t chan_n = 0,
72  NoteMode mode = Sustained,
73  MidiNoteTracker* tracker = 0,
74  MidiChannelFilter* filter = 0) const;
75 
77  timepos_t const & position,
78  timecnt_t const & dur,
79  Temporal::Range* loop_range,
80  MidiCursor& cursor,
81  uint32_t chan_n = 0,
82  NoteMode mode = Sustained) const;
83 
84  void merge (std::shared_ptr<MidiRegion const>);
85 
86  XMLNode& state () const;
87  int set_state (const XMLNode&, int version);
88 
89  int separate_by_channel (std::vector< std::shared_ptr<Region> >&) const;
90 
91  /* automation */
92 
93  std::shared_ptr<Evoral::Control> control(const Evoral::Parameter& id, bool create=false);
94 
95  std::shared_ptr<const Evoral::Control> control(const Evoral::Parameter& id) const;
96 
97  /* export */
98 
99  bool do_export (std::string const& path) const;
100 
101  std::shared_ptr<MidiModel> model();
102  std::shared_ptr<const MidiModel> model() const;
103 
105 
107  uint32_t chan_n,
108  NoteMode mode,
109  MidiChannelFilter* filter) const;
110 
112  uint32_t chan_n,
113  NoteMode mode,
114  timepos_t const & read_start,
115  timecnt_t const & read_length,
116  MidiChannelFilter* filter) const;
117 
120 
121  protected:
122 
123  virtual bool can_trim_start_before_source_start () const {
124  return true;
125  }
126 
127  private:
128  friend class RegionFactory;
129 
131  MidiRegion (std::shared_ptr<const MidiRegion>);
132  MidiRegion (std::shared_ptr<const MidiRegion>, timecnt_t const & offset);
133 
135  timepos_t const & position,
136  timecnt_t const & dur,
137  Temporal::Range* loop_range,
138  MidiCursor& cursor,
139  uint32_t chan_n = 0,
140  NoteMode mode = Sustained,
141  MidiNoteTracker* tracker = 0,
142  MidiChannelFilter* filter = 0) const;
143 
145 
148 
149  bool set_name (const std::string & str);
150 
151  void model_changed ();
153  void model_shifted (timecnt_t qn_distance);
155 
156  std::set<Evoral::Parameter> _filtered_parameters;
163 };
164 
165 } /* namespace ARDOUR */
166 
167 
std::shared_ptr< MidiSource > midi_source(uint32_t n=0) const
std::shared_ptr< const MidiModel > model() const
std::shared_ptr< const Evoral::Control > control(const Evoral::Parameter &id) const
std::shared_ptr< MidiRegion > clone(std::string path=std::string()) const
std::shared_ptr< MidiModel > model()
int set_state(const XMLNode &, int version)
void finish_domain_bounce(Temporal::DomainBounceInfo &)
timecnt_t master_read_at(MidiRingBuffer< samplepos_t > &dst, timepos_t const &position, timecnt_t const &dur, Temporal::Range *loop_range, MidiCursor &cursor, uint32_t chan_n=0, NoteMode mode=Sustained) const
std::shared_ptr< Evoral::Control > control(const Evoral::Parameter &id, bool create=false)
MidiRegion(std::shared_ptr< const MidiRegion >, timecnt_t const &offset)
PBD::ScopedConnection _source_connection
Definition: midi_region.h:160
bool do_export(std::string const &path) const
PBD::ScopedConnection _model_changed_connection
Definition: midi_region.h:159
void register_properties()
MidiRegion(const SourceList &)
PBD::ScopedConnection _model_shift_connection
Definition: midi_region.h:158
timecnt_t _read_at(const SourceList &, Evoral::EventSink< samplepos_t > &dst, timepos_t const &position, timecnt_t const &dur, Temporal::Range *loop_range, MidiCursor &cursor, uint32_t chan_n=0, NoteMode mode=Sustained, MidiNoteTracker *tracker=0, MidiChannelFilter *filter=0) const
int render_range(Evoral::EventSink< samplepos_t > &dst, uint32_t chan_n, NoteMode mode, timepos_t const &read_start, timecnt_t const &read_length, MidiChannelFilter *filter) const
PBD::ScopedConnection _model_contents_connection
Definition: midi_region.h:161
bool set_name(const std::string &str)
std::shared_ptr< MidiRegion > clone(std::shared_ptr< MidiSource >, ThawList *tl=0) const
void model_automation_state_changed(Evoral::Parameter const &)
int render(Evoral::EventSink< samplepos_t > &dst, uint32_t chan_n, NoteMode mode, MidiChannelFilter *filter) const
std::set< Evoral::Parameter > _filtered_parameters
parameters that we ask our source not to return when reading
Definition: midi_region.h:156
void start_domain_bounce(Temporal::DomainBounceInfo &)
void model_shifted(timecnt_t qn_distance)
XMLNode & state() const
void model_contents_changed()
timecnt_t read_at(Evoral::EventSink< samplepos_t > &dst, timepos_t const &position, timecnt_t const &dur, Temporal::Range *loop_range, MidiCursor &cursor, uint32_t chan_n=0, NoteMode mode=Sustained, MidiNoteTracker *tracker=0, MidiChannelFilter *filter=0) const
MidiRegion(std::shared_ptr< const MidiRegion >)
virtual bool can_trim_start_before_source_start() const
Definition: midi_region.h:123
PBD::ScopedConnection _model_connection
Definition: midi_region.h:157
void merge(std::shared_ptr< MidiRegion const >)
int separate_by_channel(std::vector< std::shared_ptr< Region > > &) const
std::vector< std::shared_ptr< Source > > SourceList
Definition: xml++.h:114
#define LIBARDOUR_API
Definition: editor.h:86
DebugBits MidiRingBuffer