Ardour  9.0-pre0-582-g084a23a80d
buffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2012 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2013-2014 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 <stddef.h>
25 
27 #include "ardour/types.h"
28 #include "ardour/data_type.h"
29 
30 namespace ARDOUR {
31 
32 
43 {
44 public:
45  Buffer (const Buffer&) = delete;
46  Buffer& operator= (const Buffer&) = delete;
47  virtual ~Buffer() {}
48 
50  static Buffer* create(DataType type, size_t capacity);
51 
53  size_t capacity() const { return _capacity; }
54 
57  DataType type() const { return _type; }
58 
59  bool silent() const { return _silent; }
60 
66  virtual void resize (size_t) = 0;
67 
69  virtual void silence (samplecnt_t len, samplecnt_t offset = 0) = 0;
70 
71  /* return true if all data is silent (or for MIDI-like, non-existent */
72  virtual bool silent_data () const = 0;
73 
75  virtual void clear() { silence(_capacity, 0); }
76 
77  virtual void read_from (const Buffer& src, samplecnt_t len, sampleoffset_t dst_offset = 0, sampleoffset_t src_offset = 0) = 0;
78  virtual void merge_from (const Buffer& src, samplecnt_t len, sampleoffset_t dst_offset = 0, sampleoffset_t src_offset = 0) = 0;
79 
80  protected:
82  : _type(type), _capacity(0), _silent (true)
83  {}
84 
87  bool _silent;
88 };
89 
90 
91 } // namespace ARDOUR
92 
DataType _type
Definition: buffer.h:85
virtual void merge_from(const Buffer &src, samplecnt_t len, sampleoffset_t dst_offset=0, sampleoffset_t src_offset=0)=0
virtual ~Buffer()
Definition: buffer.h:47
virtual void clear()
Definition: buffer.h:75
Buffer(DataType type)
Definition: buffer.h:81
pframes_t _capacity
Definition: buffer.h:86
bool _silent
Definition: buffer.h:87
static Buffer * create(DataType type, size_t capacity)
virtual bool silent_data() const =0
DataType type() const
Definition: buffer.h:57
Buffer(const Buffer &)=delete
bool silent() const
Definition: buffer.h:59
virtual void silence(samplecnt_t len, samplecnt_t offset=0)=0
virtual void resize(size_t)=0
virtual void read_from(const Buffer &src, samplecnt_t len, sampleoffset_t dst_offset=0, sampleoffset_t src_offset=0)=0
size_t capacity() const
Definition: buffer.h:53
#define LIBARDOUR_API
uint32_t pframes_t
Temporal::samplecnt_t samplecnt_t
Temporal::sampleoffset_t sampleoffset_t