HephAudio v3.0.6
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"
3#include "AudioBuffer.h"
5#include <mysofa.h>
6#include <string>
7#include <vector>
8#include <filesystem>
9
16#define HEPHAUDIO_SPATIALIZER_AZIMUTH_MIN 0
17
22#define HEPHAUDIO_SPATIALIZER_AZIMUTH_MAX 360
23
28#define HEPHAUDIO_SPATIALIZER_ELEVATION_MIN -90
29
34#define HEPHAUDIO_SPATIALIZER_ELEVATION_MAX 90
35
36namespace HephAudio
37{
43 {
44 private:
45 MYSOFA_EASY* pEasy;
46 size_t frameCount;
47 uint32_t sampleRate;
48
49 public:
51 Spatializer(const std::filesystem::path& sofaFilePath, uint32_t sampleRate);
52 Spatializer(const Spatializer&) = delete;
53 Spatializer(Spatializer&& rhs) noexcept;
55 Spatializer& operator=(const Spatializer&) = delete;
56 Spatializer& operator=(Spatializer&& rhs) noexcept;
57
62 uint32_t GetSampleRate() const;
63
68 size_t GetFrameCount() const;
69
75 void OpenSofaFile(const std::filesystem::path& sofaFilePath, uint32_t sampleRate);
76
82
93 void Process(AudioBuffer& buffer, float azimuth_deg, float elevation_deg);
94
108 void Process(AudioBuffer& buffer, float azimuth_deg, float elevation_deg, const Heph::DoubleBuffer& windowBuffer);
109
110 private:
111 static std::string GetErrorString(int errorCode);
112 };
113}
#define HEPH_API
Definition HephShared.h:132
class for storing the audio samples in internal format.
Definition AudioBuffer.h:16
implements reading the SOFA files and HRTF interpolation for spatialization.
Definition Spatializer.h:43
void Process(AudioBuffer &buffer, float azimuth_deg, float elevation_deg, const Heph::DoubleBuffer &windowBuffer)
size_t GetFrameCount() const
void OpenSofaFile(const std::filesystem::path &sofaFilePath, uint32_t sampleRate)
uint32_t GetSampleRate() const
void Process(AudioBuffer &buffer, float azimuth_deg, float elevation_deg)
buffer for storing doubles.
Definition DoubleBuffer.h:14