Skip to content
Browse files

Merge branch 'newPdParser'

  • Loading branch information...
2 parents 0671082 + 4196bf7 commit 63786a0663c25a86954997a3f74d9c42f41bf990 @mhroth committed Sep 12, 2011
Showing with 1,508 additions and 885 deletions.
  1. +1 −0 .gitignore
  2. +14 −0 Xcode/ZenGarden.xcodeproj/project.pbxproj
  3. +4 −0 src/DspAdc.cpp
  4. +2 −1 src/DspAdc.h
  5. +4 −1 src/DspAdd.cpp
  6. +2 −1 src/DspAdd.h
  7. +4 −2 src/DspBandpassFilter.cpp
  8. +2 −1 src/DspBandpassFilter.h
  9. +4 −0 src/DspBang.cpp
  10. +2 −1 src/DspBang.h
  11. +4 −0 src/DspCatch.cpp
  12. +2 −1 src/DspCatch.h
  13. +10 −29 src/DspClip.cpp
  14. +2 −1 src/DspClip.h
  15. +4 −0 src/DspCosine.cpp
  16. +2 −1 src/DspCosine.h
  17. +10 −5 src/DspDac.cpp
  18. +3 −3 src/DspDac.h
  19. +4 −1 src/DspDelayRead.cpp
  20. +2 −1 src/DspDelayRead.h
  21. +4 −0 src/DspDelayWrite.cpp
  22. +2 −1 src/DspDelayWrite.h
  23. +4 −1 src/DspDivide.cpp
  24. +2 −1 src/DspDivide.h
  25. +4 −0 src/DspEnvelope.cpp
  26. +3 −1 src/DspEnvelope.h
  27. +5 −3 src/DspHighpassFilter.cpp
  28. +2 −1 src/DspHighpassFilter.h
  29. +5 −1 src/DspInlet.cpp
  30. +2 −1 src/DspInlet.h
  31. +5 −3 src/DspLine.cpp
  32. +3 −2 src/DspLine.h
  33. +4 −1 src/DspLog.cpp
  34. +2 −1 src/DspLog.h
  35. +4 −3 src/DspLowpassFilter.cpp
  36. +2 −1 src/DspLowpassFilter.h
  37. +4 −1 src/DspMinimum.cpp
  38. +2 −1 src/DspMinimum.h
  39. +4 −2 src/DspMultiply.cpp
  40. +2 −1 src/DspMultiply.h
  41. +4 −0 src/DspNoise.cpp
  42. +2 −1 src/DspNoise.h
  43. +3 −1 src/DspObject.cpp
  44. +6 −0 src/DspObject.h
  45. +4 −1 src/DspOsc.cpp
  46. +2 −1 src/DspOsc.h
  47. +5 −1 src/DspOutlet.cpp
  48. +2 −1 src/DspOutlet.h
  49. +4 −1 src/DspPhasor.cpp
  50. +2 −1 src/DspPhasor.h
  51. +4 −0 src/DspPrint.cpp
  52. +2 −1 src/DspPrint.h
  53. +4 −0 src/DspReceive.cpp
  54. +2 −1 src/DspReceive.h
  55. +4 −0 src/DspReciprocalSqrt.cpp
  56. +2 −1 src/DspReciprocalSqrt.h
  57. +4 −0 src/DspRfft.cpp
  58. +2 −1 src/DspRfft.h
  59. +4 −0 src/DspRifft.cpp
  60. +2 −1 src/DspRifft.h
  61. +4 −0 src/DspSend.cpp
  62. +2 −1 src/DspSend.h
  63. +4 −1 src/DspSignal.cpp
  64. +6 −5 src/DspSignal.h
  65. +4 −0 src/DspSnapshot.cpp
  66. +2 −1 src/DspSnapshot.h
  67. +4 −0 src/DspSqrt.cpp
  68. +2 −1 src/DspSqrt.h
  69. +4 −1 src/DspSubtract.cpp
  70. +2 −1 src/DspSubtract.h
  71. +4 −3 src/DspTablePlay.cpp
  72. +2 −1 src/DspTablePlay.h
  73. +4 −1 src/DspTableRead.cpp
  74. +2 −1 src/DspTableRead.h
  75. +4 −1 src/DspTableRead4.cpp
  76. +2 −1 src/DspTableRead4.h
  77. +4 −0 src/DspThrow.cpp
  78. +2 −1 src/DspThrow.h
  79. +4 −1 src/DspVCF.cpp
  80. +2 −1 src/DspVCF.h
  81. +4 −0 src/DspVariableDelay.cpp
  82. +2 −1 src/DspVariableDelay.h
  83. +4 −0 src/DspWrap.cpp
  84. +2 −1 src/DspWrap.h
  85. +1 −0 src/Makefile.sourcefiles
  86. +4 −0 src/MessageAbsoluteValue.cpp
  87. +2 −1 src/MessageAbsoluteValue.h
  88. +4 −0 src/MessageAdd.cpp
  89. +2 −1 src/MessageAdd.h
  90. +4 −0 src/MessageArcTangent.cpp
  91. +2 −1 src/MessageArcTangent.h
  92. +4 −0 src/MessageArcTangent2.cpp
  93. +2 −1 src/MessageArcTangent2.h
  94. +4 −0 src/MessageBang.cpp
  95. +2 −1 src/MessageBang.h
  96. +4 −0 src/MessageChange.cpp
  97. +2 −1 src/MessageChange.h
  98. +4 −0 src/MessageClip.cpp
  99. +2 −1 src/MessageClip.h
  100. +4 −0 src/MessageCosine.cpp
  101. +2 −1 src/MessageCosine.h
  102. +4 −0 src/MessageCputime.cpp
  103. +2 −1 src/MessageCputime.h
  104. +4 −0 src/MessageDbToPow.cpp
  105. +2 −1 src/MessageDbToPow.h
  106. +4 −0 src/MessageDbToRms.cpp
  107. +2 −1 src/MessageDbToRms.h
  108. +4 −0 src/MessageDeclare.cpp
  109. +2 −1 src/MessageDeclare.h
  110. +4 −0 src/MessageDelay.cpp
  111. +2 −1 src/MessageDelay.h
  112. +4 −0 src/MessageDivide.cpp
  113. +2 −1 src/MessageDivide.h
  114. +5 −1 src/MessageEqualsEquals.cpp
  115. +2 −1 src/MessageEqualsEquals.h
  116. +4 −0 src/MessageExp.cpp
  117. +2 −1 src/MessageExp.h
  118. +4 −0 src/MessageFloat.cpp
  119. +2 −1 src/MessageFloat.h
  120. +4 −0 src/MessageFrequencyToMidi.cpp
  121. +2 −1 src/MessageFrequencyToMidi.h
  122. +4 −0 src/MessageGreaterThan.cpp
  123. +2 −1 src/MessageGreaterThan.h
  124. +4 −0 src/MessageGreaterThanOrEqualTo.cpp
  125. +2 −1 src/MessageGreaterThanOrEqualTo.h
  126. +5 −1 src/MessageInlet.cpp
  127. +2 −1 src/MessageInlet.h
  128. +4 −0 src/MessageInteger.cpp
  129. +2 −1 src/MessageInteger.h
  130. +4 −0 src/MessageLessThan.cpp
  131. +2 −1 src/MessageLessThan.h
  132. +4 −0 src/MessageLessThanOrEqualTo.cpp
  133. +2 −1 src/MessageLessThanOrEqualTo.h
  134. +4 −0 src/MessageLine.cpp
  135. +2 −1 src/MessageLine.h
  136. +36 −0 src/MessageListAppend.cpp
  137. +2 −1 src/MessageListAppend.h
  138. +1 −1 src/MessageListLength.h
  139. +1 −1 src/MessageListPrepend.h
  140. +1 −1 src/MessageListSplit.h
  141. +1 −1 src/MessageListTrim.h
  142. +4 −0 src/MessageLoadbang.cpp
  143. +2 −1 src/MessageLoadbang.h
  144. +4 −0 src/MessageLog.cpp
  145. +2 −1 src/MessageLog.h
  146. +4 −0 src/MessageLogicalAnd.cpp
  147. +2 −1 src/MessageLogicalAnd.h
  148. +4 −0 src/MessageLogicalOr.cpp
  149. +2 −1 src/MessageLogicalOr.h
  150. +4 −0 src/MessageMaximum.cpp
  151. +2 −1 src/MessageMaximum.h
  152. +4 −0 src/MessageMessageBox.cpp
  153. +2 −1 src/MessageMessageBox.h
  154. +4 −0 src/MessageMetro.cpp
  155. +2 −1 src/MessageMetro.h
  156. +5 −1 src/MessageMidiToFrequency.cpp
  157. +3 −2 src/MessageMidiToFrequency.h
  158. +4 −0 src/MessageMinimum.cpp
  159. +2 −1 src/MessageMinimum.h
  160. +4 −0 src/MessageModulus.cpp
  161. +2 −1 src/MessageModulus.h
  162. +4 −0 src/MessageMoses.cpp
  163. +2 −1 src/MessageMoses.h
  164. +4 −0 src/MessageMultiply.cpp
  165. +2 −1 src/MessageMultiply.h
  166. +4 −0 src/MessageNotEquals.cpp
  167. +2 −1 src/MessageNotEquals.h
  168. +4 −0 src/MessageNotein.cpp
  169. +2 −1 src/MessageNotein.h
  170. +1 −1 src/MessageObject.h
  171. +4 −0 src/MessageOpenPanel.cpp
  172. +2 −1 src/MessageOpenPanel.h
  173. +5 −1 src/MessageOutlet.cpp
  174. +3 −2 src/MessageOutlet.h
  175. +4 −0 src/MessagePack.cpp
  176. +2 −1 src/MessagePack.h
  177. +4 −0 src/MessagePipe.cpp
  178. +2 −1 src/MessagePipe.h
  179. +4 −0 src/MessagePow.cpp
  180. +2 −1 src/MessagePow.h
  181. +5 −1 src/MessagePowToDb.cpp
  182. +3 −2 src/MessagePowToDb.h
  183. +4 −0 src/MessagePrint.cpp
  184. +2 −1 src/MessagePrint.h
  185. +4 −0 src/MessageRandom.cpp
  186. +2 −1 src/MessageRandom.h
  187. +4 −0 src/MessageReceive.cpp
  188. +2 −1 src/MessageReceive.h
  189. +4 −0 src/MessageRemainder.cpp
  190. +2 −1 src/MessageRemainder.h
  191. +5 −1 src/MessageRmsToDb.cpp
  192. +3 −2 src/MessageRmsToDb.h
  193. +4 −0 src/MessageRoute.cpp
  194. +2 −1 src/MessageRoute.h
  195. +4 −0 src/MessageSamplerate.cpp
  196. +2 −1 src/MessageSamplerate.h
  197. +4 −0 src/MessageSelect.cpp
  198. +2 −1 src/MessageSelect.h
  199. +4 −0 src/MessageSend.cpp
  200. +2 −1 src/MessageSend.h
  201. +1 −1 src/MessageSendController.h
  202. +4 −0 src/MessageSine.cpp
  203. +2 −1 src/MessageSine.h
  204. +4 −0 src/MessageSoundfiler.cpp
  205. +2 −1 src/MessageSoundfiler.h
  206. +4 −0 src/MessageSpigot.cpp
  207. +2 −1 src/MessageSpigot.h
  208. +4 −0 src/MessageSqrt.cpp
  209. +2 −1 src/MessageSqrt.h
  210. +4 −0 src/MessageStripNote.cpp
  211. +2 −1 src/MessageStripNote.h
  212. +4 −0 src/MessageSubtract.cpp
  213. +2 −1 src/MessageSubtract.h
  214. +4 −0 src/MessageSwap.cpp
  215. +2 −1 src/MessageSwap.h
  216. +4 −0 src/MessageSwitch.cpp
  217. +2 −1 src/MessageSwitch.h
  218. +4 −0 src/MessageSymbol.cpp
  219. +2 −1 src/MessageSymbol.h
  220. +4 −0 src/MessageTable.cpp
  221. +2 −1 src/MessageTable.h
  222. +4 −0 src/MessageTableRead.cpp
  223. +2 −1 src/MessageTableRead.h
  224. +4 −0 src/MessageTableWrite.cpp
  225. +2 −1 src/MessageTableWrite.h
  226. +4 −0 src/MessageTangent.cpp
  227. +2 −1 src/MessageTangent.h
  228. +6 −2 src/MessageText.cpp
  229. +3 −2 src/MessageText.h
  230. +4 −0 src/MessageTimer.cpp
  231. +2 −1 src/MessageTimer.h
  232. +4 −0 src/MessageToggle.cpp
  233. +2 −1 src/MessageToggle.h
  234. +4 −0 src/MessageTrigger.cpp
  235. +2 −1 src/MessageTrigger.h
  236. +4 −0 src/MessageUnpack.cpp
  237. +2 −1 src/MessageUnpack.h
  238. +5 −1 src/MessageUntil.cpp
  239. +3 −2 src/MessageUntil.h
  240. +4 −0 src/MessageValue.cpp
  241. +2 −1 src/MessageValue.h
  242. +4 −0 src/MessageWrap.cpp
  243. +2 −1 src/MessageWrap.h
  244. +304 −0 src/ObjectFactoryMap.cpp
  245. +47 −0 src/ObjectFactoryMap.h
  246. +53 −605 src/PdContext.cpp
  247. +20 −12 src/PdContext.h
  248. +188 −5 src/PdFileParser.cpp
  249. +10 −3 src/PdFileParser.h
  250. +6 −6 src/PdGraph.cpp
  251. +1 −1 src/PdGraph.h
  252. +3 −7 src/PdMessage.cpp
  253. +1 −1 src/StaticUtils.cpp
  254. +1 −1 src/StaticUtils.h
  255. +8 −1 src/ZGCallbackFunction.h
  256. +37 −16 src/ZenGarden.cpp
  257. +20 −7 src/ZenGarden.h
  258. +7 −7 src/main.cpp
  259. +5 −4 src/me/rjdj/zengarden/zgcontext.cpp
