1
/************************************************************************
2
DSPatch - Cross-Platform, Object-Oriented, Flow-Based Programming Library
3
Copyright (c) 2012-2015 Marcus Tomlinson
5
This file is part of DSPatch.
7
GNU Lesser General Public License Usage
8
This file may be used under the terms of the GNU Lesser General Public
9
License version 3.0 as published by the Free Software Foundation and
10
appearing in the file LGPLv3.txt included in the packaging of this
11
file. Please review the following information to ensure the GNU Lesser
12
General Public License version 3.0 requirements will be met:
13
http://www.gnu.org/copyleft/lgpl.html.
16
Alternatively, this file may be used in accordance with the terms and
17
conditions contained in a signed written agreement between you and
20
DSPatch is distributed in the hope that it will be useful,
21
but WITHOUT ANY WARRANTY; without even the implied warranty of
22
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23
************************************************************************/
30
//=================================================================================================
31
/// Example DspComponent: Adder
33
/** This component has 2 inputs and 1 output. The component receives 2 floating-point buffers into
34
it's 2 inputs, adds each buffer element of the 1st buffer to the corresponding element of the 2nd
35
buffer, then stores the resultant buffer into a 3rd buffer. This resultant buffer is then passed to
36
output 1 of the component output bus. */
38
class DspAdder : public DspComponent
41
//! Component constructor
42
/*! When a component is constructed, it's input and output buses must be configured. This is
43
achieved by making calls to the base class protected methods: "AddInput_()" and "AddOutput_().
44
These methods must be called once per input / output required. IO signal names are optional
45
(Component IO can be referenced by either string ID or index) and can be assigned to each
46
input / output by supplying the desired string ID as an argument to the respective AddInput_()
47
/ AddOutput_() method call.*/
53
//! Virtual process method inherited from DspComponent
54
/*! The Process_() method is called from the DSPatch engine when a new set of component input
55
signals are ready for processing. The Process() method has 2 arguments: the input bus and the
56
output bus. This method's purpose is to pull its required inputs out of the input bus, process
57
these inputs, and populate the output bus with the results (see DspSignalBus). */
59
virtual void Process_(DspSignalBus& inputs, DspSignalBus& outputs);
62
std::vector<float> _stream1;
63
std::vector<float> _stream2;
66
//=================================================================================================
68
class DspAdderPlugin : public DspPlugin
70
DspComponent* Create(std::map<std::string, DspParameter>&) const
72
return new DspAdder();
76
EXPORT_DSPPLUGIN(DspAdderPlugin)
78
//=================================================================================================