An AudioChannel represents a buffer of non-interleaved floating-point audio samples. The PCM samples are normally assumed to be in a nominal range -1.0 -> +1.0
| 15 | // An AudioChannel represents a buffer of non-interleaved floating-point audio samples. |
| 16 | // The PCM samples are normally assumed to be in a nominal range -1.0 -> +1.0 |
| 17 | class AudioChannel |
| 18 | { |
| 19 | AudioChannel(const AudioChannel &); // noncopyable |
| 20 | |
| 21 | public: |
| 22 | // Memory can be externally referenced, or can be internally allocated with an AudioFloatArray. |
| 23 | |
| 24 | // Reference an external buffer. |
| 25 | AudioChannel(float * storage, int length) |
| 26 | : m_length(length) |
| 27 | , m_rawPointer(storage) |
| 28 | , m_silent(false) |
| 29 | { |
| 30 | } |
| 31 | |
| 32 | // Manage storage for us. |
| 33 | explicit AudioChannel(int length) |
| 34 | : m_length(length) |
| 35 | , m_silent(true) |
| 36 | { |
| 37 | m_memBuffer.reset(new AudioFloatArray(length)); |
| 38 | } |
| 39 | |
| 40 | // An empty audio channel -- must call set() before it's useful... |
| 41 | AudioChannel() |
| 42 | : m_length(0) |
| 43 | , m_silent(true) |
| 44 | { |
| 45 | } |
| 46 | |
| 47 | // Redefine the memory for this channel. |
| 48 | // storage represents external memory not managed by this object. |
| 49 | void set(float * storage, int length) |
| 50 | { |
| 51 | m_memBuffer.reset(); // clean up managed storage |
| 52 | m_rawPointer = storage; |
| 53 | m_length = length; |
| 54 | m_silent = false; |
| 55 | } |
| 56 | |
| 57 | // How many sample-frames do we contain? |
| 58 | int length() const { return m_length; } |
| 59 | |
| 60 | // resizeSmaller() can only be called with a new length <= the current length. |
| 61 | // The data stored in the bus will remain undisturbed. |
| 62 | void resizeSmaller(int newLength); |
| 63 | |
| 64 | // Direct access to PCM sample data. Non-const accessor clears silent flag. |
| 65 | float * mutableData() |
| 66 | { |
| 67 | clearSilentFlag(); |
| 68 | return const_cast<float *>(data()); |
| 69 | } |
| 70 | |
| 71 | const float * data() const |
| 72 | { |
| 73 | if (m_rawPointer) |
| 74 | return m_rawPointer; |
nothing calls this directly
no outgoing calls
no test coverage detected