An AudioBus represents a collection of one or more AudioChannels. The data layout is "planar" as opposed to "interleaved". An AudioBus with one channel is mono, an AudioBus with two channels is stereo, etc.
| 20 | // The data layout is "planar" as opposed to "interleaved". |
| 21 | // An AudioBus with one channel is mono, an AudioBus with two channels is stereo, etc. |
| 22 | class AudioBus |
| 23 | { |
| 24 | AudioBus(const AudioBus &); // noncopyable |
| 25 | |
| 26 | public: |
| 27 | // Can define non-standard layouts here: |
| 28 | enum |
| 29 | { |
| 30 | LayoutCanonical = 0 |
| 31 | }; |
| 32 | |
| 33 | // allocate indicates whether or not to initially have the AudioChannels created with managed storage. |
| 34 | // Normal usage is to pass true here, in which case the AudioChannels will memory-manage their own storage. |
| 35 | // If allocate is false then setChannelMemory() has to be called later on for each channel before the AudioBus is useable... |
| 36 | AudioBus(int numberOfChannels, int length, bool allocate = true); |
| 37 | |
| 38 | // Tells the given channel to use an externally allocated buffer. |
| 39 | void setChannelMemory(int channelIndex, float * storage, int length); |
| 40 | |
| 41 | // Channels |
| 42 | int numberOfChannels() const { return static_cast<int>(m_channels.size()); } |
| 43 | |
| 44 | // Use this when looping over channels |
| 45 | AudioChannel * channel(int channel) { return m_channels[channel].get(); } |
| 46 | |
| 47 | const AudioChannel * channel(int channel) const |
| 48 | { |
| 49 | return const_cast<AudioBus *>(this)->m_channels[channel].get(); |
| 50 | } |
| 51 | |
| 52 | // use this when accessing channels semantically |
| 53 | AudioChannel * channelByType(Channel type); |
| 54 | const AudioChannel * channelByType(Channel type) const; |
| 55 | |
| 56 | // Number of sample-frames |
| 57 | int length() const { return m_length; } |
| 58 | |
| 59 | // resizeSmaller() can only be called with a new length <= the current length. |
| 60 | // The data stored in the bus will remain undisturbed. |
| 61 | void resizeSmaller(int newLength); |
| 62 | |
| 63 | // Sample-rate : 0.0 if unknown or "don't care" |
| 64 | float sampleRate() const { return m_sampleRate; } |
| 65 | void setSampleRate(float sampleRate) { m_sampleRate = sampleRate; } |
| 66 | |
| 67 | // Zeroes all channels. |
| 68 | void zero(); |
| 69 | |
| 70 | // Clears the silent flag on all channels. |
| 71 | void clearSilentFlag(); |
| 72 | |
| 73 | // Returns true if the silent bit is set on all channels. |
| 74 | bool isSilent() const; |
| 75 | |
| 76 | // Returns true if all channels hold zeros. |
| 77 | // meant for debugging as it scans the data. |
| 78 | bool isZero() const; |
| 79 |
nothing calls this directly
no outgoing calls
no test coverage detected