Showing the changes to Spectacle/genlib/Obucket.cpp (1 of 32 files). Show all
Unified · Split
| @@ -0,0 +1,33 @@ | |||
| 1 | // RTcmix - Copyright (C) 2005 The RTcmix Development Team | ||
| 2 | // See ``AUTHORS'' for a list of contributors. See ``LICENSE'' for | ||
| 3 | // the license to this software and for a DISCLAIMER OF ALL WARRANTIES. | ||
| 4 | |||
| 5 | #include "Obucket.h" | ||
| 6 | |||
| 7 | Obucket::Obucket(int len, ProcessFunction callback, void *context) | ||
| 8 | : _len(len), _index(0), _callback(callback), _context(context) | ||
| 9 | { | ||
| 10 | _buf = new float [len]; | ||
| 11 | } | ||
| 12 | |||
| 13 | Obucket::~Obucket() | ||
| 14 | { | ||
| 15 | delete [] _buf; | ||
| 16 | } | ||
| 17 | |||
| 18 | void Obucket::flush(float defaultval) | ||
| 19 | { | ||
| 20 | if (_index > 0) { | ||
| 21 | for (int i = _index; i < _len; i++) | ||
| 22 | _buf[i] = defaultval; | ||
| 23 | (*_callback)(_buf, _len, _context); | ||
| 24 | _index = 0; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | void Obucket::clear(float defaultval) | ||
| 29 | { | ||
| 30 | for (int i = 0; i < _len; i++) | ||
| 31 | _buf[i] = defaultval; | ||
| 32 | } | ||
| 33 | |||