View
1 .gitignore
@@ -16,3 +16,4 @@ Mersenne-1.1.zip
demo/
libs/
ZenGarden.jar
+src/main.cpp
View
14 Xcode/ZenGarden.xcodeproj/project.pbxproj
@@ -675,6 +675,11 @@
90EC947E120EDF2A00F65F49 /* MessageValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90EC947B120EDF2A00F65F49 /* MessageValue.cpp */; };
90EC947F120EDF2A00F65F49 /* MessageValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 90EC947A120EDF2A00F65F49 /* MessageValue.h */; };
90EC9480120EDF2A00F65F49 /* MessageValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90EC947B120EDF2A00F65F49 /* MessageValue.cpp */; };
+ 90F3D68813F82F5F0058E68D /* ObjectFactoryMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90F3D68713F82F5E0058E68D /* ObjectFactoryMap.cpp */; };
+ 90F3D68913F82F5F0058E68D /* ObjectFactoryMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90F3D68713F82F5E0058E68D /* ObjectFactoryMap.cpp */; };
+ 90F3D68A13F82F5F0058E68D /* ObjectFactoryMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90F3D68713F82F5E0058E68D /* ObjectFactoryMap.cpp */; };
+ 90F3D68C13F82F700058E68D /* ObjectFactoryMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 90F3D68B13F82F6E0058E68D /* ObjectFactoryMap.h */; };
+ 90F3D68D13F82F700058E68D /* ObjectFactoryMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 90F3D68B13F82F6E0058E68D /* ObjectFactoryMap.h */; };
90F4C18D12328AC1001182CF /* MessageLogicalAnd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90F4C18B12328AC1001182CF /* MessageLogicalAnd.cpp */; };
90F4C18E12328AC1001182CF /* MessageLogicalAnd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90F4C18B12328AC1001182CF /* MessageLogicalAnd.cpp */; };
90F4C18F12328AC1001182CF /* MessageLogicalAnd.h in Headers */ = {isa = PBXBuildFile; fileRef = 90F4C18C12328AC1001182CF /* MessageLogicalAnd.h */; };
@@ -983,6 +988,8 @@
90E90A041208EF8600A48B72 /* TableReceiverInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TableReceiverInterface.h; path = ../src/TableReceiverInterface.h; sourceTree = SOURCE_ROOT; };
90EC947A120EDF2A00F65F49 /* MessageValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MessageValue.h; path = ../src/MessageValue.h; sourceTree = SOURCE_ROOT; };
90EC947B120EDF2A00F65F49 /* MessageValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MessageValue.cpp; path = ../src/MessageValue.cpp; sourceTree = SOURCE_ROOT; };
+ 90F3D68713F82F5E0058E68D /* ObjectFactoryMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactoryMap.cpp; path = ../src/ObjectFactoryMap.cpp; sourceTree = "<group>"; };
+ 90F3D68B13F82F6E0058E68D /* ObjectFactoryMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactoryMap.h; path = ../src/ObjectFactoryMap.h; sourceTree = "<group>"; };
90F4C18B12328AC1001182CF /* MessageLogicalAnd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MessageLogicalAnd.cpp; path = ../src/MessageLogicalAnd.cpp; sourceTree = SOURCE_ROOT; };
90F4C18C12328AC1001182CF /* MessageLogicalAnd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MessageLogicalAnd.h; path = ../src/MessageLogicalAnd.h; sourceTree = SOURCE_ROOT; };
90F4C19812328CFC001182CF /* MessageLogicalOr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MessageLogicalOr.cpp; path = ../src/MessageLogicalOr.cpp; sourceTree = SOURCE_ROOT; };
@@ -1297,6 +1304,8 @@
90EC947A120EDF2A00F65F49 /* MessageValue.h */,
90337C4011D0D847009FCC01 /* MessageWrap.cpp */,
90337C4111D0D847009FCC01 /* MessageWrap.h */,
+ 90F3D68713F82F5E0058E68D /* ObjectFactoryMap.cpp */,
+ 90F3D68B13F82F6E0058E68D /* ObjectFactoryMap.h */,
90BB31C811FE3F62008A0628 /* ObjectType.h */,
90337C4311D0D847009FCC01 /* OrderedMessageQueue.cpp */,
90337C4411D0D847009FCC01 /* OrderedMessageQueue.h */,
@@ -1495,6 +1504,7 @@
907B1F52129965D900B263E2 /* DspBang.h in Headers */,
90CCEBE31299CD7D009D36DF /* DspReciprocalSqrt.h in Headers */,
9086906C129AC67B00D3BD5D /* DspSqrt.h in Headers */,
+ 90F3D68C13F82F700058E68D /* ObjectFactoryMap.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1644,6 +1654,7 @@
907B1F55129965D900B263E2 /* DspBang.h in Headers */,
90CCEBE61299CD7D009D36DF /* DspReciprocalSqrt.h in Headers */,
9086906E129AC67B00D3BD5D /* DspSqrt.h in Headers */,
+ 90F3D68D13F82F700058E68D /* ObjectFactoryMap.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1870,6 +1881,7 @@
90869070129AC67B00D3BD5D /* DspSqrt.cpp in Sources */,
9099A82C13D0437E0091E9FF /* MessageCputime.cpp in Sources */,
9099A82F13D043D60091E9FF /* DspVCF.cpp in Sources */,
+ 90F3D68813F82F5F0058E68D /* ObjectFactoryMap.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2010,6 +2022,7 @@
9086906D129AC67B00D3BD5D /* DspSqrt.cpp in Sources */,
9099A82D13D0437E0091E9FF /* MessageCputime.cpp in Sources */,
9099A83013D043D70091E9FF /* DspVCF.cpp in Sources */,
+ 90F3D68913F82F5F0058E68D /* ObjectFactoryMap.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2150,6 +2163,7 @@
9086906F129AC67B00D3BD5D /* DspSqrt.cpp in Sources */,
9099A82E13D0437F0091E9FF /* MessageCputime.cpp in Sources */,
9099A83113D043D80091E9FF /* DspVCF.cpp in Sources */,
+ 90F3D68A13F82F5F0058E68D /* ObjectFactoryMap.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
4 src/DspAdc.cpp
@@ -23,6 +23,10 @@
#include "DspAdc.h"
#include "PdGraph.h"
+MessageObject *DspAdc::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspAdc(graph);
+}
+
DspAdc::DspAdc(PdGraph *graph) : DspObject(0, 0, 0, graph->getNumInputChannels(), graph) {
/* In order to avoid lots of <code>memcpy</code>ing to separate input buffers, all ADCs refer to
* the same input buffers.
View
3 src/DspAdc.h
@@ -28,10 +28,11 @@
class DspAdc : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspAdc(PdGraph *graph);
~DspAdc();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
bool doesProcessAudio();
};
View
5 src/DspAdd.cpp
@@ -24,6 +24,10 @@
#include "DspAdd.h"
#include "PdGraph.h"
+MessageObject *DspAdd::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspAdd(initMessage, graph);
+}
+
DspAdd::DspAdd(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 2, 0, 1, graph) {
constant = initMessage->isFloat(0) ? initMessage->getFloat(0) : 0.0f;
}
@@ -71,7 +75,6 @@ void DspAdd::onInletConnectionUpdate() {
void DspAdd::processMessage(int inletIndex, PdMessage *message) {
if (inletIndex == 1) {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
constant = message->getFloat(0);
}
}
View
3 src/DspAdd.h
@@ -39,10 +39,11 @@ enum DspAddCodePath {
class DspAdd : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspAdd(PdMessage *initMessage, PdGraph *graph);
~DspAdd();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
string toString();
void processDsp();
View
6 src/DspBandpassFilter.cpp
@@ -23,6 +23,10 @@
#include "DspBandpassFilter.h"
#include "PdGraph.h"
+MessageObject *DspBandpassFilter::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspBandpassFilter(initMessage, graph);
+}
+
DspBandpassFilter::DspBandpassFilter(PdMessage *initMessage, PdGraph *graph) : DspObject(3, 1, 0, 1, graph) {
sampleRate = graph->getSampleRate();
tap_0 = 0.0f;
@@ -77,14 +81,12 @@ void DspBandpassFilter::processMessage(int inletIndex, PdMessage *message) {
}
case 1: {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
calculateFilterCoefficients(message->getFloat(0), q);
}
break;
}
case 2: {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
calculateFilterCoefficients(centerFrequency, message->getFloat(0));
}
break;
View
3 src/DspBandpassFilter.h
@@ -32,10 +32,11 @@
class DspBandpassFilter : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspBandpassFilter(PdMessage *initMessage, PdGraph *graph);
~DspBandpassFilter();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
private:
void processMessage(int inletIndex, PdMessage *message);
View
4 src/DspBang.cpp
@@ -23,6 +23,10 @@
#include "DspBang.h"
#include "PdGraph.h"
+MessageObject *DspBang::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspBang(initMessage, graph);
+}
+
DspBang::DspBang(PdMessage *initMessage, PdGraph *graph) : DspObject(1, 0, 1, 0, graph) {
// nothing to do
}
View
3 src/DspBang.h
@@ -29,10 +29,11 @@
class DspBang : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspBang(PdMessage *initMessage, PdGraph *graph);
~DspBang();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
ConnectionType getConnectionType(int outletIndex);
View
4 src/DspCatch.cpp
@@ -25,6 +25,10 @@
#include "DspThrow.h"
#include "PdGraph.h"
+MessageObject *DspCatch::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspCatch(initMessage, graph);
+}
+
DspCatch::DspCatch(PdMessage *initMessage, PdGraph *graph) : DspObject(0, 0, 0, 1, graph) {
if (initMessage->isSymbol(0)) {
name = StaticUtils::copyString(initMessage->getSymbol(0));
View
3 src/DspCatch.h
@@ -34,14 +34,15 @@ class DspThrow;
class DspCatch : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspCatch(PdMessage *initMessage, PdGraph *graph);
~DspCatch();
void addThrow(DspThrow *dspThrow);
void removeThrow(DspThrow *dspThrow);
char *getName();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
ObjectType getObjectType();
string toString();
View
39 src/DspClip.cpp
@@ -24,6 +24,10 @@
#include "DspClip.h"
#include "PdGraph.h"
+MessageObject *DspClip::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspClip(initMessage, graph);
+}
+
DspClip::DspClip(PdMessage *initMessage, PdGraph *graph) : DspObject(3, 1, 0, 1, graph) {
lowerBound = initMessage->isFloat(0) ? initMessage->getFloat(0) : -1.0f;
upperBound = initMessage->isFloat(1) ? initMessage->getFloat(1) : 1.0f;
@@ -60,40 +64,17 @@ void DspClip::onInletConnectionUpdate() {
void DspClip::processMessage(int inletIndex, PdMessage *message) {
switch (inletIndex) {
- case 1: {
- if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
- lowerBound = message->getFloat(0); // set the lower bound
- }
- break;
- }
- case 2: {
- if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
- upperBound = message->getFloat(0); // set the upper bound
- }
- break;
- }
- default: {
- break;
- }
+ case 1: if (message->isFloat(0)) lowerBound = message->getFloat(0); break; // set the lower bound
+ case 2: if (message->isFloat(0)) upperBound = message->getFloat(0); break; // set the upper bound
+ default: break;
}
}
void DspClip::processDsp() {
switch (codePath) {
- case DSP_CLIP_DSPX_MESSAGE0: {
- resolveInputBuffers(0, dspBufferAtInlet0);
- // allow fallthrough
- }
- case DSP_CLIP_DSP1_MESSAGE0: {
- processDspWithIndex(0, blockSizeInt);
- break;
- }
- default: {
- DspObject::processDsp();
- break;
- }
+ case DSP_CLIP_DSPX_MESSAGE0: resolveInputBuffers(0, dspBufferAtInlet0); // allow fallthrough
+ case DSP_CLIP_DSP1_MESSAGE0: processDspWithIndex(0, blockSizeInt); break;
+ default: DspObject::processDsp(); break;
}
}
View
3 src/DspClip.h
@@ -36,10 +36,11 @@ enum DspClipCodePath {
class DspClip : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspClip(PdMessage *initMessage, PdGraph *graph);
~DspClip();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
string toString();
void processDsp();
View
4 src/DspCosine.cpp
@@ -28,6 +28,10 @@
float *DspCosine::cos_table = NULL;
int DspCosine::refCount = 0;
+MessageObject *DspCosine::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspCosine(initMessage, graph);
+}
+
DspCosine::DspCosine(PdMessage *initMessage, PdGraph *graph) : DspObject(0, 1, 0, 1, graph) {
this->sampleRate = graph->getSampleRate();
refCount++;
View
3 src/DspCosine.h
@@ -29,10 +29,11 @@
class DspCosine : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspCosine(PdMessage *initMessage, PdGraph *graph);
~DspCosine();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
void processDsp();
View
15 src/DspDac.cpp
@@ -24,6 +24,10 @@
#include "DspDac.h"
#include "PdGraph.h"
+MessageObject *DspDac::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspDac(graph);
+}
+
DspDac::DspDac(PdGraph *graph) : DspObject(0, graph->getNumOutputChannels(), 0, 0, graph) {
// nothing to do
}
@@ -36,25 +40,26 @@ const char *DspDac::getObjectLabel() {
return "dac~";
}
-void DspDac::processDspWithIndex(int fromIndex, int toIndex) {
- float *globalOutputBuffer;
+void DspDac::processDsp() {
switch (incomingDspConnections.size()) {
default: {
/* TODO(mhroth): fit this into the new buffer reference architecture
for (int i = 2; i < numDspInlets; i++) {
- globalOutputBuffer = graph->getGlobalDspBufferAtOutlet(i);
+ float *globalOutputBuffer = graph->getGlobalDspBufferAtOutlet(i);
ArrayArithmetic::add(globalOutputBuffer, localDspBufferAtInlet[i], globalOutputBuffer, 0, blockSizeInt);
}
*/
// allow fallthrough
}
case 2: {
- globalOutputBuffer = graph->getGlobalDspBufferAtOutlet(1);
+ RESOLVE_DSPINLET1_IF_NECESSARY();
+ float *globalOutputBuffer = graph->getGlobalDspBufferAtOutlet(1);
ArrayArithmetic::add(globalOutputBuffer, dspBufferAtInlet1, globalOutputBuffer, 0, blockSizeInt);
// allow fallthrough
}
case 1: {
- globalOutputBuffer = graph->getGlobalDspBufferAtOutlet(0);
+ RESOLVE_DSPINLET0_IF_NECESSARY();
+ float *globalOutputBuffer = graph->getGlobalDspBufferAtOutlet(0);
ArrayArithmetic::add(globalOutputBuffer, dspBufferAtInlet0, globalOutputBuffer, 0, blockSizeInt);
// allow fallthrough
}
View
6 src/DspDac.h
@@ -28,13 +28,13 @@
class DspDac : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspDac(PdGraph *graph);
~DspDac();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
- private:
- void processDspWithIndex(int fromIndex, int toIndex);
+ void processDsp();
};
#endif // _DSP_DAC_H_
View
5 src/DspDelayRead.cpp
@@ -25,6 +25,10 @@
#include "DspDelayWrite.h"
#include "PdGraph.h"
+MessageObject *DspDelayRead::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspDelayRead(initMessage, graph);
+}
+
DspDelayRead::DspDelayRead(PdMessage *initMessage, PdGraph *graph) : DelayReceiver(1, 0, 0, 1, graph) {
if (initMessage->isSymbol(0) && initMessage->isFloat(1)) {
name = StaticUtils::copyString(initMessage->getSymbol(0));
@@ -51,7 +55,6 @@ ObjectType DspDelayRead::getObjectType() {
void DspDelayRead::processMessage(int inletIndex, PdMessage *message) {
if (message->isFloat(0)) {
// update the delay time
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
delayInSamples = StaticUtils::millisecondsToSamples(message->getFloat(0), graph->getSampleRate());
delayInSamplesInt = (int) delayInSamples;
}
View
3 src/DspDelayRead.h
@@ -34,10 +34,11 @@ class DspDelayWrite;
class DspDelayRead : public DelayReceiver {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspDelayRead(PdMessage *initString, PdGraph *graph);
~DspDelayRead();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
ObjectType getObjectType();
private:
View
4 src/DspDelayWrite.cpp
@@ -24,6 +24,10 @@
#include "DspDelayWrite.h"
#include "PdGraph.h"
+MessageObject *DspDelayWrite::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspDelayWrite(initMessage, graph);
+}
+
DspDelayWrite::DspDelayWrite(PdMessage *initMessage, PdGraph *graph) : DspObject(0, 1, 0, 0, graph) {
if (initMessage->isSymbol(0) && initMessage->isFloat(1)) {
bufferLength = (int) ceilf(StaticUtils::millisecondsToSamples(initMessage->getFloat(1),
View
3 src/DspDelayWrite.h
@@ -28,10 +28,11 @@
class DspDelayWrite : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspDelayWrite(PdMessage *initMessage, PdGraph *graph);
~DspDelayWrite();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
ObjectType getObjectType();
char *getName();
View
5 src/DspDivide.cpp
@@ -24,6 +24,10 @@
#include "DspDivide.h"
#include "PdGraph.h"
+MessageObject *DspDivide::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspDivide(initMessage, graph);
+}
+
DspDivide::DspDivide(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 2, 0, 1, graph) {
constant = initMessage->isFloat(0) ? initMessage->getFloat(0) : 0.0f;
}
@@ -47,7 +51,6 @@ void DspDivide::processMessage(int inletIndex, PdMessage *message) {
switch (inletIndex) {
case 1: {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
constant = message->getFloat(0);
}
break;
View
3 src/DspDivide.h
@@ -28,10 +28,11 @@
class DspDivide : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspDivide(PdMessage *initMessage, PdGraph *graph);
~DspDivide();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
string toString();
private:
View
4 src/DspEnvelope.cpp
@@ -27,6 +27,10 @@
/** By default, the analysis window size is 1024 samples. */
#define DEFAULT_WINDOW_SIZE 1024
+MessageObject *DspEnvelope::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspEnvelope(initMessage, graph);
+}
+
DspEnvelope::DspEnvelope(PdMessage *initMessage, PdGraph *graph) : DspObject(0, 1, 1, 0, graph) {
if (initMessage->isFloat(0)) {
if (initMessage->isFloat(1)) {
View
4 src/DspEnvelope.h
@@ -29,6 +29,8 @@
class DspEnvelope : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
+
/*
* @param windowSize The window size in samples of the analysis. Defaults to 1024.
* @param windowInterval The window interval in samples of the analysis.
@@ -38,7 +40,7 @@ class DspEnvelope : public DspObject {
DspEnvelope(PdMessage *initMessage, PdGraph *graph);
~DspEnvelope();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
string toString();
ConnectionType getConnectionType(int outletIndex);
View
8 src/DspHighpassFilter.cpp
@@ -25,6 +25,10 @@
#include "DspHighpassFilter.h"
#include "PdGraph.h"
+MessageObject *DspHighpassFilter::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspHighpassFilter(initMessage, graph);
+}
+
DspHighpassFilter::DspHighpassFilter(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 1, 0, 1, graph) {
sampleRate = graph->getSampleRate();
tapIn = 0.0f;
@@ -57,16 +61,14 @@ void DspHighpassFilter::calculateFilterCoefficients(float cutoffFrequency) {
void DspHighpassFilter::processMessage(int inletIndex, PdMessage *message) {
switch (inletIndex) {
case 0: {
- if (message->isSymbol(0) && strcmp(message->getSymbol(0), "clear") == 0) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
+ if (message->isSymbol(0, "clear")) {
tapIn = 0.0f;
tapOut = 0.0f;
}
break;
}
case 1: {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
calculateFilterCoefficients(message->getFloat(0));
}
break;
View
3 src/DspHighpassFilter.h
@@ -32,10 +32,11 @@
class DspHighpassFilter : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspHighpassFilter(PdMessage *initMessage, PdGraph *graph);
~DspHighpassFilter();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
private:
void processMessage(int inletIndex, PdMessage *message);
View
6 src/DspInlet.cpp
@@ -24,8 +24,12 @@
#include "DspInlet.h"
#include "PdGraph.h"
+MessageObject *DspInlet::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspInlet(graph);
+}
+
DspInlet::DspInlet(PdGraph *graph) : DspObject(0, 1, 0, 1, graph) {
- canvasX = 0;
+ canvasX = 0.0f;
}
DspInlet::~DspInlet() {
View
3 src/DspInlet.h
@@ -35,10 +35,11 @@ class PdGraph;
*/
class DspInlet : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspInlet(PdGraph *graph);
~DspInlet();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
ObjectType getObjectType();
list<MessageObject *> *getProcessOrder();
View
8 src/DspLine.cpp
@@ -24,7 +24,11 @@
#include "DspLine.h"
#include "PdGraph.h"
-DspLine::DspLine(PdGraph *graph) : DspObject(2, 0, 0, 1, graph) {
+MessageObject *DspLine::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspLine(initMessage, graph);
+}
+
+DspLine::DspLine(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 0, 0, 1, graph) {
target = 0.0f;
slope = 0.0f;
numSamplesToTarget = 0.0f;
@@ -48,7 +52,6 @@ void DspLine::processMessage(int inletIndex, PdMessage *message) {
case 1: {
// jump to value
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
target = message->getFloat(0);
lastOutputSample = target;
slope = 0.0f;
@@ -59,7 +62,6 @@ void DspLine::processMessage(int inletIndex, PdMessage *message) {
default: { // at least two inputs
// new ramp
if (message->isFloat(0) && message->isFloat(1)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
target = message->getFloat(0);
float timeToTargetMs = message->getFloat(1); // no negative time to targets!
numSamplesToTarget = StaticUtils::millisecondsToSamples(
View
5 src/DspLine.h
@@ -29,10 +29,11 @@
class DspLine : public DspObject {
public:
- DspLine(PdGraph *graph);
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
+ DspLine(PdMessage *initMessage, PdGraph *graph);
~DspLine();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
private:
void processMessage(int inletIndex, PdMessage *message);
View
5 src/DspLog.cpp
@@ -23,6 +23,10 @@
#include "DspLog.h"
#include "PdGraph.h"
+MessageObject *DspLog::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspLog(initMessage, graph);
+}
+
DspLog::DspLog(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 2, 0, 1, graph) {
// by default assume ln
log2_base = initMessage->isFloat(0) ? log2f(initMessage->getFloat(0)) : M_LOG2E;
@@ -39,7 +43,6 @@ const char *DspLog::getObjectLabel() {
void DspLog::processMessage(int inletIndex, PdMessage *message) {
if (inletIndex == 1) {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
if (message->getFloat(0) <= 0.0f) {
graph->printErr("log~ base cannot be set to a non-positive number: %d\n", message->getFloat(0));
} else {
View
3 src/DspLog.h
@@ -29,10 +29,11 @@
class DspLog : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspLog(PdMessage *initMessage, PdGraph *graph);
~DspLog();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
private:
void processMessage(int inletIndex, PdMessage *message);
View
7 src/DspLowpassFilter.cpp
@@ -24,6 +24,10 @@
#include "DspLowpassFilter.h"
#include "PdGraph.h"
+MessageObject *DspLowpassFilter::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspLowpassFilter(initMessage, graph);
+}
+
DspLowpassFilter::DspLowpassFilter(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 1, 0, 1, graph) {
calculateFilterCoefficients(initMessage->isFloat(0) ? initMessage->getFloat(0) : graph->getSampleRate()/2.0f);
signalConstant = 0.0f;
@@ -82,13 +86,11 @@ void DspLowpassFilter::processMessage(int inletIndex, PdMessage *message) {
case 0: {
switch (message->getType(0)) {
case FLOAT: {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
signalConstant = message->getFloat(0);
break;
}
case SYMBOL: {
if (message->isSymbol(0, "clear")) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
dspBufferAtOutlet0[0] = dspBufferAtOutlet0[1] = 0.0f;
}
break;
@@ -101,7 +103,6 @@ void DspLowpassFilter::processMessage(int inletIndex, PdMessage *message) {
}
case 1: {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
calculateFilterCoefficients(message->getFloat(0));
}
break;
View
3 src/DspLowpassFilter.h
@@ -39,10 +39,11 @@ enum DspLopCodePath {
class DspLowpassFilter : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspLowpassFilter(PdMessage *initMessage, PdGraph *graph);
~DspLowpassFilter();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
float *getDspBufferRefAtOutlet(int outletIndex);
View
5 src/DspMinimum.cpp
@@ -24,6 +24,10 @@
#include "DspMinimum.h"
#include "PdGraph.h"
+MessageObject *DspMinimum::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspMinimum(initMessage, graph);
+}
+
DspMinimum::DspMinimum(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 2, 0, 1, graph) {
constant = initMessage->isFloat(0) ? initMessage->getFloat(0) : 0.0f;
codePath = DSP_MINIMUM_DEFAULT;
@@ -116,7 +120,6 @@ void DspMinimum::processDsp() {
void DspMinimum::processMessage(int inletIndex, PdMessage *message) {
if (inletIndex == 1) {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
constant = message->getFloat(0);
}
}
View
3 src/DspMinimum.h
@@ -40,10 +40,11 @@ enum DspMinimumCodePath {
class DspMinimum : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspMinimum(PdMessage *initMessage, PdGraph *graph);
~DspMinimum();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
string toString();
void processDsp();
View
6 src/DspMultiply.cpp
@@ -24,6 +24,10 @@
#include "DspMultiply.h"
#include "PdGraph.h"
+MessageObject *DspMultiply::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspMultiply(initMessage, graph);
+}
+
DspMultiply::DspMultiply(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 2, 0, 1, graph) {
constant = initMessage->isFloat(0) ? initMessage->getFloat(0) : 0.0f;
inputConstant = 0.0f;
@@ -74,14 +78,12 @@ void DspMultiply::processMessage(int inletIndex, PdMessage *message) {
switch (inletIndex) {
case 0: {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
inputConstant = message->getFloat(0);
}
break;
}
case 1: {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
constant = message->getFloat(0);
}
break;
View
3 src/DspMultiply.h
@@ -39,10 +39,11 @@ enum DspMultiplyCodePath {
class DspMultiply : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspMultiply(PdMessage *initMessage, PdGraph *graph);
~DspMultiply();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
string toString();
void processDsp();
View
4 src/DspNoise.cpp
@@ -23,6 +23,10 @@
#include "DspNoise.h"
#include "PdGraph.h"
+MessageObject *DspNoise::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspNoise(graph);
+}
+
DspNoise::DspNoise(PdGraph *graph) : DspObject(1, 0, 0, 1, graph) {
twister = new MTRand(); // use new seed
}
View
3 src/DspNoise.h
@@ -32,10 +32,11 @@ class PdGraph;
class DspNoise : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspNoise(PdGraph *graph);
~DspNoise();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
void processDsp();
View
4 src/DspObject.cpp
@@ -251,11 +251,13 @@ void DspObject::processDsp() {
PdMessage *message = messageLetPair.first;
unsigned int inletIndex = messageLetPair.second;
+ float blockIndexOfCurrentMessage = graph->getBlockIndex(message);
+ processDspWithIndex(blockIndexOfLastMessage, blockIndexOfCurrentMessage);
processMessage(inletIndex, message);
message->freeMessage(); // free the message from the head, the message has been consumed.
messageQueue.pop();
- blockIndexOfLastMessage = graph->getBlockIndex(message);
+ blockIndexOfLastMessage = blockIndexOfCurrentMessage;
} while (!messageQueue.empty());
processDspWithIndex(blockIndexOfLastMessage, (float) blockSizeInt);
blockIndexOfLastMessage = 0.0f; // reset the block index of the last received message
View
6 src/DspObject.h
@@ -36,6 +36,12 @@
resolveInputBuffers(0, dspBufferAtInlet0); \
}
+#define RESOLVE_DSPINLET1_IF_NECESSARY() \
+ if (incomingDspConnections[1].size() > 1) { \
+ dspBufferAtInlet1 = (float *) alloca(numBytesInBlock); \
+ resolveInputBuffers(1, dspBufferAtInlet1); \
+ }
+
typedef std::pair<PdMessage *, unsigned int> MessageLetPair;
/**
View
5 src/DspOsc.cpp
@@ -27,6 +27,10 @@
float *DspOsc::cos_table = NULL;
int DspOsc::refCount = 0;
+MessageObject *DspOsc::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspOsc(initMessage, graph);
+}
+
DspOsc::DspOsc(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 2, 0, 1, graph) {
frequency = initMessage->isFloat(0) ? initMessage->getFloat(0) : 0.0f;
@@ -65,7 +69,6 @@ void DspOsc::processMessage(int inletIndex, PdMessage *message) {
switch (inletIndex) {
case 0: { // update the frequency
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
frequency = fabsf(message->getFloat(0));
}
break;
View
3 src/DspOsc.h
@@ -29,10 +29,11 @@
class DspOsc : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspOsc(PdMessage *initMessage, PdGraph *graph); // and oscillator of default zero frequency
~DspOsc();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
string toString();
protected:
View
6 src/DspOutlet.cpp
@@ -22,8 +22,12 @@
#include "DspOutlet.h"
+MessageObject *DspOutlet::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspOutlet(graph);
+}
+
DspOutlet::DspOutlet(PdGraph *graph) : DspObject(0, 1, 0, 1, graph) {
- canvasX = 0;
+ canvasX = 0.0f;
}
DspOutlet::~DspOutlet() {
View
3 src/DspOutlet.h
@@ -38,10 +38,11 @@ class PdGraph;
class DspOutlet : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspOutlet(PdGraph *graph);
~DspOutlet();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
ObjectType getObjectType();
bool isLeafNode();
View
5 src/DspPhasor.cpp
@@ -34,6 +34,10 @@ union tabfudge {
int tf_i[2];
};
+MessageObject *DspPhasor::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspPhasor(initMessage, graph);
+}
+
DspPhasor::DspPhasor(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 2, 0, 1, graph) {
frequency = initMessage->isFloat(0) ? initMessage->getFloat(0) : 0.0f;
@@ -76,7 +80,6 @@ void DspPhasor::processMessage(int inletIndex, PdMessage *message) {
switch (inletIndex) {
case 0: { // update the frequency
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
frequency = message->getFloat(0);
}
break;
View
3 src/DspPhasor.h
@@ -29,10 +29,11 @@
class DspPhasor : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspPhasor(PdMessage *initMessage, PdGraph *graph); // and Phasorillator of default zero frequency
~DspPhasor();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
string toString();
protected:
View
4 src/DspPrint.cpp
@@ -23,6 +23,10 @@
#include "DspPrint.h"
#include "PdGraph.h"
+MessageObject *DspPrint::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspPrint(initMessage, graph);
+}
+
DspPrint::DspPrint(PdMessage *initMessage, PdGraph *graph) : DspObject(1, 1, 0, 0, graph) {
name = StaticUtils::copyString(initMessage->isSymbol(0) ? initMessage->getSymbol(0) : (char *) "print~");
}
View
3 src/DspPrint.h
@@ -29,10 +29,11 @@
class DspPrint : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspPrint(PdMessage *initMessage, PdGraph *graph);
~DspPrint();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
private:
void processMessage(int inletIndex, PdMessage *message);
View
4 src/DspReceive.cpp
@@ -24,6 +24,10 @@
#include "DspReceive.h"
#include "PdGraph.h"
+MessageObject *DspReceive::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspReceive(initMessage, graph);
+}
+
DspReceive::DspReceive(PdMessage *initMessage, PdGraph *graph) : DspObject(1, 0, 0, 1, graph) {
if (initMessage->isSymbol(0)) {
name = StaticUtils::copyString(initMessage->getSymbol(0));
View
3 src/DspReceive.h
@@ -29,13 +29,14 @@
class DspReceive : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspReceive(PdMessage *initMessage, PdGraph *graph);
~DspReceive();
/** Set a double-pointer at the send~'s input buffer. */
void setBuffer(float **buffer);
char *getName();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
ObjectType getObjectType();
void processDsp();
View
4 src/DspReciprocalSqrt.cpp
@@ -25,6 +25,10 @@
#include "DspReciprocalSqrt.h"
#include "PdGraph.h"
+MessageObject *DspReciprocalSqrt::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspReciprocalSqrt(initMessage, graph);
+}
+
DspReciprocalSqrt::DspReciprocalSqrt(PdMessage *initMessage, PdGraph *graph) : DspObject(0, 1, 0, 1, graph) {
// nothign to do
}
View
3 src/DspReciprocalSqrt.h
@@ -29,10 +29,11 @@
class DspReciprocalSqrt : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspReciprocalSqrt(PdMessage *initMessage, PdGraph *graph);
~DspReciprocalSqrt();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
void processDsp();
};
View
4 src/DspRfft.cpp
@@ -24,6 +24,10 @@
#include "DspRfft.h"
#include "PdGraph.h"
+MessageObject *DspRfft::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspRfft(initMessage, graph);
+}
+
DspRfft::DspRfft(PdMessage *initMessage, PdGraph *graph) : DspObject(0, 1, 0, 2, graph) {
#if __APPLE__
log2n = lrintf(log2f((float) blockSizeInt));
View
3 src/DspRfft.h
@@ -30,10 +30,11 @@
class DspRfft : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspRfft(PdMessage *initMessage, PdGraph *graph);
~DspRfft();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
void processDsp();
View
4 src/DspRifft.cpp
@@ -24,6 +24,10 @@
#include "DspRifft.h"
#include "PdGraph.h"
+MessageObject *DspRifft::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspRifft(initMessage, graph);
+}
+
DspRifft::DspRifft(PdMessage *initMessage, PdGraph *graph) : DspObject(0, 2, 0, 1, graph) {
#if __APPLE__
log2n = lrintf(log2f((float) blockSizeInt));
View
3 src/DspRifft.h
@@ -30,10 +30,11 @@
class DspRifft : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspRifft(PdMessage *initMessage, PdGraph *graph);
~DspRifft();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
private:
void processDspWithIndex(int fromIndex, int toIndex);
View
4 src/DspSend.cpp
@@ -23,6 +23,10 @@
#include "DspSend.h"
#include "PdGraph.h"
+MessageObject *DspSend::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspSend(initMessage, graph);
+}
+
DspSend::DspSend(PdMessage *initMessage, PdGraph *graph) : DspObject(0, 1, 0, 0, graph) {
if (initMessage->isSymbol(0)) {
name = StaticUtils::copyString(initMessage->getSymbol(0));
View
3 src/DspSend.h
@@ -29,6 +29,7 @@
class DspSend : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspSend(PdMessage *initMessage, PdGraph *graph);
~DspSend();
@@ -39,7 +40,7 @@ class DspSend : public DspObject {
*/
float **getBuffer();
char *getName();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
string toString();
ObjectType getObjectType();
View
5 src/DspSignal.cpp
@@ -24,6 +24,10 @@
#include "DspSignal.h"
#include "PdGraph.h"
+MessageObject *DspSignal::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspSignal(initMessage, graph);
+}
+
DspSignal::DspSignal(PdMessage *initMessage, PdGraph *graph) : DspObject(1, 0, 0, 1, graph) {
constant = initMessage->isFloat(0) ? initMessage->getFloat(0) : 0.0f;
}
@@ -44,7 +48,6 @@ string DspSignal::toString() {
void DspSignal::processMessage(int inletIndex, PdMessage *message) {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
constant = message->getFloat(0);
}
}
View
11 src/DspSignal.h
@@ -28,12 +28,13 @@
/** [sig~] */
class DspSignal : public DspObject {
-public:
- DspSignal(PdMessage *initMessage, PdGraph *graph);
- ~DspSignal();
+ public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
+ DspSignal(PdMessage *initMessage, PdGraph *graph);
+ ~DspSignal();
- const char *getObjectLabel();
- string toString();
+ static const char *getObjectLabel();
+ string toString();
private:
void processMessage(int inletIndex, PdMessage *message);
View
4 src/DspSnapshot.cpp
@@ -23,6 +23,10 @@
#include "DspSnapshot.h"
#include "PdGraph.h"
+MessageObject *DspSnapshot::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspSnapshot(initMessage, graph);
+}
+
DspSnapshot::DspSnapshot(PdMessage *initMessage, PdGraph *graph) : DspObject(1, 1, 1, 0, graph) {
// nothing to do
}
View
3 src/DspSnapshot.h
@@ -29,10 +29,11 @@
class DspSnapshot : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspSnapshot(PdMessage *initMessage, PdGraph *graph);
~DspSnapshot();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
ConnectionType getConnectionType(int outletIndex);
View
4 src/DspSqrt.cpp
@@ -23,6 +23,10 @@
#include "DspSqrt.h"
#include "PdGraph.h"
+MessageObject *DspSqrt::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspSqrt(initMessage, graph);
+}
+
DspSqrt::DspSqrt(PdMessage *initMessage, PdGraph *graph) : DspObject(0, 1, 0, 1, graph) {
// nothign to do
}
View
3 src/DspSqrt.h
@@ -30,10 +30,11 @@
class DspSqrt : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspSqrt(PdMessage *initMessage, PdGraph *graph);
~DspSqrt();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
void processDsp();
};
View
5 src/DspSubtract.cpp
@@ -24,6 +24,10 @@
#include "DspSubtract.h"
#include "PdGraph.h"
+MessageObject *DspSubtract::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspSubtract(initMessage, graph);
+}
+
DspSubtract::DspSubtract(PdMessage *initMessage, PdGraph *graph) : DspObject(2, 2, 0, 1, graph) {
constant = initMessage->isFloat(0) ? initMessage->getFloat(0) : 0.0f;
codePath = DSP_SUBTRACT_DEFAULT;
@@ -97,7 +101,6 @@ void DspSubtract::processDsp() {
void DspSubtract::processMessage(int inletIndex, PdMessage *message) {
if (inletIndex == 1) {
if (message->isFloat(0)) {
- processDspWithIndex(blockIndexOfLastMessage, graph->getBlockIndex(message));
constant = message->getFloat(0);
}
}
View
3 src/DspSubtract.h
@@ -38,10 +38,11 @@ enum DspSubtractCodePath {
class DspSubtract : public DspObject {
public:
+ static MessageObject *newObject(PdMessage *initMessage, PdGraph *graph);
DspSubtract(PdMessage *initMessage, PdGraph *graph);
~DspSubtract();
- const char *getObjectLabel();
+ static const char *getObjectLabel();
string toString();
void processDsp();
View
7 src/DspTablePlay.cpp
@@ -24,6 +24,10 @@
#include "MessageTable.h"
#include "PdGraph.h"
+MessageObject *DspTablePlay::newObject(PdMessage *initMessage, PdGraph *graph) {
+ return new DspTablePlay(initMessage, graph);
+}
+
DspTablePlay::DspTablePlay(PdMessage *initMessage, PdGraph *graph) : DspObject(1, 0, 2, 1, graph) {
name = initMessage->isSymbol(0) ? StaticUtils::copyString(initMessage->getSymbol(0)) : NULL;
table = NULL;