Skip to content

Commit

Permalink
feat(arch): Refactored Amplitude architecture design.
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Nana <[email protected]>
  • Loading branch information
na2axl committed Jul 26, 2024
1 parent e912464 commit 262a1f2
Show file tree
Hide file tree
Showing 158 changed files with 5,391 additions and 2,662 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
- name: Setup vcpkg
uses: lukka/[email protected]
with:
vcpkgGitCommitId: f7423ee180c4b7f40d43402c2feb3859161ef625
vcpkgGitCommitId: 198d68dbcc6c907cb3d0b9b1d93c3df6ecf93c62

- name: Find flatc version
if: startsWith(matrix.config.os, 'ubuntu') || startsWith(matrix.config.os, 'macos')
Expand Down
29 changes: 25 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,18 @@ set(SA_SOURCE
include/SparkyStudios/Audio/Amplitude/IO/PackageItemFile.h
include/SparkyStudios/Audio/Amplitude/IO/PackageFileSystem.h
include/SparkyStudios/Audio/Amplitude/IO/Resource.h
include/SparkyStudios/Audio/Amplitude/Math/BarycentricCoordinates.h
include/SparkyStudios/Audio/Amplitude/Math/CartesianCoordinateSystem.h
include/SparkyStudios/Audio/Amplitude/Math/Curve.h
include/SparkyStudios/Audio/Amplitude/Math/FFT.h
include/SparkyStudios/Audio/Amplitude/Math/Geometry.h
include/SparkyStudios/Audio/Amplitude/Math/HandmadeMath.h
include/SparkyStudios/Audio/Amplitude/Math/Orientation.h
include/SparkyStudios/Audio/Amplitude/Math/Shape.h
include/SparkyStudios/Audio/Amplitude/Math/SphericalPosition.h
include/SparkyStudios/Audio/Amplitude/Math/SplitComplex.h
include/SparkyStudios/Audio/Amplitude/Math/Utils.h
include/SparkyStudios/Audio/Amplitude/Mixer/Amplimix.h
include/SparkyStudios/Audio/Amplitude/Mixer/Resampler.h
include/SparkyStudios/Audio/Amplitude/Mixer/SoundProcessor.h
include/SparkyStudios/Audio/Amplitude/Sound/Attenuation.h
Expand All @@ -187,7 +190,6 @@ set(SA_SOURCE
include/SparkyStudios/Audio/Amplitude/Sound/Fader.h
include/SparkyStudios/Audio/Amplitude/Sound/Filter.h
include/SparkyStudios/Audio/Amplitude/Sound/Rtpc.h
include/SparkyStudios/Audio/Amplitude/Sound/Scheduler.h
include/SparkyStudios/Audio/Amplitude/Sound/Sound.h
include/SparkyStudios/Audio/Amplitude/Sound/SoundBank.h
include/SparkyStudios/Audio/Amplitude/Sound/SoundObject.h
Expand Down Expand Up @@ -224,12 +226,14 @@ set(SA_SOURCE
src/Core/Playback/ChannelInternalState.h

src/Core/Asset.cpp
src/Core/Asset.h
src/Core/Codec.cpp
src/Core/Common.cpp
src/Core/DefaultPlugins.h
src/Core/Device.cpp
src/Core/Driver.cpp
src/Core/Engine.cpp
src/Core/Engine.h
src/Core/EngineInternalState.h
src/Core/Entity.cpp
src/Core/EntityInternalState.cpp
Expand All @@ -238,6 +242,7 @@ set(SA_SOURCE
src/Core/EnvironmentInternalState.cpp
src/Core/EnvironmentInternalState.h
src/Core/Event.cpp
src/Core/Event.h
src/Core/ListenerInternalState.cpp
src/Core/ListenerInternalState.h
src/Core/Listener.cpp
Expand All @@ -247,18 +252,23 @@ set(SA_SOURCE
src/Core/Version.cpp

src/HRTF/HRIRSphere.cpp
src/HRTF/HRIRSphere.h
src/IO/DiskFile.cpp
src/IO/DiskFileSystem.cpp
src/IO/File.cpp
src/IO/MemoryFile.cpp
src/IO/PackageItemFile.cpp
src/IO/PackageFileSystem.cpp
src/IO/Resource.cpp
src/IO/Resource.h

src/Math/BarycentricCoordinates.cpp
src/Math/CartesianCoordinateSystem.cpp
src/Math/Curve.cpp
src/Math/Orientation.cpp
src/Math/FaceBSPTree.cpp
src/Math/FaceBSPTree.h
src/Math/FFT.cpp
src/Math/Geometry.cpp
src/Math/Shape.cpp
src/Math/SphericalPosition.cpp
src/Math/SplitComplex.cpp
Expand All @@ -272,8 +282,8 @@ set(SA_SOURCE
src/Mixer/SoundProcessors/OcclusionProcessor.h
src/Mixer/SoundProcessors/PassThroughProcessor.h
src/Mixer/SoundProcessors/SilenceProcessor.h
src/Mixer/Mixer.cpp
src/Mixer/Mixer.h
src/Mixer/Amplimix.h
src/Mixer/Amplimix.cpp
src/Mixer/ProcessorPipeline.cpp
src/Mixer/ProcessorPipeline.h
src/Mixer/RealChannel.cpp
Expand Down Expand Up @@ -309,6 +319,8 @@ set(SA_SOURCE
src/Sound/Filters/FreeverbFilter.h
src/Sound/Filters/LofiFilter.cpp
src/Sound/Filters/LofiFilter.h
src/Sound/Filters/MonoPoleFilter.cpp
src/Sound/Filters/MonoPoleFilter.h
src/Sound/Filters/RobotizeFilter.cpp
src/Sound/Filters/RobotizeFilter.h
src/Sound/Filters/WaveShaperFilter.cpp
Expand All @@ -318,19 +330,28 @@ set(SA_SOURCE
src/Sound/Schedulers/SequenceScheduler.cpp
src/Sound/Schedulers/SequenceScheduler.h
src/Sound/Attenuation.cpp
src/Sound/Attenuation.h
src/Sound/AttenuationShapes.cpp
src/Sound/AttenuationShapes.h
src/Sound/Collection.cpp
src/Sound/Collection.h
src/Sound/Effect.cpp
src/Sound/Effect.h
src/Sound/Fader.cpp
src/Sound/Filter.cpp
src/Sound/RefCounter.cpp
src/Sound/Rtpc.cpp
src/Sound/Rtpc.h
src/Sound/Scheduler.h
src/Sound/Sound.cpp
src/Sound/Sound.h
src/Sound/SoundBank.cpp
src/Sound/SoundObject.cpp
src/Sound/SoundObject.h
src/Sound/Switch.cpp
src/Sound/Switch.h
src/Sound/SwitchContainer.cpp
src/Sound/SwitchContainer.h

src/Utils/Audio/Compression/ADPCM/ADPCM.cpp
src/Utils/Audio/Compression/ADPCM/ADPCM.h
Expand Down
10 changes: 6 additions & 4 deletions include/SparkyStudios/Audio/Amplitude/Amplitude.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#pragma once

#ifndef SS_AMPLITUDE_AUDIO_AMPLITUDE_H
#define SS_AMPLITUDE_AUDIO_AMPLITUDE_H
#ifndef _AM_AMPLITUDE_H
#define _AM_AMPLITUDE_H

#include <SparkyStudios/Audio/Amplitude/Core/Common.h>

Expand Down Expand Up @@ -48,16 +48,19 @@
#include <SparkyStudios/Audio/Amplitude/IO/PackageItemFile.h>
#include <SparkyStudios/Audio/Amplitude/IO/Resource.h>

#include <SparkyStudios/Audio/Amplitude/Math/BarycentricCoordinates.h>
#include <SparkyStudios/Audio/Amplitude/Math/CartesianCoordinateSystem.h>
#include <SparkyStudios/Audio/Amplitude/Math/Curve.h>
#include <SparkyStudios/Audio/Amplitude/Math/FFT.h>
#include <SparkyStudios/Audio/Amplitude/Math/Geometry.h>
#include <SparkyStudios/Audio/Amplitude/Math/HandmadeMath.h>
#include <SparkyStudios/Audio/Amplitude/Math/Orientation.h>
#include <SparkyStudios/Audio/Amplitude/Math/Shape.h>
#include <SparkyStudios/Audio/Amplitude/Math/SphericalPosition.h>
#include <SparkyStudios/Audio/Amplitude/Math/SplitComplex.h>
#include <SparkyStudios/Audio/Amplitude/Math/Utils.h>

#include <SparkyStudios/Audio/Amplitude/Mixer/Amplimix.h>
#include <SparkyStudios/Audio/Amplitude/Mixer/Resampler.h>
#include <SparkyStudios/Audio/Amplitude/Mixer/SoundProcessor.h>

Expand All @@ -67,11 +70,10 @@
#include <SparkyStudios/Audio/Amplitude/Sound/Fader.h>
#include <SparkyStudios/Audio/Amplitude/Sound/Filter.h>
#include <SparkyStudios/Audio/Amplitude/Sound/Rtpc.h>
#include <SparkyStudios/Audio/Amplitude/Sound/Scheduler.h>
#include <SparkyStudios/Audio/Amplitude/Sound/Sound.h>
#include <SparkyStudios/Audio/Amplitude/Sound/SoundBank.h>
#include <SparkyStudios/Audio/Amplitude/Sound/SoundObject.h>
#include <SparkyStudios/Audio/Amplitude/Sound/Switch.h>
#include <SparkyStudios/Audio/Amplitude/Sound/SwitchContainer.h>

#endif // SS_AMPLITUDE_AUDIO_AMPLITUDE_H
#endif // _AM_AMPLITUDE_H
25 changes: 19 additions & 6 deletions include/SparkyStudios/Audio/Amplitude/Convolution/Convolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@

#pragma once

#ifndef SS_AMPLITUDE_AUDIO_CONVOLUTION_CONVOLVER_H
#define SS_AMPLITUDE_AUDIO_CONVOLUTION_CONVOLVER_H
#ifndef _AM_CONVOLUTION_CONVOLVER_H
#define _AM_CONVOLUTION_CONVOLVER_H

#include <SparkyStudios/Audio/Amplitude/Core/Common.h>

#include <SparkyStudios/Audio/Amplitude/Math/FFT.h>

namespace SparkyStudios::Audio::Amplitude::Convolution
namespace SparkyStudios::Audio::Amplitude
{
/**
* @class Convolver
* @brief Implementation of a partitioned FFT convolution algorithm with uniform block size
*
* Some notes on how to use it:
Expand Down Expand Up @@ -79,6 +78,20 @@ namespace SparkyStudios::Audio::Amplitude::Convolution
*/
void Reset();

/**
* @brief Gets the size of a single convolution segment.
*
* @return The size of a single convolution segment.
*/
[[nodiscard]] AmSize GetSegmentSize() const;

/**
* @brief Gets the number of convolution segments.
*
* @return The number of convolution segments.
*/
[[nodiscard]] AmSize GetSegmentCount() const;

private:
AmSize _blockSize;
AmSize _segSize;
Expand All @@ -95,6 +108,6 @@ namespace SparkyStudios::Audio::Amplitude::Convolution
AmAlignedReal32Buffer _inputBuffer;
AmSize _inputBufferFill;
};
} // namespace SparkyStudios::Audio::Amplitude::Convolution
} // namespace SparkyStudios::Audio::Amplitude

#endif // SS_AMPLITUDE_AUDIO_CONVOLUTION_CONVOLVER_H
#endif // _AM_CONVOLUTION_CONVOLVER_H
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@

#pragma once

#ifndef SS_AMPLITUDE_AUDIO_CONVOLUTION_TWO_STAGE_CONVOLVER_H
#define SS_AMPLITUDE_AUDIO_CONVOLUTION_TWO_STAGE_CONVOLVER_H
#ifndef _AM_CONVOLUTION_TWO_STAGE_CONVOLVER
#define _AM_CONVOLUTION_TWO_STAGE_CONVOLVER

#include <SparkyStudios/Audio/Amplitude/Convolution/Convolver.h>

namespace SparkyStudios::Audio::Amplitude::Convolution
namespace SparkyStudios::Audio::Amplitude
{
/**
* @class TwoStageConvolver
* @brief FFT convolver using two different block sizes
*
* The 2-stage convolver consists internally of two convolvers:
Expand Down Expand Up @@ -67,7 +66,7 @@ namespace SparkyStudios::Audio::Amplitude::Convolution
*
* @return @c true on success, @c false otherwise.
*/
bool Init(size_t headBlockSize, size_t tailBlockSize, const AmAudioSample* ir, size_t irLen);
bool Init(AmSize headBlockSize, AmSize tailBlockSize, const AmAudioSample* ir, AmSize irLen);

/**
* @brief Convolves the the given input samples and immediately outputs the result
Expand All @@ -76,7 +75,7 @@ namespace SparkyStudios::Audio::Amplitude::Convolution
* @param output The convolution result
* @param len Number of input/output samples
*/
void Process(const AmAudioSample* input, AmAudioSample* output, size_t len);
void Process(const AmAudioSample* input, AmAudioSample* output, AmSize len);

/**
* @brief Resets the convolver and discards the set impulse response
Expand Down Expand Up @@ -107,8 +106,8 @@ namespace SparkyStudios::Audio::Amplitude::Convolution
void DoBackgroundProcessing();

private:
size_t _headBlockSize;
size_t _tailBlockSize;
AmSize _headBlockSize;
AmSize _tailBlockSize;
Convolver _headConvolver;
Convolver _tailConvolver0;
AmAlignedReal32Buffer _tailOutput0;
Expand All @@ -117,10 +116,10 @@ namespace SparkyStudios::Audio::Amplitude::Convolution
AmAlignedReal32Buffer _tailOutput;
AmAlignedReal32Buffer _tailPrecalculated;
AmAlignedReal32Buffer _tailInput;
size_t _tailInputFill;
size_t _precalculatedPos;
AmSize _tailInputFill;
AmSize _precalculatedPos;
AmAlignedReal32Buffer _backgroundProcessingInput;
};
} // namespace SparkyStudios::Audio::Amplitude::Convolution

#endif // SS_AMPLITUDE_AUDIO_CONVOLUTION_TWO_STAGE_CONVOLVER_H
#endif // _AM_CONVOLUTION_TWO_STAGE_CONVOLVER
Loading

0 comments on commit 262a1f2

Please sign in to comment.