Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 62 lines (54 sloc) 2.071 kB
f2342d0 @mhroth Add catch~ and throw~.
authored
1 /*
bdfb1f1 @mhroth update throw~, send~, and catch~ to handle pre-resolved buffers.
authored
2 * Copyright 2010,2012 Reality Jockey, Ltd.
f2342d0 @mhroth Add catch~ and throw~.
authored
3 * info@rjdj.me
4 * http://rjdj.me/
5 *
6 * This file is part of ZenGarden.
7 *
8 * ZenGarden is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ZenGarden is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with ZenGarden. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23 #include "DspThrow.h"
7b6d44a @mhroth Record path of abstraction when the graph is instantiated
authored
24 #include "PdContext.h"
f2342d0 @mhroth Add catch~ and throw~.
authored
25 #include "PdGraph.h"
26
7329847 @mhroth Add static factory method to all objects in order to create an object…
authored
27 MessageObject *DspThrow::newObject(PdMessage *initMessage, PdGraph *graph) {
28 return new DspThrow(initMessage, graph);
29 }
30
f2342d0 @mhroth Add catch~ and throw~.
authored
31 DspThrow::DspThrow(PdMessage *initMessage, PdGraph *graph) : DspObject(0, 1, 0, 0, graph) {
32 if (initMessage->isSymbol(0)) {
33 name = StaticUtils::copyString(initMessage->getSymbol(0));
b6e0218 @mhroth Throw~ buffers input until catch~ can process it
authored
34 buffer = ALLOC_ALIGNED_BUFFER(graph->getBlockSize() * sizeof(float));
f2342d0 @mhroth Add catch~ and throw~.
authored
35 } else {
36 name = NULL;
b6e0218 @mhroth Throw~ buffers input until catch~ can process it
authored
37 buffer = NULL;
bdfb1f1 @mhroth update throw~, send~, and catch~ to handle pre-resolved buffers.
authored
38 graph->printErr("throw~ may not be initialised without a name. \"set\" message not supported.");
f2342d0 @mhroth Add catch~ and throw~.
authored
39 }
b6e0218 @mhroth Throw~ buffers input until catch~ can process it
authored
40 processFunction = &processSignal;
f2342d0 @mhroth Add catch~ and throw~.
authored
41 }
42
43 DspThrow::~DspThrow() {
b6e0218 @mhroth Throw~ buffers input until catch~ can process it
authored
44 FREE_ALIGNED_BUFFER(buffer);
f2342d0 @mhroth Add catch~ and throw~.
authored
45 free(name);
46 }
47
bdfb1f1 @mhroth update throw~, send~, and catch~ to handle pre-resolved buffers.
authored
48 void DspThrow::processMessage(int inletIndex, PdMessage *message) {
49 if (inletIndex == 0 && message->isSymbol(0, "set") && message->isSymbol(1)) {
50 graph->printErr("throw~ does not support the \"set\" message.");
ceee816 @mhroth Update DspObject interface for (much) fast dsp object performance. In…
authored
51 }
f2342d0 @mhroth Add catch~ and throw~.
authored
52 }
b6e0218 @mhroth Throw~ buffers input until catch~ can process it
authored
53
54 void DspThrow::processSignal(DspObject *dspObject, int fromIndex, int toIndex) {
55 DspThrow *d = reinterpret_cast<DspThrow *>(dspObject);
56 memcpy(d->buffer, d->dspBufferAtInlet[0], toIndex*sizeof(float));
57 }
7ee7ade @Kyew Resolved catch~ and throw~ process ordering
Kyew authored
58
59 bool DspThrow::isLeafNode() {
60 return graph->getContext()->getDspCatch(name) == NULL;
61 }
Something went wrong with that request. Please try again.