/* -------------------------------------------------------------------------- */
+void AudioBuffer::forEachFrame(std::function<void(float*, int)> f)
+{
+ for (int i = 0; i < countFrames(); i++)
+ f((*this)[i], i);
+}
+
+/* -------------------------------------------------------------------------- */
+
+void AudioBuffer::forEachChannel(int frame, std::function<void(float&, int)> f)
+{
+ assert(frame < m_size);
+
+ for (int i = 0; i < countChannels(); i++)
+ f((*this)[frame][i], i);
+}
+
+/* -------------------------------------------------------------------------- */
+
+void AudioBuffer::forEachSample(std::function<void(float&, int)> f)
+{
+ for (int i = 0; i < countSamples(); i++)
+ f(m_data[i], i);
+}
+
+/* -------------------------------------------------------------------------- */
+
template void AudioBuffer::copyData<AudioBuffer::Operation::SUM>(const AudioBuffer&, int, int, int, float, Pan);
template void AudioBuffer::copyData<AudioBuffer::Operation::SET>(const AudioBuffer&, int, int, int, float, Pan);
-} // namespace mcl
\ No newline at end of file
+} // namespace mcl
#define MONOCASUAL_AUDIO_BUFFER_H
#include <array>
+#include <functional>
namespace mcl
{
void applyGain(float g);
+ /* forEachFrame
+ Applies a function to each frame in the audio buffer. */
+
+ void forEachFrame(std::function<void(float* /*channels*/, int /*numFrame*/)>);
+
+ /* forEachChannel
+ Applies a function to each channel in the given frame. */
+
+ void forEachChannel(int frame, std::function<void(float& /*value*/, int /*numChannel*/)>);
+
+ /* forEachSample
+ Applies a function to each sample in the audio buffer. */
+
+ void forEachSample(std::function<void(float& /*value*/, int /*numSample*/)>);
+
private:
enum class Operation
{
};
} // namespace mcl
-#endif
\ No newline at end of file
+#endif