Ardour  9.0-pre0-582-g084a23a80d
fixed_delay.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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 #pragma once
20 
21 #include <vector>
22 #include "ardour/buffer.h"
23 
24 namespace ARDOUR {
25 
26 class ChanCount;
27 
44 {
45 public:
48 
55  void configure (const ChanCount& count, samplecnt_t max_delay, bool shrink = true);
56 
65  void set (const ChanCount& count, samplecnt_t delay);
66 
80  void delay (ARDOUR::DataType dt, uint32_t id, Buffer& out, const Buffer& in, pframes_t n_samples, samplecnt_t dst_offset = 0, samplecnt_t src_offset = 0);
81 
83  void flush();
84 
86  samplecnt_t delay () const { return _delay; }
87 
88 private:
93 
94  struct DelayBuffer {
95  public:
96  DelayBuffer () : buf (0), pos (0) {}
97  DelayBuffer (DataType dt, size_t capacity)
98  : buf (Buffer::create (dt, capacity)), pos (0) {}
99  ~DelayBuffer () { delete buf; }
102  };
103 
104  typedef std::vector<DelayBuffer*> BufferVec;
105  // Vector of vectors, indexed by DataType
106  std::vector<BufferVec> _buffers;
107 
108  void ensure_buffers(DataType type, size_t num_buffers, size_t buffer_capacity);
109  void clear ();
110 };
111 
112 } // namespace ARDOUR
113 
void set(const ChanCount &count, samplecnt_t delay)
samplecnt_t _buf_size
Definition: fixed_delay.h:90
void ensure_buffers(DataType type, size_t num_buffers, size_t buffer_capacity)
samplecnt_t _max_delay
Definition: fixed_delay.h:89
samplecnt_t _delay
Definition: fixed_delay.h:91
ChanCount _count
Definition: fixed_delay.h:92
std::vector< BufferVec > _buffers
Definition: fixed_delay.h:106
samplecnt_t delay() const
Definition: fixed_delay.h:86
void delay(ARDOUR::DataType dt, uint32_t id, Buffer &out, const Buffer &in, pframes_t n_samples, samplecnt_t dst_offset=0, samplecnt_t src_offset=0)
std::vector< DelayBuffer * > BufferVec
Definition: fixed_delay.h:104
void configure(const ChanCount &count, samplecnt_t max_delay, bool shrink=true)
#define LIBARDOUR_API
uint32_t pframes_t
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
DelayBuffer(DataType dt, size_t capacity)
Definition: fixed_delay.h:97