~marcustomlinson/dspatchables/trunk

« back to all changes in this revision

Viewing changes to DspAdder/DspAdder.h

  • Committer: Marcus Tomlinson
  • Date: 2015-04-05 22:25:24 UTC
  • mfrom: (1.1.10 trunk)
  • Revision ID: marcus.tomlinson@canonical.com-20150405222524-urntp725s5hbk2im
Merged add_basic_components

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/************************************************************************
 
2
DSPatch - Cross-Platform, Object-Oriented, Flow-Based Programming Library
 
3
Copyright (c) 2012-2015 Marcus Tomlinson
 
4
 
 
5
This file is part of DSPatch.
 
6
 
 
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.
 
14
 
 
15
Other Usage
 
16
Alternatively, this file may be used in accordance with the terms and
 
17
conditions contained in a signed written agreement between you and
 
18
Marcus Tomlinson.
 
19
 
 
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
************************************************************************/
 
24
 
 
25
#ifndef DSPADDER_H
 
26
#define DSPADDER_H
 
27
 
 
28
#include <DSPatch.h>
 
29
 
 
30
//=================================================================================================
 
31
/// Example DspComponent: Adder
 
32
 
 
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. */
 
37
 
 
38
class DspAdder : public DspComponent
 
39
{
 
40
public:
 
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.*/
 
48
 
 
49
    DspAdder();
 
50
    ~DspAdder();
 
51
 
 
52
protected:
 
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). */
 
58
 
 
59
    virtual void Process_(DspSignalBus& inputs, DspSignalBus& outputs);
 
60
 
 
61
private:
 
62
    std::vector<float> _stream1;
 
63
    std::vector<float> _stream2;
 
64
};
 
65
 
 
66
//=================================================================================================
 
67
 
 
68
class DspAdderPlugin : public DspPlugin
 
69
{
 
70
    DspComponent* Create(std::map<std::string, DspParameter>&) const
 
71
    {
 
72
        return new DspAdder();
 
73
    }
 
74
};
 
75
 
 
76
EXPORT_DSPPLUGIN(DspAdderPlugin)
 
77
 
 
78
//=================================================================================================
 
79
 
 
80
#endif  // DSPADDER_H