-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoundEngine.h
36 lines (32 loc) · 1010 Bytes
/
SoundEngine.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
//
// Created by vincenzo on 22/10/22.
//
#ifndef CHIPEMULATOR_SOUNDENGINE_H
#define CHIPEMULATOR_SOUNDENGINE_H
#include "SDL.h"
#include "Synth/WaveTableSynth.h"
#include "Synth/SineWaveTableSynth.h"
#include <list>
class SoundEngine {
public:
static SoundEngine* getInstance();
static const int samplePerSecond=48000;
void startPlaying() const;
void stopPlaying() const;
virtual ~SoundEngine();
static void forwardCallback(void *userdata, Uint8 *stream, int len);
void addSynth(WaveTableSynth* s,float wantedFreq);
void removeSynth(WaveTableSynth* s);
private:
SoundEngine();
static SoundEngine* instance;
void audioCallback(Uint8 *stream, int len);
std::list<WaveTableSynth*> synthesizers;
SDL_AudioSpec want{}, have{};
SDL_AudioDeviceID audioDevice;
const SDL_AudioFormat audioFormat = AUDIO_S16SYS;
const int audioChannels=2;
const int sampleBufferSize=1024;
const int synthTableSize=128;
};
#endif //CHIPEMULATOR_SOUNDENGINE_H