OboeTester: remove FifoProcessor, add docs
Add more class descriptions.
diff --git a/apps/OboeTester/app/src/main/cpp/FifoProcessor.cpp b/apps/OboeTester/app/src/main/cpp/FifoProcessor.cpp
deleted file mode 100644
index f7478bf..0000000
--- a/apps/OboeTester/app/src/main/cpp/FifoProcessor.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "FifoProcessor.h"
-
-
-FifoProcessor::FifoProcessor(int channelCount, int numFrames, int threshold)
- : mFifoBuffer(channelCount, numFrames)
- , output(*this, channelCount)
-{
- mFifoBuffer.setThresholdFrames(threshold);
-}
-
-FifoProcessor::~FifoProcessor() {
-}
diff --git a/apps/OboeTester/app/src/main/cpp/FifoProcessor.h b/apps/OboeTester/app/src/main/cpp/FifoProcessor.h
deleted file mode 100644
index 8db8c4e..0000000
--- a/apps/OboeTester/app/src/main/cpp/FifoProcessor.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef NATIVEOBOE_FIFIPROCESSOR_H
-#define NATIVEOBOE_FIFIPROCESSOR_H
-
-#include "flowgraph/AudioProcessorBase.h"
-#include "fifo/FifoBuffer.h"
-
-class FifoProcessor : public flowgraph::AudioProcessorBase {
-public:
- FifoProcessor(int samplesPerFrame, int numFrames, int threshold);
-
- virtual ~FifoProcessor();
-
- uint32_t read(float *destination, int framesToRead) {
- return mFifoBuffer.read(destination, framesToRead);
- }
-
- uint32_t write(const float *source, int framesToWrite) {
- return mFifoBuffer.write(source, framesToWrite);
- }
-
- uint32_t getThresholdFrames() {
- return mFifoBuffer.getThresholdFrames();
- }
-
- void setThresholdFrames(uint32_t threshold) {
- return mFifoBuffer.setThresholdFrames(threshold);
- }
-
- int32_t onProcess(
- int64_t framePosition,
- int numFrames) override {
- float *buffer = output.getBlock();
- return mFifoBuffer.readNow(buffer, numFrames);
- }
-
- uint32_t getUnderrunCount() const { return mFifoBuffer.getUnderrunCount(); }
-
-private:
- oboe::FifoBuffer mFifoBuffer;
-
-public:
- flowgraph::AudioFloatOutputPort output;
-
-};
-
-
-#endif //NATIVEOBOE_FIFIPROCESSOR_H
diff --git a/apps/OboeTester/app/src/main/cpp/flowgraph/AudioProcessorBase.h b/apps/OboeTester/app/src/main/cpp/flowgraph/AudioProcessorBase.h
index d0e6a0f..3c5fe4d 100644
--- a/apps/OboeTester/app/src/main/cpp/flowgraph/AudioProcessorBase.h
+++ b/apps/OboeTester/app/src/main/cpp/flowgraph/AudioProcessorBase.h
@@ -83,6 +83,10 @@
/***************************************************************************/
/**
* This is a connector that allows data to flow between modules.
+ *
+ * The ports are the primary means of interacting with a module.
+ * So they are generally declared as public.
+ *
*/
class AudioPort {
public:
diff --git a/apps/OboeTester/app/src/main/cpp/flowgraph/OscillatorBase.h b/apps/OboeTester/app/src/main/cpp/flowgraph/OscillatorBase.h
index b336967..b3144bb 100644
--- a/apps/OboeTester/app/src/main/cpp/flowgraph/OscillatorBase.h
+++ b/apps/OboeTester/app/src/main/cpp/flowgraph/OscillatorBase.h
@@ -19,7 +19,15 @@
#include "AudioProcessorBase.h"
-constexpr float TWO_PI = (float)(2.0 * M_PI);
+/**
+ * Base class for various oscillators.
+ * The oscillator has a phase that ranges from -1.0 to +1.0.
+ * That makes it easier to implement simple algebraic waveforms.
+ *
+ * Subclasses must implement onProcess().
+ *
+ * This module has "frequency" and "amplitude" ports for control.
+ */
class OscillatorBase : public flowgraph::AudioProcessorBase {
public:
@@ -51,6 +59,13 @@
flowgraph::AudioFloatOutputPort output;
protected:
+ /**
+ * Increment phase based on frequency in Hz.
+ * Frequency may be positive or negative.
+ *
+ * Frequency should not exceed +/- Nyquist Rate.
+ * Nyquist Rate is sampleRate/2.
+ */
float incrementPhase(float frequency) {
mPhase += frequency * mFrequencyToPhaseIncrement;
// Wrap phase in the range of -1 to +1
@@ -64,7 +79,7 @@
float mPhase = 0.0; // phase that ranges from -1.0 to +1.0
float mSampleRate = 0.0f;
- float mFrequencyToPhaseIncrement = 0.0f; // Scaler for converting frequency to phase increment.
+ float mFrequencyToPhaseIncrement = 0.0f; // scaler for converting frequency to phase increment
};
diff --git a/apps/OboeTester/app/src/main/cpp/flowgraph/RampLinear.h b/apps/OboeTester/app/src/main/cpp/flowgraph/RampLinear.h
index bdc8f41..0d5ed10 100644
--- a/apps/OboeTester/app/src/main/cpp/flowgraph/RampLinear.h
+++ b/apps/OboeTester/app/src/main/cpp/flowgraph/RampLinear.h
@@ -25,6 +25,14 @@
namespace flowgraph {
+/**
+ * When the target is modified then the output will ramp smoothly
+ * between the original and the new target value.
+ * This can be used to smooth out control values and reduce pops.
+ *
+ * The target may be updated while a ramp is in progress, which will trigger
+ * a new ramp from the current value.
+ */
class RampLinear : public AudioProcessorBase {
public:
explicit RampLinear(int32_t channelCount);