/
SDLSoundSynthesis.h
49 lines (35 loc) · 1.09 KB
/
SDLSoundSynthesis.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
/*
* SDLSoundSynthesis.h
*
* Created on: 15.2.2013
* Author: Tomas Ukkonen
*/
#ifndef SDLSOUNDSYNTHESIS_H_
#define SDLSOUNDSYNTHESIS_H_
#include <vector>
#include <string>
#include <stdint.h>
#include <SDL.h>
#include "SoundSynthesis.h"
class SDLSoundSynthesis : public SoundSynthesis
{
public:
SDLSoundSynthesis();
virtual ~SDLSoundSynthesis();
virtual bool play();
virtual bool pause();
// recommended time it takes to synthesize sound:
// it is not good idea to change parameters faster than this
virtual unsigned long long getSoundSynthesisSpeedMS() = 0;
// return current signal power of synthesized sound in DECIBELs
virtual double getSynthPower() = 0;
protected:
SDL_AudioSpec snd;
virtual bool synthesize(int16_t* buffer, int samples) = 0;
private:
SDL_AudioDeviceID dev;
SDL_AudioSpec desired;
friend void __sdl_soundsynthesis_mixaudio(void* unused, Uint8* stream, int len);
};
void __sdl_soundsynthesis_mixaudio(void* unused, Uint8* stream, int len);
#endif /* SDLSOUNDSYNTHESIS_H_ */