You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.5 KiB
63 lines
1.5 KiB
8 years ago
|
/*
|
||
8 years ago
|
* AudioMixer
|
||
8 years ago
|
*
|
||
8 years ago
|
* AudioMixer4
|
||
8 years ago
|
* 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)
|
||
8 years ago
|
*
|
||
|
* Extended to AudioMixer8
|
||
|
* By: Chip Audette, OpenAudio, Feb 2017
|
||
8 years ago
|
*
|
||
|
* MIT License. use at your own risk.
|
||
|
*/
|
||
|
|
||
8 years ago
|
#ifndef AUDIOMIXER_F32_H
|
||
|
#define AUDIOMIXER_F32_H
|
||
8 years ago
|
|
||
|
#include <arm_math.h>
|
||
|
#include <AudioStream_F32.h>
|
||
|
|
||
|
class AudioMixer4_F32 : public AudioStream_F32 {
|
||
8 years ago
|
//GUI: inputs:4, outputs:1 //this line used for automatic generation of GUI node
|
||
8 years ago
|
//GUI: shortName:Mixer4
|
||
8 years ago
|
public:
|
||
|
AudioMixer4_F32() : AudioStream_F32(4, inputQueueArray) {
|
||
8 years ago
|
for (int i=0; i<4; i++) multiplier[i] = 1.0;
|
||
8 years ago
|
}
|
||
|
|
||
|
virtual void update(void);
|
||
|
|
||
|
void gain(unsigned int channel, float gain) {
|
||
8 years ago
|
if (channel >= 4 || channel < 0) return;
|
||
8 years ago
|
multiplier[channel] = gain;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
audio_block_f32_t *inputQueueArray[4];
|
||
|
float multiplier[4];
|
||
|
};
|
||
|
|
||
8 years ago
|
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) {
|
||
|
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];
|
||
|
};
|
||
|
|
||
8 years ago
|
#endif
|