-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMixer.hpp
60 lines (50 loc) · 1.7 KB
/
Mixer.hpp
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
#ifndef MIXER_H
#define MIXER_H
#include "OutputDevice.hpp"
#include "Channel.hpp"
#include "Compressor.hpp"
#include "Sequencer.hpp"
#include "portaudio.h"
namespace tsal {
/** @class Mixer
* @brief The main audio manager that handles the overhead of audio buffers
* and channel mixing
*
* To use TSAL, the Mixer class needs to be initiliazed at the start of the project.
* All other audio devices will be routed through the Mixer's master channel
*/
class Mixer {
public:
Mixer();
Mixer(unsigned sampleRate);
~Mixer();
void add(Channel& channel);
void add(Instrument& instrument);
void add(Effect& effect);
void remove(Channel& channel);
void remove(Instrument& instrument);
void remove(Effect& effect);
Channel& getMaster() { return mMaster; };
Sequencer& getSequencer() { return mSequencer; };
unsigned getSampleRate() { return mSampleRate; };
unsigned getChannelCount() { return mChannelCount; };
private:
PaStream* mPaStream;
Channel mMaster;
Compressor mCompressor;
Sequencer mSequencer;
void openPaStream();
AudioBuffer<float> mBuffer;
unsigned mSampleRate = 44100;
// Assuming two channels until a system for variable number of channels exists
unsigned mChannelCount = 2;
int audioCallback(float *outputBuffer, unsigned long frameCount);
static void paStreamFinished(void* userData);
static int paCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo* timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData );
};
}
#endif