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
AudioProcessor.h
Go to the documentation of this file.
1#pragma once
2#include "HephAudioShared.h"
3#include "AudioBuffer.h"
4#include "EchoInfo.h"
5#include "EqualizerInfo.h"
7#include "Windows/Window.h"
10#include <vector>
11
14namespace HephAudio
15{
21 {
22 private:
23 static constexpr size_t DEFAULT_HOP_SIZE = 1024u;
24 static constexpr size_t DEFAULT_FFT_SIZE = 4096u;
25
26 public:
27 AudioProcessor() = delete;
28 AudioProcessor(const AudioProcessor&) = delete;
29 AudioProcessor& operator=(const AudioProcessor&) = delete;
30#pragma region Converts, Mix, Split/Merge Channels
31 public:
36 static void ChangeChannelLayout(AudioBuffer& buffer, const AudioChannelLayout& outputChannelLayout);
37
42 static void ChangeSampleRate(AudioBuffer& buffer, uint32_t outputSampleRate);
43
48 static std::vector<Heph::DoubleBuffer> SplitChannels(const AudioBuffer& buffer);
49
54 static AudioBuffer MergeChannels(const std::vector<Heph::DoubleBuffer>& channels, uint32_t sampleRate);
55
61 static void ChangeEndian(AudioBuffer& buffer);
62#pragma endregion
63#pragma region Sound Effects
64 public:
70 static void Echo(AudioBuffer& buffer, EchoInfo info);
71
80 static void LinearPanning(AudioBuffer& buffer, double panningFactor);
81
90 static void SquareLawPanning(AudioBuffer& buffer, double panningFactor);
91
100 static void SineLawPanning(AudioBuffer& buffer, double panningFactor);
101
110 static void Tremolo(AudioBuffer& buffer, double depth, const Oscillator& lfo);
111
121 static void Vibrato(AudioBuffer& buffer, double depth, double extent_semitone, const Oscillator& lfo);
122
139 static void Chorus(AudioBuffer& buffer, double depth, double feedbackGain, double baseDelay_ms, double delay_ms, double extent_semitone, const Oscillator& lfo);
140
156 static void Flanger(AudioBuffer& buffer, double depth, double feedbackGain, double baseDelay_ms, double delay_ms, const Oscillator& lfo);
157
163 static void FixOverflow(AudioBuffer& buffer);
164
170 static void Normalize(AudioBuffer& buffer, heph_audio_sample_t peakAmplitude);
171
177 static void RmsNormalize(AudioBuffer& buffer, double rms);
178
185 static void HardClipDistortion(AudioBuffer& buffer, double clippingLevel_dB);
186
193 static void ArctanDistortion(AudioBuffer& buffer, double alpha);
194
201 static void CubicDistortion(AudioBuffer& buffer, double a);
202
209 static void Overdrive(AudioBuffer& buffer, double drive);
210
220 static void Fuzz(AudioBuffer& buffer, double depth, double alpha);
221
227 static void LinearFadeIn(AudioBuffer& buffer, double duration_s);
228
235 static void LinearFadeIn(AudioBuffer& buffer, double duration_s, size_t startIndex);
236
242 static void LinearFadeOut(AudioBuffer& buffer, double duration_s);
243
250 static void LinearFadeOut(AudioBuffer& buffer, double duration_s, size_t startIndex);
251
258 static void Equalizer(AudioBuffer& buffer, Window& window, const std::vector<EqualizerInfo>& infos);
259
268 static void Equalizer(AudioBuffer& buffer, size_t hopSize, size_t fftSize, Window& window, const std::vector<EqualizerInfo>& infos);
269
276 static void EqualizerMT(AudioBuffer& buffer, Window& window, const std::vector<EqualizerInfo>& infos);
277
285 static void EqualizerMT(AudioBuffer& buffer, size_t threadCountPerChannel, Window& window, const std::vector<EqualizerInfo>& infos);
286
295 static void EqualizerMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, Window& window, const std::vector<EqualizerInfo>& infos);
296
306 static void EqualizerMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, size_t threadCountPerChannel, Window& window, const std::vector<EqualizerInfo>& infos);
307
314 static void ChangeSpeed(AudioBuffer& buffer, double speed, Window& window);
315
324 static void ChangeSpeed(AudioBuffer& buffer, size_t hopSize, size_t windowSize, double speed, Window& window);
325
332 static void PitchShift(AudioBuffer& buffer, double pitchChange_semitone, Window& window);
333
341 static void PitchShift(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double pitchChange_semitone, Window& window);
342
349 static void PitchShiftMT(AudioBuffer& buffer, double pitchChange_semitone, Window& window);
350
358 static void PitchShiftMT(AudioBuffer& buffer, double pitchChange_semitone, size_t threadCountPerChannel, Window& window);
359
367 static void PitchShiftMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double pitchChange_semitone, Window& window);
368
377 static void PitchShiftMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double pitchChange_semitone, size_t threadCountPerChannel, Window& window);
378#pragma endregion
379#pragma region Filters
380 public:
387 static void LowPassFilter(AudioBuffer& buffer, double cutoffFreq, Window& window);
388
397 static void LowPassFilter(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double cutoffFreq, Window& window);
398
405 static void LowPassFilterMT(AudioBuffer& buffer, double cutoffFreq, Window& window);
406
415 static void LowPassFilterMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double cutoffFreq, Window& window);
416
424 static void LowPassFilterMT(AudioBuffer& buffer, double cutoffFreq, size_t threadCountPerChannel, Window& window);
425
435 static void LowPassFilterMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double cutoffFreq, size_t threadCountPerChannel, Window& window);
436
443 static void HighPassFilter(AudioBuffer& buffer, double cutoffFreq, Window& window);
444
453 static void HighPassFilter(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double cutoffFreq, Window& window);
454
461 static void HighPassFilterMT(AudioBuffer& buffer, double cutoffFreq, Window& window);
462
471 static void HighPassFilterMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double cutoffFreq, Window& window);
472
480 static void HighPassFilterMT(AudioBuffer& buffer, double cutoffFreq, size_t threadCountPerChannel, Window& window);
481
491 static void HighPassFilterMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double cutoffFreq, size_t threadCountPerChannel, Window& window);
492
500 static void BandPassFilter(AudioBuffer& buffer, double lowCutoffFreq, double highCutoffFreq, Window& window);
501
511 static void BandPassFilter(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, Window& window);
512
520 static void BandPassFilterMT(AudioBuffer& buffer, double lowCutoffFreq, double highCutoffFreq, Window& window);
521
531 static void BandPassFilterMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, Window& window);
532
541 static void BandPassFilterMT(AudioBuffer& buffer, double lowCutoffFreq, double highCutoffFreq, size_t threadCountPerChannel, Window& window);
542
553 static void BandPassFilterMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, size_t threadCountPerChannel, Window& window);
554
562 static void BandCutFilter(AudioBuffer& buffer, double lowCutoffFreq, double highCutoffFreq, Window& window);
563
573 static void BandCutFilter(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, Window& window);
574
582 static void BandCutFilterMT(AudioBuffer& buffer, double lowCutoffFreq, double highCutoffFreq, Window& window);
583
593 static void BandCutFilterMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, Window& window);
594
603 static void BandCutFilterMT(AudioBuffer& buffer, double lowCutoffFreq, double highCutoffFreq, size_t threadCountPerChannel, Window& window);
604
615 static void BandCutFilterMT(AudioBuffer& buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, size_t threadCountPerChannel, Window& window);
616#pragma endregion
617 };
618}
float heph_audio_sample_t
Definition HephAudioShared.h:133
#define HEPH_API
Definition HephShared.h:132
class for storing the audio samples in internal format.
Definition AudioBuffer.h:16
provides sound effects and filters.
Definition AudioProcessor.h:21
static void BandCutFilterMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, size_t threadCountPerChannel, Window &window)
static void ChangeSpeed(AudioBuffer &buffer, double speed, Window &window)
static void LowPassFilterMT(AudioBuffer &buffer, double cutoffFreq, size_t threadCountPerChannel, Window &window)
static void Chorus(AudioBuffer &buffer, double depth, double feedbackGain, double baseDelay_ms, double delay_ms, double extent_semitone, const Oscillator &lfo)
static void EqualizerMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, Window &window, const std::vector< EqualizerInfo > &infos)
static void HighPassFilter(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double cutoffFreq, Window &window)
static void Normalize(AudioBuffer &buffer, heph_audio_sample_t peakAmplitude)
static std::vector< Heph::DoubleBuffer > SplitChannels(const AudioBuffer &buffer)
static void ChangeChannelLayout(AudioBuffer &buffer, const AudioChannelLayout &outputChannelLayout)
static void BandPassFilter(AudioBuffer &buffer, double lowCutoffFreq, double highCutoffFreq, Window &window)
static void HighPassFilterMT(AudioBuffer &buffer, double cutoffFreq, size_t threadCountPerChannel, Window &window)
static void EqualizerMT(AudioBuffer &buffer, size_t threadCountPerChannel, Window &window, const std::vector< EqualizerInfo > &infos)
static void LinearFadeIn(AudioBuffer &buffer, double duration_s, size_t startIndex)
static void ChangeSampleRate(AudioBuffer &buffer, uint32_t outputSampleRate)
static void PitchShiftMT(AudioBuffer &buffer, double pitchChange_semitone, Window &window)
static void LowPassFilterMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double cutoffFreq, size_t threadCountPerChannel, Window &window)
static void Equalizer(AudioBuffer &buffer, Window &window, const std::vector< EqualizerInfo > &infos)
static void LowPassFilter(AudioBuffer &buffer, double cutoffFreq, Window &window)
static void Tremolo(AudioBuffer &buffer, double depth, const Oscillator &lfo)
static void BandCutFilter(AudioBuffer &buffer, double lowCutoffFreq, double highCutoffFreq, Window &window)
static void Vibrato(AudioBuffer &buffer, double depth, double extent_semitone, const Oscillator &lfo)
static void Equalizer(AudioBuffer &buffer, size_t hopSize, size_t fftSize, Window &window, const std::vector< EqualizerInfo > &infos)
static void CubicDistortion(AudioBuffer &buffer, double a)
static void LinearPanning(AudioBuffer &buffer, double panningFactor)
static void Echo(AudioBuffer &buffer, EchoInfo info)
static void LowPassFilterMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double cutoffFreq, Window &window)
static void HighPassFilterMT(AudioBuffer &buffer, double cutoffFreq, Window &window)
static void EqualizerMT(AudioBuffer &buffer, Window &window, const std::vector< EqualizerInfo > &infos)
static void BandPassFilterMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, Window &window)
static void HighPassFilterMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double cutoffFreq, size_t threadCountPerChannel, Window &window)
static void Overdrive(AudioBuffer &buffer, double drive)
static void BandCutFilter(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, Window &window)
static void RmsNormalize(AudioBuffer &buffer, double rms)
static void PitchShiftMT(AudioBuffer &buffer, double pitchChange_semitone, size_t threadCountPerChannel, Window &window)
static void BandPassFilterMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, size_t threadCountPerChannel, Window &window)
static void LowPassFilterMT(AudioBuffer &buffer, double cutoffFreq, Window &window)
static void BandCutFilterMT(AudioBuffer &buffer, double lowCutoffFreq, double highCutoffFreq, size_t threadCountPerChannel, Window &window)
static void BandPassFilterMT(AudioBuffer &buffer, double lowCutoffFreq, double highCutoffFreq, Window &window)
static void EqualizerMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, size_t threadCountPerChannel, Window &window, const std::vector< EqualizerInfo > &infos)
static void BandCutFilterMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, Window &window)
static void BandPassFilterMT(AudioBuffer &buffer, double lowCutoffFreq, double highCutoffFreq, size_t threadCountPerChannel, Window &window)
static void HighPassFilterMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double cutoffFreq, Window &window)
static void Flanger(AudioBuffer &buffer, double depth, double feedbackGain, double baseDelay_ms, double delay_ms, const Oscillator &lfo)
static void LinearFadeIn(AudioBuffer &buffer, double duration_s)
static void BandCutFilterMT(AudioBuffer &buffer, double lowCutoffFreq, double highCutoffFreq, Window &window)
static void LowPassFilter(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double cutoffFreq, Window &window)
static void PitchShiftMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double pitchChange_semitone, Window &window)
static void SquareLawPanning(AudioBuffer &buffer, double panningFactor)
static void SineLawPanning(AudioBuffer &buffer, double panningFactor)
static void BandPassFilter(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double lowCutoffFreq, double highCutoffFreq, Window &window)
static void Fuzz(AudioBuffer &buffer, double depth, double alpha)
static void PitchShiftMT(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double pitchChange_semitone, size_t threadCountPerChannel, Window &window)
static void FixOverflow(AudioBuffer &buffer)
static void ChangeSpeed(AudioBuffer &buffer, size_t hopSize, size_t windowSize, double speed, Window &window)
static void HighPassFilter(AudioBuffer &buffer, double cutoffFreq, Window &window)
static void LinearFadeOut(AudioBuffer &buffer, double duration_s, size_t startIndex)
static void LinearFadeOut(AudioBuffer &buffer, double duration_s)
static void ChangeEndian(AudioBuffer &buffer)
static void PitchShift(AudioBuffer &buffer, size_t hopSize, size_t fftSize, double pitchChange_semitone, Window &window)
static void HardClipDistortion(AudioBuffer &buffer, double clippingLevel_dB)
static void ArctanDistortion(AudioBuffer &buffer, double alpha)
static void PitchShift(AudioBuffer &buffer, double pitchChange_semitone, Window &window)
static AudioBuffer MergeChannels(const std::vector< Heph::DoubleBuffer > &channels, uint32_t sampleRate)
base class for oscillators.
Definition Oscillator.h:16
base class for windows.
Definition Window.h:14
stores information about the channel layout.
Definition AudioChannelLayout.h:136
container for echo effect parameters.
Definition EchoInfo.h:15