NAP
audionode.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Std includes
8 #include <functional>
9 #include <set>
10 
11 // RTTI includes
12 #include <rtti/rtti.h>
13 
14 // Audio includes
15 #include <audio/utility/audiotypes.h>
16 #include <audio/core/audiopin.h>
17 #include <audio/core/process.h>
18 
19 namespace nap
20 {
21  namespace audio
22  {
23 
24  // Forward declarations
25  class NodeManager;
26 
27 
33  class NAPAPI Node : public Process
34  {
35  RTTI_ENABLE(Process)
36 
37  friend class InputPinBase;
38  friend class InputPin;
39  friend class OutputPin;
40  friend class MultiInputPin;
41 
42  public:
46  Node(NodeManager& manager);
47 
51  const std::set<OutputPin*>& getOutputs() const
52  {
53  return mOutputs;
54  }
55 
59  const std::set<InputPinBase*>& getInputs() const { return mInputs; }
60 
61  /*
62  * Override this method to do the actual audio processing and fill the buffers of this node's outputs with new audio data
63  * Use @getOutputBuffer() to access the buffers that have to be filled.
64  */
65  void process() override { }
66 
67  protected:
72  SampleBuffer& getOutputBuffer(OutputPin& output);
73 
74  private:
75  /*
76  * Used by the node manager to notify the node that the buffer size has changed.
77  * @param bufferSize the new value
78  */
79  void setBufferSize(int bufferSize) override;
80 
81  std::set<OutputPin*> mOutputs; // Used internally by the node to keep track of all its outputs.
82  std::set<InputPinBase*> mInputs; // Used internally by the node to keep track of all its inputs.
83  };
84 
85 
86  }
87 }
88 
89 
90 
91 
92 
nap::audio::MultiInputPin
Definition: audiopin.h:145
nap::audio::InputPinBase
Definition: audiopin.h:32
nap::audio::Node::process
void process() override
Definition: audionode.h:65
nap::audio::Process
Definition: process.h:36
nap::audio::NodeManager
Definition: audionodemanager.h:33
nap::audio::OutputPin
Definition: audiopin.h:204
nap::audio::Node
Definition: audionode.h:33
nap::audio::Node::getInputs
const std::set< InputPinBase * > & getInputs() const
Definition: audionode.h:59
nap::audio::InputPin
Definition: audiopin.h:87
nap
Definition: templateapp.h:17
nap::audio::SampleBuffer
std::vector< SampleValue > SampleBuffer
Definition: audiotypes.h:34