Skip to content

Commit

Permalink
feat(amplimix): Add methods to describe a pipeline node.
Browse files Browse the repository at this point in the history
These methods are mostly used by the studio app, to know how to handle and render them in the pipeline editor.
  • Loading branch information
na2axl committed Nov 3, 2024
1 parent afe344f commit 16e10f3
Show file tree
Hide file tree
Showing 26 changed files with 517 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,16 @@ set(SA_SOURCE
src/Mixer/Nodes/ClipNode.h
src/Mixer/Nodes/EnvironmentEffectNode.cpp
src/Mixer/Nodes/EnvironmentEffectNode.h
src/Mixer/Nodes/InputNode.cpp
src/Mixer/Nodes/InputNode.h
src/Mixer/Nodes/NearFieldEffectNode.cpp
src/Mixer/Nodes/NearFieldEffectNode.h
src/Mixer/Nodes/ObstructionNode.cpp
src/Mixer/Nodes/ObstructionNode.h
src/Mixer/Nodes/OcclusionNode.cpp
src/Mixer/Nodes/OcclusionNode.h
src/Mixer/Nodes/OutputNode.cpp
src/Mixer/Nodes/OutputNode.h
src/Mixer/Nodes/ReflectionsNode.cpp
src/Mixer/Nodes/ReflectionsNode.h
src/Mixer/Nodes/ReverbNode.cpp
Expand Down
28 changes: 28 additions & 0 deletions include/SparkyStudios/Audio/Amplitude/Mixer/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,34 @@ namespace SparkyStudios::Audio::Amplitude
*/
[[nodiscard]] const AmString& GetName() const;

/**
* @brief Returns `true` if the node can consume audio data.
*
* @return `true` if the node can consume audio data, `false` otherwise.
*/
[[nodiscard]] virtual bool CanConsume() const = 0;

/**
* @brief Returns `true` if the node can produce audio data.
*
* @return `true` if the node can produce audio data, `false` otherwise.
*/
[[nodiscard]] virtual bool CanProduce() const = 0;

/**
* @brief Returns the maximum number of input connections the node can have.
*
* @return The maximum number of input connections the node can have.
*/
[[nodiscard]] virtual AmSize GetMaxInputCount() const = 0;

/**
* @brief Returns the minimum number of input connections the node can have.
*
* @return The minimum number of input connections the node can have.
*/
[[nodiscard]] virtual AmSize GetMinInputCount() const = 0;

/**
* @brief Registers a new node.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Core/DefaultPlugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@
#include <Mixer/Nodes/ClampNode.h>
#include <Mixer/Nodes/ClipNode.h>
#include <Mixer/Nodes/EnvironmentEffectNode.h>
#include <Mixer/Nodes/InputNode.h>
#include <Mixer/Nodes/NearFieldEffectNode.h>
#include <Mixer/Nodes/ObstructionNode.h>
#include <Mixer/Nodes/OcclusionNode.h>
#include <Mixer/Nodes/OutputNode.h>
#include <Mixer/Nodes/ReflectionsNode.h>
#include <Mixer/Nodes/ReverbNode.h>
#include <Mixer/Nodes/StereoMixerNode.h>
Expand Down
6 changes: 6 additions & 0 deletions src/Core/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ namespace SparkyStudios::Audio::Amplitude
static AmUniquePtr<eMemoryPoolKind_Engine, ClampNode> sClampNodePlugin = nullptr;
static AmUniquePtr<eMemoryPoolKind_Engine, ClipNode> sClipNodePlugin = nullptr;
static AmUniquePtr<eMemoryPoolKind_Engine, EnvironmentEffectNode> sEnvironmentEffectNodePlugin = nullptr;
static AmUniquePtr<eMemoryPoolKind_Engine, InputNode> sInputNodePlugin = nullptr;
static AmUniquePtr<eMemoryPoolKind_Engine, NearFieldEffectNode> sNearFieldEffectNodePlugin = nullptr;
static AmUniquePtr<eMemoryPoolKind_Engine, ObstructionNode> sObstructionNodePlugin = nullptr;
static AmUniquePtr<eMemoryPoolKind_Engine, OcclusionNode> sOcclusionNodePlugin = nullptr;
static AmUniquePtr<eMemoryPoolKind_Engine, OutputNode> sOutputNodePlugin = nullptr;
static AmUniquePtr<eMemoryPoolKind_Engine, ReflectionsNode> sReflectionsNodePlugin = nullptr;
static AmUniquePtr<eMemoryPoolKind_Engine, ReverbNode> sReverbNodePlugin = nullptr;
static AmUniquePtr<eMemoryPoolKind_Engine, StereoMixerNode> sStereoMixerNodePlugin = nullptr;
Expand Down Expand Up @@ -385,9 +387,11 @@ namespace SparkyStudios::Audio::Amplitude
sClampNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, ClampNode));
sClipNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, ClipNode));
sEnvironmentEffectNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, EnvironmentEffectNode));
sInputNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, InputNode));
sNearFieldEffectNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, NearFieldEffectNode));
sObstructionNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, ObstructionNode));
sOcclusionNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, OcclusionNode));
sOutputNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, OutputNode));
sReflectionsNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, ReflectionsNode));
sReverbNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, ReverbNode));
sStereoMixerNodePlugin.reset(ampoolnew(eMemoryPoolKind_Engine, StereoMixerNode));
Expand Down Expand Up @@ -441,9 +445,11 @@ namespace SparkyStudios::Audio::Amplitude
sClampNodePlugin.reset(nullptr);
sClipNodePlugin.reset(nullptr);
sEnvironmentEffectNodePlugin.reset(nullptr);
sInputNodePlugin.reset(nullptr);
sNearFieldEffectNodePlugin.reset(nullptr);
sObstructionNodePlugin.reset(nullptr);
sOcclusionNodePlugin.reset(nullptr);
sOutputNodePlugin.reset(nullptr);
sReflectionsNodePlugin.reset(nullptr);
sReverbNodePlugin.reset(nullptr);
sStereoMixerNodePlugin.reset(nullptr);
Expand Down
22 changes: 21 additions & 1 deletion src/Mixer/Nodes/AmbisonicBinauralDecoderNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,30 @@ namespace SparkyStudios::Audio::Amplitude
return ampoolnew(eMemoryPoolKind_Amplimix, AmbisonicBinauralDecoderNodeInstance);
}

void DestroyInstance(NodeInstance* instance) const override
AM_INLINE void DestroyInstance(NodeInstance* instance) const override
{
ampooldelete(eMemoryPoolKind_Amplimix, AmbisonicBinauralDecoderNodeInstance, (AmbisonicBinauralDecoderNodeInstance*)instance);
}

[[nodiscard]] AM_INLINE bool CanConsume() const override
{
return true;
}

[[nodiscard]] AM_INLINE bool CanProduce() const override
{
return true;
}

[[nodiscard]] AM_INLINE AmSize GetMaxInputCount() const override
{
return 1;
}

[[nodiscard]] AM_INLINE AmSize GetMinInputCount() const override
{
return 1;
}
};
} // namespace SparkyStudios::Audio::Amplitude

Expand Down
5 changes: 0 additions & 5 deletions src/Mixer/Nodes/AmbisonicMixerNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <SparkyStudios/Audio/Amplitude/Core/Memory.h>
#include <SparkyStudios/Audio/Amplitude/Mixer/Amplimix.h>

#include <Core/EngineInternalState.h>
#include <Mixer/Nodes/AmbisonicMixerNode.h>
#include <Utils/Utils.h>

namespace SparkyStudios::Audio::Amplitude
{
Expand Down
20 changes: 20 additions & 0 deletions src/Mixer/Nodes/AmbisonicMixerNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ namespace SparkyStudios::Audio::Amplitude
{
ampooldelete(eMemoryPoolKind_Amplimix, MixerNodeInstance, (MixerNodeInstance*)instance);
}

[[nodiscard]] AM_INLINE bool CanConsume() const override
{
return true;
}

[[nodiscard]] AM_INLINE bool CanProduce() const override
{
return true;
}

[[nodiscard]] AM_INLINE AmSize GetMaxInputCount() const override
{
return -1;
}

[[nodiscard]] AM_INLINE AmSize GetMinInputCount() const override
{
return 1;
}
};
} // namespace SparkyStudios::Audio::Amplitude

Expand Down
20 changes: 20 additions & 0 deletions src/Mixer/Nodes/AmbisonicPanningNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ namespace SparkyStudios::Audio::Amplitude
{
ampooldelete(eMemoryPoolKind_Amplimix, AmbisonicPanningNodeInstance, (AmbisonicPanningNodeInstance*)instance);
}

[[nodiscard]] AM_INLINE bool CanConsume() const override
{
return true;
}

[[nodiscard]] AM_INLINE bool CanProduce() const override
{
return true;
}

[[nodiscard]] AM_INLINE AmSize GetMaxInputCount() const override
{
return 1;
}

[[nodiscard]] AM_INLINE AmSize GetMinInputCount() const override
{
return 1;
}
};
} // namespace SparkyStudios::Audio::Amplitude

Expand Down
22 changes: 21 additions & 1 deletion src/Mixer/Nodes/AmbisonicRotatorNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,30 @@ namespace SparkyStudios::Audio::Amplitude
return ampoolnew(eMemoryPoolKind_Amplimix, AmbisonicRotatorNodeInstance);
}

void DestroyInstance(NodeInstance* instance) const override
AM_INLINE void DestroyInstance(NodeInstance* instance) const override
{
ampooldelete(eMemoryPoolKind_Amplimix, AmbisonicRotatorNodeInstance, (AmbisonicRotatorNodeInstance*)instance);
}

[[nodiscard]] AM_INLINE bool CanConsume() const override
{
return true;
}

[[nodiscard]] AM_INLINE bool CanProduce() const override
{
return true;
}

[[nodiscard]] AM_INLINE AmSize GetMaxInputCount() const override
{
return 1;
}

[[nodiscard]] AM_INLINE AmSize GetMinInputCount() const override
{
return 1;
}
};
} // namespace SparkyStudios::Audio::Amplitude

Expand Down
20 changes: 20 additions & 0 deletions src/Mixer/Nodes/AttenuationNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ namespace SparkyStudios::Audio::Amplitude
{
ampooldelete(eMemoryPoolKind_Amplimix, AttenuationNodeInstance, (AttenuationNodeInstance*)instance);
}

[[nodiscard]] AM_INLINE bool CanConsume() const override
{
return true;
}

[[nodiscard]] AM_INLINE bool CanProduce() const override
{
return true;
}

[[nodiscard]] AM_INLINE AmSize GetMaxInputCount() const override
{
return 1;
}

[[nodiscard]] AM_INLINE AmSize GetMinInputCount() const override
{
return 1;
}
};
} // namespace SparkyStudios::Audio::Amplitude

Expand Down
22 changes: 21 additions & 1 deletion src/Mixer/Nodes/ClampNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,30 @@ namespace SparkyStudios::Audio::Amplitude
return ampoolnew(eMemoryPoolKind_Amplimix, ClampNodeInstance);
}

void DestroyInstance(NodeInstance* instance) const override
AM_INLINE void DestroyInstance(NodeInstance* instance) const override
{
ampooldelete(eMemoryPoolKind_Amplimix, ClampNodeInstance, (ClampNodeInstance*)instance);
}

[[nodiscard]] AM_INLINE bool CanConsume() const override
{
return true;
}

[[nodiscard]] AM_INLINE bool CanProduce() const override
{
return true;
}

[[nodiscard]] AM_INLINE AmSize GetMaxInputCount() const override
{
return 1;
}

[[nodiscard]] AM_INLINE AmSize GetMinInputCount() const override
{
return 1;
}
};
} // namespace SparkyStudios::Audio::Amplitude

Expand Down
22 changes: 21 additions & 1 deletion src/Mixer/Nodes/ClipNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,30 @@ namespace SparkyStudios::Audio::Amplitude
return ampoolnew(eMemoryPoolKind_Amplimix, ClipNodeInstance);
}

void DestroyInstance(NodeInstance* instance) const override
AM_INLINE void DestroyInstance(NodeInstance* instance) const override
{
ampooldelete(eMemoryPoolKind_Amplimix, ClipNodeInstance, (ClipNodeInstance*)instance);
}

[[nodiscard]] AM_INLINE bool CanConsume() const override
{
return true;
}

[[nodiscard]] AM_INLINE bool CanProduce() const override
{
return true;
}

[[nodiscard]] AM_INLINE AmSize GetMaxInputCount() const override
{
return 1;
}

[[nodiscard]] AM_INLINE AmSize GetMinInputCount() const override
{
return 1;
}
};
} // namespace SparkyStudios::Audio::Amplitude

Expand Down
22 changes: 21 additions & 1 deletion src/Mixer/Nodes/EnvironmentEffectNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,30 @@ namespace SparkyStudios::Audio::Amplitude
return ampoolnew(eMemoryPoolKind_Amplimix, EnvironmentEffectNodeInstance);
}

void DestroyInstance(NodeInstance* instance) const override
AM_INLINE void DestroyInstance(NodeInstance* instance) const override
{
ampooldelete(eMemoryPoolKind_Amplimix, EnvironmentEffectNodeInstance, (EnvironmentEffectNodeInstance*)instance);
}

[[nodiscard]] AM_INLINE bool CanConsume() const override
{
return true;
}

[[nodiscard]] AM_INLINE bool CanProduce() const override
{
return true;
}

[[nodiscard]] AM_INLINE AmSize GetMaxInputCount() const override
{
return 1;
}

[[nodiscard]] AM_INLINE AmSize GetMinInputCount() const override
{
return 1;
}
};
} // namespace SparkyStudios::Audio::Amplitude

Expand Down
22 changes: 22 additions & 0 deletions src/Mixer/Nodes/InputNode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2024-present Sparky Studios. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <Mixer/Nodes/InputNode.h>

namespace SparkyStudios::Audio::Amplitude
{
InputNode::InputNode()
: Node("Input")
{}
} // namespace SparkyStudios::Audio::Amplitude
Loading

0 comments on commit 16e10f3

Please sign in to comment.