To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / CollidoscopeApp / include / RingBufferPack.h @ 5:75b744078d66
History | View | Annotate | Download (1.56 KB)
| 1 | 5:75b744078d66 | f | /*
|
|---|---|---|---|
| 2 | |||
| 3 | Copyright (C) 2016 Queen Mary University of London
|
||
| 4 | Author: Fiore Martin
|
||
| 5 | |||
| 6 | This file is part of Collidoscope.
|
||
| 7 | |||
| 8 | Collidoscope is free software: you can redistribute it and/or modify
|
||
| 9 | it under the terms of the GNU General Public License as published by
|
||
| 10 | the Free Software Foundation, either version 3 of the License, or
|
||
| 11 | (at your option) any later version.
|
||
| 12 | |||
| 13 | This program is distributed in the hope that it will be useful,
|
||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
| 16 | GNU General Public License for more details.
|
||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License
|
||
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
| 20 | */
|
||
| 21 | |||
| 22 | 0:02467299402e | f | #pragma once
|
| 23 | |||
| 24 | #include "cinder/audio/dsp/RingBuffer.h" |
||
| 25 | |||
| 26 | |||
| 27 | 3:7fb593d53361 | f | /** Packs together a cinder::audio::dsp::RingBuffer and the related array used passed as argument to exchange data (read/write) with the ring buffer */
|
| 28 | 0:02467299402e | f | template <typename T> |
| 29 | class RingBufferPack {
|
||
| 30 | |||
| 31 | public:
|
||
| 32 | |||
| 33 | RingBufferPack( size_t size ) : |
||
| 34 | mSize( size ), |
||
| 35 | mBuffer( size ) |
||
| 36 | {
|
||
| 37 | mArray = new T[size]; |
||
| 38 | } |
||
| 39 | |||
| 40 | ~RingBufferPack() |
||
| 41 | {
|
||
| 42 | delete[] mArray; |
||
| 43 | } |
||
| 44 | |||
| 45 | // no copy
|
||
| 46 | RingBufferPack( const RingBufferPack © ) = delete;
|
||
| 47 | RingBufferPack & operator=(const RingBufferPack ©) = delete;
|
||
| 48 | |||
| 49 | ci::audio::dsp::RingBufferT<T> & getBuffer() { return mBuffer; }
|
||
| 50 | |||
| 51 | T* getExchangeArray() { return mArray; }
|
||
| 52 | |||
| 53 | std::size_t getSize() { return mSize; }
|
||
| 54 | |||
| 55 | private:
|
||
| 56 | size_t mSize; |
||
| 57 | |||
| 58 | ci::audio::dsp::RingBufferT<T> mBuffer; |
||
| 59 | |||
| 60 | T* mArray; |
||
| 61 | |||
| 62 | |||
| 63 | 3:7fb593d53361 | f | }; |