-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathAudioMixer_F32.h
69 lines (56 loc) · 1.86 KB
/
AudioMixer_F32.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
/*
* AudioMixer
*
* AudioMixer4
* Created: Patrick Radius, December 2016
* Purpose: Mix up to 4 audio channels with individual gain controls.
* Assumes floating-point data.
*
* This processes a single stream fo audio data (ie, it is mono)
*
* Extended to AudioMixer8
* By: Chip Audette, OpenAudio, Feb 2017
*
* MIT License. use at your own risk.
*/
#ifndef AUDIOMIXER_F32_H
#define AUDIOMIXER_F32_H
#include <arm_math.h>
#include <AudioStream_F32.h>
class AudioMixer4_F32 : public AudioStream_F32 {
//GUI: inputs:4, outputs:1 //this line used for automatic generation of GUI node
//GUI: shortName:Mixer4
public:
AudioMixer4_F32() : AudioStream_F32(4, inputQueueArray) { setDefaultValues(); }
AudioMixer4_F32(const AudioSettings_F32 &settings) : AudioStream_F32(4, inputQueueArray) { setDefaultValues(); }
void setDefaultValues(void) {
for (int i=0; i<4; i++) multiplier[i] = 1.0;
}
virtual void update(void);
void gain(unsigned int channel, float gain) {
if (channel >= 4 || channel < 0) return;
multiplier[channel] = gain;
}
private:
audio_block_f32_t *inputQueueArray[4];
float multiplier[4];
};
class AudioMixer8_F32 : public AudioStream_F32 {
//GUI: inputs:8, outputs:1 //this line used for automatic generation of GUI node
//GUI: shortName:Mixer8
public:
AudioMixer8_F32() : AudioStream_F32(8, inputQueueArray) { setDefaultValues();}
AudioMixer8_F32(const AudioSettings_F32 &settings) : AudioStream_F32(8, inputQueueArray) { setDefaultValues();}
void setDefaultValues(void) {
for (int i=0; i<8; i++) multiplier[i] = 1.0;
}
virtual void update(void);
void gain(unsigned int channel, float gain) {
if (channel >= 8 || channel < 0) return;
multiplier[channel] = gain;
}
private:
audio_block_f32_t *inputQueueArray[8];
float multiplier[8];
};
#endif