Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
23 
24 #include "midi++/parser.h"
25 
26 #include "ardour/port.h"
27 #include "ardour/midi_buffer.h"
28 
29 namespace ARDOUR {
30 
31 class MidiBuffer;
32 class MidiEngine;
33 
34 class LIBARDOUR_API MidiPort : public Port {
35  public:
37 
38  DataType type () const {
39  return DataType::MIDI;
40  }
41 
42  void cycle_start (pframes_t nframes);
43  void cycle_end (pframes_t nframes);
44  void cycle_split ();
45 
46  void flush_buffers (pframes_t nframes);
48  void realtime_locate (bool);
49  void reset ();
50  void require_resolve ();
51 
52  bool input_active() const { return _input_active; }
53  void set_input_active (bool yn);
54 
56  return get_midi_buffer (nframes);
57  }
58 
60 
61  void set_trace (std::weak_ptr<MIDI::Parser> trace_parser);
62  std::shared_ptr<MIDI::Parser> trace_parser() const;
63 
64  typedef std::function<bool(MidiBuffer&,MidiBuffer&)> MidiFilter;
66  int add_shadow_port (std::string const &, MidiFilter);
67  std::shared_ptr<MidiPort> shadow_port() const { return _shadow_port; }
68 
70 
71 protected:
72  friend class PortManager;
73 
74  MidiPort (const std::string& name, PortFlags);
75 
76 private:
81  std::shared_ptr<MidiPort> _shadow_port;
83  std::weak_ptr<MIDI::Parser> _trace_parser;
85 
86  void resolve_notes (void* buffer, samplepos_t when);
87  void pull_input (pframes_t nframes, bool adjust_speed);
88  void parse_input (pframes_t nframes, MIDI::Parser& parser);
89 };
90 
91 } // namespace ARDOUR
92 
void realtime_locate(bool)
MidiFilter _inbound_midi_filter
Definition: midi_port.h:80
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:79
std::shared_ptr< MidiPort > shadow_port() const
Definition: midi_port.h:67
bool _data_fetched_for_cycle
Definition: midi_port.h:84
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:78
void transport_stopped()
void require_resolve()
bool input_active() const
Definition: midi_port.h:52
MidiFilter _shadow_midi_filter
Definition: midi_port.h:82
void resolve_notes(void *buffer, samplepos_t when)
MidiBuffer * _buffer
Definition: midi_port.h:77
void cycle_start(pframes_t nframes)
MidiBuffer & get_midi_buffer(pframes_t nframes)
std::function< bool(MidiBuffer &, MidiBuffer &)> MidiFilter
Definition: midi_port.h:64
std::weak_ptr< MIDI::Parser > _trace_parser
Definition: midi_port.h:83
Buffer & get_buffer(pframes_t nframes)
Definition: midi_port.h:55
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:38
std::shared_ptr< MidiPort > _shadow_port
Definition: midi_port.h:81
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
uint32_t pframes_t
Temporal::samplepos_t samplepos_t