1
// ------------------------------------------------------------------------
3
// Copyright (C) 2011-2012 Fons Adriaensen <fons@linuxaudio.org>
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 3 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program. If not, see <http://www.gnu.org/licenses/>.
18
// ------------------------------------------------------------------------
30
// maxdel = maximum delay in samples.
31
// period = number of samples guaranteed to be available for
32
// linear reading or writing, i.e. without wraparound.
36
// * Read or write up to 'period' samples.
37
// * Commit number of samples used.
43
Delayproc (int maxdel, int period);
49
// Delay must be in the range 0...'maxdel'.
50
void set_delay (int k)
53
if (_rdind < 0) _rdind += _length;
56
// Get write or read pointer. Either can be used as
57
// the base of an array of size 'period' samples.
58
float *wr_ptr (void) const { return _data + _wrind; }
59
float *rd_ptr (void) const { return _data + _rdind; }
61
// Commit writing of k samples.
62
void wr_commit (int k)
67
// This ensures that the first and last period sized
68
// blocks remain identical, allowing linear access
69
// for both reading and writing.
80
memcpy (p, q, n * sizeof (float));
92
memcpy (p, q, n * sizeof (float));
97
// Commit reading of k samples.
98
void rd_commit (int k)
101
if (_rdind >= _length) _rdind -= _length;