1 /* 2 * Copyright (C) 2021 Robin Gareus <robin@gareus.org> 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 #ifndef _ardour_monitor_port_h_ 20 #define _ardour_monitor_port_h_ 21 22 #include <boost/shared_ptr.hpp> 23 #include <set> 24 25 #include "zita-resampler/vmresampler.h" 26 27 #include "pbd/rcu.h" 28 29 #include "ardour/audio_buffer.h" 30 #include "ardour/port_engine.h" 31 32 namespace ARDOUR { 33 34 class LIBARDOUR_API MonitorPort : public boost::noncopyable 35 { 36 public: 37 ~MonitorPort (); 38 39 void set_buffer_size (pframes_t); 40 bool silent () const; 41 AudioBuffer& get_audio_buffer (pframes_t); 42 43 void add_port (std::string const&); 44 void remove_port (std::string const&, bool instantly = false); 45 bool monitoring (std::string const& = "") const; 46 void active_monitors (std::list <std::string>&) const; 47 void set_active_monitors (std::list <std::string> const&); 48 void clear_ports (bool instantly); 49 50 PBD::Signal2<void, std::string, bool> MonitorInputChanged; 51 52 protected: 53 friend class PortManager; 54 MonitorPort (); 55 void monitor (PortEngine&, pframes_t); 56 57 private: 58 struct MonitorInfo { MonitorInfoMonitorInfo59 MonitorInfo () 60 { 61 gain = 0; 62 remove = false; 63 } 64 65 float gain; 66 bool remove; 67 }; 68 69 void collect (boost::shared_ptr<MonitorInfo>, Sample*, pframes_t, std::string const&); 70 void finalize (pframes_t); 71 72 typedef std::map<std::string, boost::shared_ptr<MonitorInfo> > MonitorPorts; 73 SerializedRCUManager<MonitorPorts> _monitor_ports; 74 75 AudioBuffer* _buffer; 76 ArdourZita::VMResampler _src; 77 Sample* _input; 78 Sample* _data; 79 pframes_t _insize; 80 bool _silent; 81 }; 82 83 } 84 85 #endif 86