-
Notifications
You must be signed in to change notification settings - Fork 2
/
audio_engine.h
77 lines (57 loc) · 2.4 KB
/
audio_engine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
==============================================================================
AudioEngine.h
Created: 1 Sep 2021 6:24:22pm
Author: Thomas Hézard
==============================================================================
*/
#pragma once
#include "audio_processor.h"
class AudioEngine {
public:
// =========================================
// CONSTRUCTOR & DESTRUCTOR
/// Constructor
AudioEngine();
/// Default destructor
~AudioEngine() = default;
// =========================================
// AUDIO LIFE CYCLE
/// Prepare resources
/// Inform audio modules of samples per block and sample rate values,
/// so that they can prepare (allocate buffers etc.) their resources
/// to get ready to generate/process audio data.
/// @param maxSamplesPerBlock Max value of `numSamples` in a `generateAudioData` call.
/// @param sampleRate Sample rate of audio data.
void prepareResources(int maxSamplesPerBlock, double sampleRate);
/// Release resources
/// Inform audio modules that they can release their resources before
/// the app terminates or before a change in sample rate or samples
/// per block values.
void releaseResources();
/// Process a block of audio data.
/// @param ioAudioData Audio buffer to process, 2D array of size [numChannels, numSamples].
/// @param inputNumChannels Number of input channels.
/// @param outputNumChannels Number of output channels.
/// @param numSamples Number of samples in each channel.
void processAudioData(float*const* ioAudioData,
int inputNumChannels,
int outputNumChannels,
int numSamples);
// =========================================
// CONTROLS
/// Set the parameter A
/// @param parameter New value of the parameter.
void setParameterA(float parameter);
/// Return the value of the parameter A
float getParameterA() const;
/// Set the parameter B
/// @param parameter New value of the parameter.
void setParameterB(float parameter);
/// Return the value of the parameter B
float getParameterB() const;
private:
AudioProcessor audio_processor_;
float parameter_a_;
float parameter_b_;
};