-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTTSSound.h
74 lines (57 loc) · 2.06 KB
/
TTSSound.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
70
71
72
73
/**
* TTSSound.h: Includes TTSSound class that provides sound playback utilies for TTS engine.
*
*
*/
#ifndef _TTSSOUND_
#define _TTSSOUND_
#include "TTSError.h"
#include "TTSIncludes.h"
///////////////////////////////////////////
//////////Defines For TTSSound/////////////
///////////////////////////////////////////
#define BLOCK_SIZE 8192 //size of each wave data block in each wave header
#define BLOCK_COUNT 5 //sound data block count, also wave header count
//global definitions for wave file attributes
#define DEFAULT_BITS_PER_SAMPLE 8 //bits per sample
//#define DEFAULT_SAMPLES_PER_SECOND 44100 //sample per second in hertz
#define DEFAULT_SAMPLES_PER_SECOND 11025 //sample per second in hertz
#define DEFAULT_NUM_OF_CHANNELS 1 //number of channels 1 for mono, 2 for stereo
class TTSSound {
public:
TTSSound();
TTSSound(int bPS, int sPS, int noC);
~TTSSound();
int Stop();
int Pause();
int Restart();
int SetPitch(unsigned long int newPitch);
unsigned long int GetPitch();
int SetVolume(unsigned long int newVol);
unsigned long int GetVolume();
int SetPlaybackRate(unsigned long int newRate);
unsigned long int GetPlaybackRate();
int WriteSndData(char * block, int size);
bool IsBusy();
void SetBusy(bool flag){ isBusy = flag; }
private:
int InitSound(int bitsPerSample = DEFAULT_BITS_PER_SAMPLE,
int samplesPerSecond = DEFAULT_SAMPLES_PER_SECOND,
int numOfChannels = DEFAULT_NUM_OF_CHANNELS) ;
int ExitSound();
void PrintError_Exit(int errNum);
void PrintError(int errNum);
int OpenSndDevice(int bitsPerSample, int samplesPerSecond, int numOfChannels);
int CloseSndDevice();
HWAVEOUT HWaveOut; //device handle
char errorStr[100];
CRITICAL_SECTION waveCriticalSection;
bool isStopped ;
int isBusy;
};
static void CALLBACK SoundCallback(HWAVEOUT hWaveOut,
UINT uMsg,
DWORD dwInstance,
DWORD dwParam1,
DWORD dwParam2 );
#endif