Ardour  9.0-pre0-582-g084a23a80d
midi_channel_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 David Robillard <d@drobilla.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #pragma once
20 
21 #include <atomic>
22 #include <cstdint>
23 
24 #include <glib.h>
25 
26 #include "pbd/signals.h"
27 
28 #include "ardour/types.h"
29 
30 namespace ARDOUR
31 {
32 
33 class BufferSet;
34 
48 {
49 public:
51 
53  void filter(BufferSet& bufs);
54 
61  bool filter(uint8_t* buf, uint32_t len);
62 
66  bool set_channel_mode(ChannelMode mode, uint16_t mask);
67 
71  bool set_channel_mask(uint16_t mask);
72 
74  void get_mode_and_mask(ChannelMode* mode, uint16_t* mask) const {
75  const uint32_t mm = _mode_mask.load();
76  *mode = static_cast<ChannelMode>((mm & 0xFFFF0000) >> 16);
77  *mask = (mm & 0x0000FFFF);
78  }
79 
81  return static_cast<ChannelMode> ((_mode_mask.load() & 0xFFFF0000) >> 16);
82  }
83 
84  uint16_t get_channel_mask() const {
85  return _mode_mask.load() & 0x0000FFFF;
86  }
87 
90 
91 private:
92  std::atomic<uint32_t> _mode_mask;
93 };
94 
95 } /* namespace ARDOUR */
96 
PBD::Signal< void()> ChannelMaskChanged
std::atomic< uint32_t > _mode_mask
16 bits mode, 16 bits mask
bool set_channel_mask(uint16_t mask)
void get_mode_and_mask(ChannelMode *mode, uint16_t *mask) const
void filter(BufferSet &bufs)
bool set_channel_mode(ChannelMode mode, uint16_t mask)
ChannelMode get_channel_mode() const
bool filter(uint8_t *buf, uint32_t len)
uint16_t get_channel_mask() const
PBD::Signal< void()> ChannelModeChanged
#define LIBARDOUR_API