fix SConstruct so that it can build from a git checkout rather than an svn checkout
[ardour.git] / libs / ardour / ardour / base_audio_port.h
1 /*
2     Copyright (C) 2002 Paul Davis 
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
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18     $Id: port.h 712 2006-07-28 01:08:57Z drobilla $
19 */
20
21 #ifndef __ardour_base_audio_port_h__
22 #define __ardour_base_audio_port_h__
23
24 #include <string>
25
26 #include <sigc++/signal.h>
27
28 #include <pbd/failed_constructor.h>
29
30 #include <ardour/ardour.h>
31 #include <ardour/port.h>
32 #include <ardour/audio_buffer.h>
33
34 namespace ARDOUR {
35
36 class AudioEngine;
37
38 class BaseAudioPort : public virtual Port {
39   public:
40         virtual ~BaseAudioPort();
41
42         DataType type() const { return DataType::AUDIO; }
43
44         virtual Buffer& get_buffer () {
45                 assert (_buffer);
46                 return *_buffer;
47         }
48
49         virtual AudioBuffer& get_audio_buffer() {
50                 assert (_buffer);
51                 return *_buffer;
52         }
53         
54         void reset ();
55
56         void reset_overs () {
57                 /* XXX NOT THREAD SAFE */
58                 _short_overs = 0;
59                 _long_overs = 0;
60                 _overlen = 0;
61         }
62
63         void reset_peak_meter () {
64                 /* XXX NOT THREAD SAFE */
65                 _peak = 0;
66         }
67         
68         void reset_meters () {
69                 /* XXX NOT THREAD SAFE */
70                 reset_peak_meter ();
71                 reset_overs ();
72         }
73
74         float  peak_db() const { return _peak_db; }
75         Sample peak()    const { return _peak; }
76
77         uint32_t short_overs () const { return _short_overs; }
78         uint32_t long_overs ()  const { return _long_overs; }
79         
80         static void set_short_over_length (nframes_t);
81         static void set_long_over_length (nframes_t);
82
83         void set_mixdown_function (void (*func)(const std::set<Port*>&, AudioBuffer*, nframes_t, nframes_t, bool));
84
85   protected:
86         BaseAudioPort (const std::string& name, Flags flags);
87
88         AudioBuffer* _buffer;
89         nframes_t    _overlen;
90         Sample       _peak;
91         float        _peak_db;
92         uint32_t     _short_overs;
93         uint32_t     _long_overs;
94         bool         _own_buffer;
95
96         void (*_mixdown)(const std::set<Port*>&, AudioBuffer*, nframes_t, nframes_t, bool);
97
98         static void default_mixdown (const std::set<Port*>&, AudioBuffer*, nframes_t, nframes_t, bool);
99         
100         static nframes_t _long_over_length;
101         static nframes_t _short_over_length;
102 };
103  
104 } // namespace ARDOUR
105
106 #endif /* __ardour_base_audio_port_h__ */