Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Edited README.md via GitHub

  • Loading branch information...
commit ba1251955cd28d4920cc3d19a9df22bb29ac86a5 1 parent 1b28c9d
@mhroth authored
Showing with 56 additions and 1 deletion.
  1. +56 −1 README.md
View
57 README.md
@@ -312,7 +312,62 @@ void MessageAdd::processMessage(int inletIndex, PdMessage *message) {
#### A DspObject External
-*TODO!*
+Here, a basic `[+~]` object is described. The `DspObject` class is extended in [DspAdd.h](https://github.com/mhroth/ZenGarden/blob/master/src/DspAdd.h), and the `processDspWithIndex` function is overridden in addition to `processMessage` seen in the previous example. Receiving messages and evaluating which parts of the audio buffer must be evalutated when is taken care of by the `DspObject` superclass. The implementation is responsible for actually filling in the buffer.
+
+```C++
+#include "DspObject.h"
+
+/** [+~], [+~ float] */
+class DspAdd : public DspObject {
+
+ public:
+ DspAdd(PdMessage *initMessage, PdGraph *graph);
+ ~DspAdd();
+
+ static const char *getObjectLabel();
+
+ private:
+ void processMessage(int inletIndex, PdMessage *message);
+ void processDspWithIndex(int fromIndex, int toIndex);
+
+ float constant;
+};
+```
+
+[DspAdd.cpp](https://github.com/mhroth/ZenGarden/blob/master/src/DspAdd.cpp)
+
+*TODO BELOW CODE NOT CORRECT*
+
+```C++
+#include "DspAdd.h"
+#include "PdGraph.h"
+
+DspAdd::DspAdd(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 2, 0, 1, graph) {
+ constant = initMessage->isFloat(0) ? initMessage->getFloat(0) : 0.0f;
+}
+
+DspAdd::~DspAdd() {
+ // nothing to do
+}
+
+const char *DspAdd::getObjectLabel() {
+ return "+~";
+}
+
+void DspAdd::processMessage(int inletIndex, PdMessage *message) {
+ if (inletIndex == 1) {
+ if (message->isFloat(0)) {
+ constant = message->getFloat(0);
+ }
+ }
+}
+
+void DspAdd::processDspWithIndex(int fromIndex, int toIndex) {
+ for (int i = fromIndex; i < toIndex; i++) {
+ dspBufferAtOutlet0[i] = dspBufferAtInlet0[i] + constant;
+ }
+}
+```
### Registering an External
Please sign in to comment.
Something went wrong with that request. Please try again.