-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlibv2.h
122 lines (100 loc) · 5.71 KB
/
libv2.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*************************************************************************************/
/*************************************************************************************/
/** **/
/** LibV2 header file **/
/** written by Tammo 'kb' Hinrichs 2000-2008 **/
/** This file is in the public domain **/
/** **/
/*************************************************************************************/
/*************************************************************************************/
#ifndef LIBV2_H_
#define LIBV2_H_
#ifdef __cplusplus
extern "C"
{
#endif
/*************************************************************************************/
/** **/
/** DirectSound output code **/
/** **/
/*************************************************************************************/
// your rendering callback function has to look this way:
// parm: pointer you specified with dsInit
// buf: pointer to interleved stereo float destination buffer (1.0=0dB)
// len: length of buffer in samples (!)
typedef void (__stdcall DSIOCALLBACK)(void *parm, float *buf, unsigned long len);
// initializes DirectSound output.
// callback: your render callback function
// parm: a pointer that'll be supplied to the function on every call
// hWnd: window handle of your application (GetForegroundWindow() works quite well :)
unsigned long __stdcall dsInit(DSIOCALLBACK *callback, void *parm, void *hWnd);
// shuts down DirectSound output
void __stdcall dsClose();
// gets sample-exact and latency compensated current play position
signed long __stdcall dsGetCurSmp();
// sets player volume (default is 1.0)
void __stdcall dsSetVolume(float vol);
// forces rendering thread to update. On single-core CPUs it's a good idea to
// call this once per frame (improves A/V sync and reduces any stuttering),
// with more than one CPU it's pretty much useless.
void __stdcall dsTick();
// lock and unlock the sound thread's thread sync lock. If you want to modify
// any of your sound variables outside the render thread, encapsulate that part
// of code in between these two functions.
void __stdcall dsLock();
void __stdcall dsUnlock();
/*************************************************************************************/
/** **/
/** Synthesizer interface **/
/** **/
/*************************************************************************************/
// returns size of work memory in bytes. Per synthesizer instance reserve at least
// this amount of memory and supply it as the "pthis" parameter of all other functions
// Note: If you need only one static instance, 3 Megabytes are a good bet.
unsigned int __stdcall synthGetSize();
// inits synthesizer instance.
// pthis : pointer to work mem
// patchmap : pointer to patch data
// samplerate: output sample rate (44100-192000 Hz), use 44100 when playing with dsio
void __stdcall synthInit(void *pthis, const void *patchmap, int samplerate=44100);
// inits global parameters
// pthis: pointer to work mem
// ptr : pointer to global parameters
void __stdcall synthSetGlobals(void *pthis, const void *ptr);
// inits speech synthesizer texts
// pthis: pointer to work mem
// ptr : pointer to text array
void __stdcall synthSetLyrics(void *pthis, const char **ptr);
// renders synth output to destination buffer
// pthis: pointer to work mem
// buf : pointer to interleaved float stereo out buffer
// smp : number of samples to render
// buf2 : if this is specified, the synth will render the left and right channel into
// two mono float buffers at buf and buf2 instead of one interleaved buffer
// add : if this is specified, the synth will add its output to the destination
// buffer instead of replacing its contents
void __stdcall synthRender(void *pthis, void *buf, int smp, void *buf2=0, int add=0);
// pipes a stream of MIDI commands to the synthesizer
// pthis: pointer to work mem
// ptr : pointer to buffer with MIDI data to process.
// NOTE: The buffer MUST end with a 0xfd byte
void __stdcall synthProcessMIDI(void *pthis, const void *ptr);
// sets operation mode of VU meters
// pthis: pointer to work mem
// mode : 0 for peak meters, 1 for RMS meters
void __stdcall synthSetVUMode(void *pthis, int mode); // 0: peak, 1: rms
// retrieves VU meter data for a channel
// pthis: pointer to work mem
// ch : channel to retrieve (0..15)
// l : pointer to float variable where left VU is stored
// r : pointer to float variable where right VU is stored
void __stdcall synthGetChannelVU(void *pthis, int ch, float *l, float *r); // ch: 0..15
// retrieves master VU meter
// pthis: pointer to work mem
// l : pointer to float variable where left VU is stored
// r : pointer to float variable where right VU is stored
void __stdcall synthGetMainVU(void *pthis, float *l, float *r);
#ifdef __cplusplus
}
#endif
#endif