Switchboard Extension SDK
Loading...
Searching...
No Matches
AudioGraphResampler.hpp
1//
2// AudioGraphResampler.hpp
3// SwitchboardSDK
4//
5// Created by Balazs Kiss on 2025. 04. 15..
6//
7
8#pragma once
9
10#include <audio/ResamplingFIFO.hpp>
11#include <buffer/AudioData.hpp>
12#include <functional>
13#include <memory>
14#include <switchboard/export.h>
15#include <switchboard_core/AudioBusList.hpp>
16
17namespace switchboard {
18
23class SWITCHBOARDSDK_EXPORT AudioGraphResampler {
24public:
33 using ProcessCallback = std::function<bool(AudioBusList& inAudioBuses, AudioBusList& outAudioBuses)>;
34
41 AudioGraphResampler(int sampleRate, int bufferSize);
42
47
54
63 bool setNumberOfBuses(const uint numberOfInputBuses, const uint numberOfOutputBuses);
64
73 bool process(AudioBusList& inAudioBuses, AudioBusList& outAudioBuses);
74
75private:
76 ProcessCallback processCallback;
77 int sampleRate;
78 int bufferSize;
79 int numberOfInputBuses;
80 int numberOfOutputBuses;
81 std::unique_ptr<audio::ResamplingFIFO> inputResamplingFIFO;
82 std::unique_ptr<audio::ResamplingFIFO> outputResamplingFIFO;
83 buffer::AudioData<float> interleavedData;
84 buffer::AudioData<float> callbackInAudioData;
85 buffer::AudioData<float> callbackOutAudioData;
86
87 bool callProcessCallback(AudioBuffer<float>* inBuffer, AudioBuffer<float>* outBuffer);
88 void configureResamplers(AudioBuffer<float>* inBuffer, AudioBuffer<float>* outBuffer);
89 bool process(AudioBuffer<float>* inBuffer, AudioBuffer<float>* outBuffer);
90 void pushInputBufferToResampler(AudioBuffer<float>& buffer);
91 void popInputBufferFromResampler(AudioBuffer<float>& buffer);
92 void pushOutputBufferToResampler(AudioBuffer<float>& buffer);
93 void popOutputBufferFromResampler(AudioBuffer<float>& buffer);
94};
95
96}
Provides an abstraction around raw audio buffers stored in memory.
Definition AudioBuffer.hpp:22
AudioGraphResampler(int sampleRate, int bufferSize)
Constructor for AudioGraphResampler.
void setProcessCallback(ProcessCallback callback)
Sets the process callback function.
bool process(AudioBusList &inAudioBuses, AudioBusList &outAudioBuses)
Processes the audio data.
bool setNumberOfBuses(const uint numberOfInputBuses, const uint numberOfOutputBuses)
Sets the number of input and output buses.
~AudioGraphResampler()
Destructor for AudioGraphResampler.
std::function< bool(AudioBusList &inAudioBuses, AudioBusList &outAudioBuses)> ProcessCallback
Callback function type for processing audio data.
Definition AudioGraphResampler.hpp:33
Holds a list of AudioBus instances.
Definition AudioBusList.hpp:25