NAP
napaudio/src/audio/component/inputcomponent.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 // Nap includes
8 #include <component.h>
9 #include <audio/utility/safeptr.h>
10 
11 // Audio includes
12 #include <audio/component/audiocomponentbase.h>
13 #include <audio/node/inputnode.h>
14 #include <audio/node/multiplynode.h>
15 #include <audio/node/controlnode.h>
16 
17 namespace nap
18 {
19  namespace audio
20  {
21  class AudioInputComponentInstance;
22 
28  {
29  RTTI_ENABLE(AudioComponentBase)
31  public:
33  {}
34 
35  // Properties
36  std::vector<int> mChannels;
37  ControllerValue mGain = 1.0;
38  bool mAllowOutOfBoundChannels = true;
39 
40  private:
41  };
42 
43 
49  {
50  RTTI_ENABLE(AudioComponentBaseInstance)
51  public:
53  entity, resource)
54  {}
55 
56  // Inherited from ComponentInstance
57  bool init(utility::ErrorState& errorState) override;
58 
59  // Inherited from AudioComponentBaseInstance
60  int getChannelCount() const override { return mGainNodes.size(); }
61 
62  OutputPin* getOutputForChannel(int channel) override { return &mGainNodes[channel]->audioOutput; }
63 
67  void setGain(ControllerValue gain);
68 
72  ControllerValue getGain() const;
73 
74  private:
75  std::vector<SafeOwner<Node>> mInputNodes; // Nodes pulling audio input data out of the ADC inputs from the node manager
76  std::vector<SafeOwner<MultiplyNode>> mGainNodes; // Nodes to control gain level of the input
77  SafeOwner<ControlNode> mGainControl; // Node to control the gain for each channel.
78 
79  ControllerValue mGain = 1; // Gain factor of the output signal.
80  };
81 
82  }
83 
84 }
nap::audio::AudioInputComponentInstance::getOutputForChannel
OutputPin * getOutputForChannel(int channel) override
Definition: napaudio/src/audio/component/inputcomponent.h:62
nap::audio::AudioInputComponent::AudioInputComponent
AudioInputComponent()
Definition: napaudio/src/audio/component/inputcomponent.h:32
nap::audio::AudioInputComponent
Definition: napaudio/src/audio/component/inputcomponent.h:27
nap::utility::ErrorState
Definition: errorstate.h:19
nap::audio::AudioComponentBaseInstance
Definition: audiocomponentbase.h:47
nap::audio::AudioComponentBase
Definition: audiocomponentbase.h:31
nap::audio::ControllerValue
float ControllerValue
Definition: audiotypes.h:113
nap::audio::SafeOwner
Definition: safeptr.h:25
nap::EntityInstance
Definition: entity.h:34
nap::audio::OutputPin
Definition: audiopin.h:204
nap::audio::AudioInputComponentInstance::AudioInputComponentInstance
AudioInputComponentInstance(EntityInstance &entity, Component &resource)
Definition: napaudio/src/audio/component/inputcomponent.h:52
nap::Component
Definition: component.h:151
nap::audio::AudioInputComponentInstance
Definition: napaudio/src/audio/component/inputcomponent.h:48
nap::audio::AudioInputComponentInstance::getChannelCount
int getChannelCount() const override
Definition: napaudio/src/audio/component/inputcomponent.h:60
nap
Definition: templateapp.h:17
nap::audio::AudioInputComponent::mChannels
std::vector< int > mChannels
property: 'Channels' Defines what audio input channels to receive data from. The size of this array d...
Definition: napaudio/src/audio/component/inputcomponent.h:36
nap::InputComponent
Definition: napinput/src/inputcomponent.h:22