Ardour  8.12
midi_port.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2007-2018 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2015-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 #ifndef __ardour_midi_port_h__
23 #define __ardour_midi_port_h__
24 
25 #include "midi++/parser.h"
26 
27 #include "ardour/port.h"
28 #include "ardour/midi_buffer.h"
29 
30 namespace ARDOUR {
31 
32 class MidiBuffer;
33 class MidiEngine;
34 
35 class LIBARDOUR_API MidiPort : public Port {
36  public:
38 
39  DataType type () const {
40  return DataType::MIDI;
41  }
42 
43  void cycle_start (pframes_t nframes);
44  void cycle_end (pframes_t nframes);
45  void cycle_split ();
46 
47  void flush_buffers (pframes_t nframes);
49  void realtime_locate (bool);
50  void reset ();
51  void require_resolve ();
52 
53  bool input_active() const { return _input_active; }
54  void set_input_active (bool yn);
55 
57  return get_midi_buffer (nframes);
58  }
59 
61 
62  void set_trace (std::weak_ptr<MIDI::Parser> trace_parser);
63  std::shared_ptr<MIDI::Parser> trace_parser() const;
64 
65  typedef boost::function<bool(MidiBuffer&,MidiBuffer&)> MidiFilter;
67  int add_shadow_port (std::string const &, MidiFilter);
68  std::shared_ptr<MidiPort> shadow_port() const { return _shadow_port; }
69 
71 
72 protected:
73  friend class PortManager;
74 
75  MidiPort (const std::string& name, PortFlags);
76 
77 private:
82  std::shared_ptr<MidiPort> _shadow_port;
84  std::weak_ptr<MIDI::Parser> _trace_parser;
86 
87  void resolve_notes (void* buffer, samplepos_t when);
88  void pull_input (pframes_t nframes, bool adjust_speed);
89  void parse_input (pframes_t nframes, MIDI::Parser& parser);
90 };
91 
92 } // namespace ARDOUR
93 
94 #endif /* __ardour_midi_port_h__ */
void realtime_locate(bool)
MidiFilter _inbound_midi_filter
Definition: midi_port.h:81
void cycle_end(pframes_t nframes)
std::shared_ptr< MIDI::Parser > trace_parser() const
MidiPort(const std::string &name, PortFlags)
void pull_input(pframes_t nframes, bool adjust_speed)
void set_inbound_filter(MidiFilter)
bool _input_active
Definition: midi_port.h:80
std::shared_ptr< MidiPort > shadow_port() const
Definition: midi_port.h:68
bool _data_fetched_for_cycle
Definition: midi_port.h:85
void set_trace(std::weak_ptr< MIDI::Parser > trace_parser)
int add_shadow_port(std::string const &, MidiFilter)
bool _resolve_required
Definition: midi_port.h:79
void transport_stopped()
void require_resolve()
bool input_active() const
Definition: midi_port.h:53
MidiFilter _shadow_midi_filter
Definition: midi_port.h:83
void resolve_notes(void *buffer, samplepos_t when)
MidiBuffer * _buffer
Definition: midi_port.h:78
void cycle_start(pframes_t nframes)
MidiBuffer & get_midi_buffer(pframes_t nframes)
std::weak_ptr< MIDI::Parser > _trace_parser
Definition: midi_port.h:84
boost::function< bool(MidiBuffer &, MidiBuffer &)> MidiFilter
Definition: midi_port.h:65
Buffer & get_buffer(pframes_t nframes)
Definition: midi_port.h:56
void set_input_active(bool yn)
void parse_input(pframes_t nframes, MIDI::Parser &parser)
void flush_buffers(pframes_t nframes)
void read_and_parse_entire_midi_buffer_with_no_speed_adjustment(pframes_t nframes, MIDI::Parser &parser, samplepos_t now)
DataType type() const
Definition: midi_port.h:39
std::shared_ptr< MidiPort > _shadow_port
Definition: midi_port.h:82
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
uint32_t pframes_t
Temporal::samplepos_t samplepos_t