@@ -33,18 +33,18 @@ class AudioBus
33
33
// allocate indicates whether or not to initially have the AudioChannels created with managed storage.
34
34
// Normal usage is to pass true here, in which case the AudioChannels will memory-manage their own storage.
35
35
// If allocate is false then setChannelMemory() has to be called later on for each channel before the AudioBus is useable...
36
- AudioBus (size_t numberOfChannels, size_t length, bool allocate = true );
36
+ AudioBus (int numberOfChannels, int length, bool allocate = true );
37
37
38
38
// Tells the given channel to use an externally allocated buffer.
39
- void setChannelMemory (size_t channelIndex, float * storage, size_t length);
39
+ void setChannelMemory (int channelIndex, float * storage, int length);
40
40
41
41
// Channels
42
- size_t numberOfChannels () const { return m_channels.size (); }
42
+ int numberOfChannels () const { return static_cast < int >( m_channels.size () ); }
43
43
44
44
// Use this when looping over channels
45
- AudioChannel * channel (size_t channel) { return m_channels[channel].get (); }
45
+ AudioChannel * channel (int channel) { return m_channels[channel].get (); }
46
46
47
- const AudioChannel * channel (size_t channel) const
47
+ const AudioChannel * channel (int channel) const
48
48
{
49
49
return const_cast <AudioBus *>(this )->m_channels [channel].get ();
50
50
}
@@ -54,11 +54,11 @@ class AudioBus
54
54
const AudioChannel * channelByType (Channel type) const ;
55
55
56
56
// Number of sample-frames
57
- size_t length () const { return m_length; }
57
+ int length () const { return m_length; }
58
58
59
59
// resizeSmaller() can only be called with a new length <= the current length.
60
60
// The data stored in the bus will remain undisturbed.
61
- void resizeSmaller (size_t newLength);
61
+ void resizeSmaller (int newLength);
62
62
63
63
// Sample-rate : 0.0 if unknown or "don't care"
64
64
float sampleRate () const { return m_sampleRate; }
@@ -76,21 +76,6 @@ class AudioBus
76
76
// Returns true if the channel count and frame-size match.
77
77
bool topologyMatches (const AudioBus & sourceBus) const ;
78
78
79
- // Creates a new buffer from a range in the source buffer.
80
- // 0 may be returned if the range does not fit in the sourceBuffer
81
- static std::unique_ptr<AudioBus> createBufferFromRange (const AudioBus * sourceBus, size_t startFrame, size_t endFrame);
82
-
83
- // Creates a new AudioBus by sample-rate converting sourceBus to the newSampleRate.
84
- // setSampleRate() must have been previously called on sourceBus.
85
- static std::unique_ptr<AudioBus> createBySampleRateConverting (const AudioBus * sourceBus, bool mixToMono, float newSampleRate);
86
-
87
- // Creates a new AudioBus by mixing all the channels down to mono.
88
- // If sourceBus is already mono, then the returned AudioBus will simply be a copy.
89
- static std::unique_ptr<AudioBus> createByMixingToMono (const AudioBus * sourceBus);
90
-
91
- // Creates a new AudioBus by cloning an existing one
92
- static std::unique_ptr<AudioBus> createByCloning (const AudioBus * sourceBus);
93
-
94
79
// Scales all samples by the same amount.
95
80
void scale (float scale);
96
81
@@ -110,7 +95,7 @@ class AudioBus
110
95
void copyWithGainFrom (const AudioBus & sourceBus, float * lastMixGain, float targetGain);
111
96
112
97
// Copies the sourceBus by scaling with sample-accurate gain values.
113
- void copyWithSampleAccurateGainValuesFrom (const AudioBus & sourceBus, float * gainValues, size_t numberOfGainValues);
98
+ void copyWithSampleAccurateGainValuesFrom (const AudioBus & sourceBus, float * gainValues, int numberOfGainValues);
114
99
115
100
// Returns maximum absolute value across all channels (useful for normalization).
116
101
float maxAbsValue () const ;
@@ -120,7 +105,25 @@ class AudioBus
120
105
121
106
bool isFirstTime () { return m_isFirstTime; }
122
107
108
+ // Static Functions
109
+
110
+ // Creates a new buffer from a range in the source buffer.
111
+ // 0 may be returned if the range does not fit in the sourceBuffer
112
+ static std::unique_ptr<AudioBus> createBufferFromRange (const AudioBus * sourceBus, int startFrame, int endFrame);
113
+
114
+ // Creates a new AudioBus by sample-rate converting sourceBus to the newSampleRate.
115
+ // setSampleRate() must have been previously called on sourceBus.
116
+ static std::unique_ptr<AudioBus> createBySampleRateConverting (const AudioBus * sourceBus, bool mixToMono, float newSampleRate);
117
+
118
+ // Creates a new AudioBus by mixing all the channels down to mono.
119
+ // If sourceBus is already mono, then the returned AudioBus will simply be a copy.
120
+ static std::unique_ptr<AudioBus> createByMixingToMono (const AudioBus * sourceBus);
121
+
122
+ // Creates a new AudioBus by cloning an existing one
123
+ static std::unique_ptr<AudioBus> createByCloning (const AudioBus * sourceBus);
124
+
123
125
protected:
126
+
124
127
AudioBus () = default ;
125
128
126
129
void speakersCopyFrom (const AudioBus &);
@@ -130,18 +133,14 @@ class AudioBus
130
133
void speakersSumFrom5_1_ToMono (const AudioBus &);
131
134
void speakersSumFrom7_1_ToMono (const AudioBus &);
132
135
133
- size_t m_length = 0 ;
134
-
135
- std::vector<std::unique_ptr<AudioChannel>> m_channels;
136
-
137
- int m_layout = LayoutCanonical;
138
-
139
- float m_busGain = 1 .0f ;
140
-
141
136
std::unique_ptr<AudioFloatArray> m_dezipperGainValues;
137
+ std::vector<std::unique_ptr<AudioChannel>> m_channels;
142
138
143
139
bool m_isFirstTime = true ;
144
140
float m_sampleRate = 0 .0f ;
141
+ float m_busGain = 1 .0f ;
142
+ int m_layout = LayoutCanonical;
143
+ int m_length = 0 ;
145
144
};
146
145
147
146
} // lab
0 commit comments