HephAudio v3.1.0
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
Spatializer.h
Go to the documentation of this file.
1#pragma once
2#include "HephAudioShared.h"
5#include <filesystem>
6#include <mysofa.h>
7#include <array>
8
15#define HEPHAUDIO_SPATIALIZER_AZIMUTH_MIN (0)
16
21#define HEPHAUDIO_SPATIALIZER_AZIMUTH_MAX (360)
22
27#define HEPHAUDIO_SPATIALIZER_ELEVATION_MIN (-90)
28
33#define HEPHAUDIO_SPATIALIZER_ELEVATION_MAX (90)
34
35namespace HephAudio
36{
42 {
43 public:
44 using FrequencyDomainEffect::Process;
45
46 protected:
51 float azimuth;
52
57 float elevation;
58
63 std::filesystem::path filePath;
64
69 MYSOFA_EASY* pEasy;
70
75 size_t hrtfSize;
76
82
88
93 std::array<Heph::ComplexBuffer, 2> transferFunctions;
94
95 public:
98
100 Spatializer(size_t hopSize, const Window& wnd);
101
111 Spatializer(float azimuth, float elevation, size_t hopSize, const Window& wnd);
112
124 Spatializer(const std::filesystem::path& filePath, uint32_t sampleRate, float azimuth, float elevation, size_t hopSize, const Window& wnd);
125
127 virtual ~Spatializer();
128
129 virtual std::string Name() const override;
130 virtual void Process(AudioBuffer& buffer, size_t startIndex, size_t frameCount) override;
131 virtual void SetWindow(const Window& wnd) override;
132
139 virtual void OpenSofaFile(const std::filesystem::path& filePath);
140
145 virtual void CloseSofaFile();
146
151 virtual float GetAzimuth() const;
152
159 virtual void SetAzimuth(float azimuth);
160
165 virtual float GetElevation() const;
166
173 virtual void SetElevation(float elevation);
174
179 virtual uint32_t GetSampleRate() const;
180
187 virtual void SetSampleRate(uint32_t sampleRate);
188
193 virtual size_t GetHrtfSize() const;
194
195 protected:
196 virtual void ProcessST(const AudioBuffer& inputBuffer, AudioBuffer& outputBuffer, size_t startIndex, size_t frameCount) override;
197
202 virtual void OpenDefaultFile();
203
210 virtual std::string GetErrorString(int errorCode) const;
211 };
212}
#define HEPH_API
Definition HephShared.h:124
class for storing the audio samples in internal format.
Definition AudioBuffer.h:16
base class for effects that are computed in the frequency domain.
Definition FrequencyDomainEffect.h:16
applies 3D audio spatialization using SOFA files.
Definition Spatializer.h:42
std::filesystem::path filePath
Definition Spatializer.h:63
virtual void Process(AudioBuffer &buffer, size_t startIndex, size_t frameCount) override
virtual void CloseSofaFile()
size_t hrtfSize
Definition Spatializer.h:75
std::array< Heph::ComplexBuffer, 2 > transferFunctions
Definition Spatializer.h:93
float azimuth
Definition Spatializer.h:51
virtual void OpenSofaFile(const std::filesystem::path &filePath)
virtual void SetAzimuth(float azimuth)
virtual void SetSampleRate(uint32_t sampleRate)
float elevation
Definition Spatializer.h:57
virtual std::string Name() const override
Spatializer(const std::filesystem::path &filePath, uint32_t sampleRate, float azimuth, float elevation, size_t hopSize, const Window &wnd)
bool updateTransferFunctions
Definition Spatializer.h:87
virtual void ProcessST(const AudioBuffer &inputBuffer, AudioBuffer &outputBuffer, size_t startIndex, size_t frameCount) override
virtual void OpenDefaultFile()
uint32_t hrtfSampleRate
Definition Spatializer.h:81
virtual void SetWindow(const Window &wnd) override
Spatializer(float azimuth, float elevation, size_t hopSize, const Window &wnd)
virtual uint32_t GetSampleRate() const
MYSOFA_EASY * pEasy
Definition Spatializer.h:69
virtual float GetAzimuth() const
virtual void SetElevation(float elevation)
virtual size_t GetHrtfSize() const
virtual std::string GetErrorString(int errorCode) const
gets the error message that corresponds to the provided code.
virtual float GetElevation() const
Spatializer(size_t hopSize, const Window &wnd)
base class for windows.
Definition Window.h:14