OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
gv.h
1/*
2GameSpy Voice2 SDK
3Dan "Mr. Pants" Schoenblum
4dan@gamespy.com
5
6Copyright 2004 GameSpy Industries, Inc
7
8devsupport@gamespy.com
9http://gamespy.net
10*/
11
12/************************
13** GameSpy Voice 2 SDK **
14************************/
15
16#ifndef _GV_H_
17#define _GV_H_
18
19#include "../common/gsCommon.h"
20
21#if defined(__cplusplus)
22extern "C" {
23#endif
24
25//DEFINES
27#define GV_BYTES_PER_SAMPLE (sizeof(GVSample) / sizeof(GVByte))
28#define GV_BITS_PER_SAMPLE (GV_BYTES_PER_SAMPLE * 8)
29
30#define GV_DEVICE_NAME_LEN 64
31#define GV_CHANNEL_NAME_LEN 64
32
33#define GV_CAPTURE 1
34#define GV_PLAYBACK 2
35#define GV_CAPTURE_AND_PLAYBACK (GV_CAPTURE|GV_PLAYBACK)
36
37#define GVRate_8KHz 8000
38#define GVRate_16KHz 16000
39//Used by PSP
40#define GVRate_11KHz 11025
41
42//For backwards compatability
43#define GV_SAMPLES_PER_SECOND (gvGetSampleRate())
44#define GV_BYTES_PER_SECOND (gvGetSampleRate() * GV_BYTES_PER_SAMPLE)
45
46//TYPES
48typedef enum
49{
50 GVCodecRaw,
51 GVCodecSuperHighQuality,
52 GVCodecHighQuality,
53 GVCodecAverage,
54 GVCodecLowBandwidth,
55 GVCodecSuperLowBandwidth
56} GVCodec;
57
58typedef enum
59{
60 GVHardwareDirectSound, // Win32
61 GVHardwarePS2Spu2, // PS2 (System output)
62 GVHardwarePS2Headset, // PS2 (USB)
63 GVHardwarePS2Microphone, // PS2 (USB)
64 GVHardwarePS2Speakers, // PS2 (USB)
65 GVHardwarePS2Eyetoy, // PS2 (USB)
66 GVHardwarePS3Headset, // PS3 (USB)
67 GVHardwarePSPHeadset, // PSP
68 GVHardwareMacOSX, // MacOSX
69 GVHardwareCustom // Any
70} GVHardwareType;
71
72typedef enum
73{
74 GVCaptureModeThreshold,
75 GVCaptureModePushToTalk
76} GVCaptureMode;
77
78typedef int GVBool;
79#define GVFalse 0
80#define GVTrue 1
81
82typedef gsi_u8 GVByte;
83typedef gsi_i16 GVSample;
84
85typedef int GVRate;
86
87#if defined(_PSP) || defined(_PS2) || defined(_PS3)
88 typedef float GVScalar; // range 0-1
89#else
90 typedef double GVScalar; // range 0-1
91#endif
92typedef gsi_u16 GVFrameStamp;
93typedef void * GVDecoderData;
94typedef int GVDeviceType;
95typedef struct GVIDevice * GVDevice;
96
97#if defined(GV_CUSTOM_SOURCE_TYPE)
98typedef GV_CUSTOM_SOURCE_TYPE GVSource;
99#else
100typedef int GVSource;
101#endif
102
103#if defined(_WIN32)
104typedef GUID GVDeviceID;
105#else
106typedef int GVDeviceID;
107#endif
108
109typedef struct
110{
111 GVDeviceID m_id;
112 gsi_char m_name[GV_DEVICE_NAME_LEN];
113 GVDeviceType m_deviceType;
114 GVDeviceType m_defaultDevice; // not supported on PS2
115 GVHardwareType m_hardwareType;
117
118typedef struct
119{
120 int m_samplesPerFrame; // number of samples in an unencoded frame
121 int m_encodedFrameSize; // number of bytes in an encoded frame
122
123 GVBool (* m_newDecoderCallback)(GVDecoderData * data);
124 void (* m_freeDecoderCallback)(GVDecoderData data);
125
126 void (* m_encodeCallback)(GVByte * out, const GVSample * in);
127 void (* m_decodeAddCallback)(GVSample * out, const GVByte * in, GVDecoderData data); // adds to output (required)
128 void (* m_decodeSetCallback)(GVSample * out, const GVByte * in, GVDecoderData data); // sets output (optional)
130
131//GLOBALS
133#if defined(_WIN32)
134extern const GVDeviceID GVDefaultCaptureDeviceID;
135extern const GVDeviceID GVDefaultPlaybackDeviceID;
136#elif defined(_PS2)
137extern const GVDeviceID GVPS2Spu2DeviceID;
138#endif
139
140//GENERAL
142#if defined(_WIN32)
143GVBool gvStartup(HWND hWnd);
144#else
145GVBool gvStartup(void);
146#endif
147void gvCleanup(void);
148
149void gvThink(void);
150
151//CODEC
153GVBool gvSetCodec(GVCodec codec);
154void gvSetCustomCodec(GVCustomCodecInfo * info);
155
156void gvGetCodecInfo(int * samplesPerFrame, int * encodedFrameSize, int * bitsPerSecond);
157
158//SAMPLE RATE
160void gvSetSampleRate(GVRate sampleRate);
161GVRate gvGetSampleRate(void);
162
163//DEVICES
165int gvListDevices(GVDeviceInfo devices[], int maxDevices, GVDeviceType types);
166
167#if defined(_WIN32)
168GVBool gvRunSetupWizard(GVDeviceID captureDeviceID, GVDeviceID playbackDeviceID);
169GVBool gvAreDevicesSetup(GVDeviceID captureDeviceID, GVDeviceID playbackDeviceID);
170#endif
171
172GVDevice gvNewDevice(GVDeviceID deviceID, GVDeviceType type);
173void gvFreeDevice(GVDevice device);
174
175GVBool gvStartDevice(GVDevice device, GVDeviceType type);
176void gvStopDevice(GVDevice device, GVDeviceType type);
177GVBool gvIsDeviceStarted(GVDevice device, GVDeviceType type);
178
179void gvSetDeviceVolume(GVDevice device, GVDeviceType type, GVScalar volume);
180GVScalar gvGetDeviceVolume(GVDevice device, GVDeviceType type);
181
182typedef void (* gvUnpluggedCallback)(GVDevice device);
183void gvSetUnpluggedCallback(GVDevice device, gvUnpluggedCallback unpluggedCallback);
184
185typedef void (* gvFilterCallback)(GVDevice device, GVSample * audio, GVFrameStamp frameStamp);
186void gvSetFilter(GVDevice device, GVDeviceType type, gvFilterCallback callback);
187
188//CAPTURE
190// len is both an input and output parameter
191GVBool gvCapturePacket(GVDevice device, GVByte * packet, int * len, GVFrameStamp * frameStamp, GVScalar * volume);
192int gvGetAvailableCaptureBytes(GVDevice device);
193
194void gvSetCaptureThreshold(GVDevice device, GVScalar threshold);
195GVScalar gvGetCaptureThreshold(GVDevice device);
196
197void gvSetCaptureMode(GVDevice device, GVCaptureMode captureMode);
198GVCaptureMode gvGetCaptureMode(GVDevice device);
199
200void gvSetPushToTalk(GVDevice device, GVBool talkOn);
201GVBool gvGetPushToTalk(GVDevice device);
202
203//PLAYBACK
205void gvPlayPacket(GVDevice device, const GVByte * packet, int len, GVSource source, GVFrameStamp frameStamp, GVBool mute);
206
207GVBool gvIsSourceTalking(GVDevice device, GVSource source);
208int gvListTalkingSources(GVDevice device, GVSource sources[], int maxSources);
209
210void gvSetGlobalMute(GVBool mute);
211GVBool gvGetGlobalMute(void);
212
213//CUSTOM DEVICE
215GVDevice gvNewCustomDevice(GVDeviceType type);
216
217// for both of these, numSamples must be a multiple of the codec's samplesPerFrame
218// this ensures that no data needs to be buffered by the SDK
219GVBool gvGetCustomPlaybackAudio(GVDevice device, GVSample * audio, int numSamples);
220GVBool gvSetCustomCaptureAudio(GVDevice device, const GVSample * audio, int numSamples,
221 GVByte * packet, int * packetLen, GVFrameStamp * frameStamp, GVScalar * volume);
222
223//CHANNELS
225int gvGetNumChannels(GVDevice device, GVDeviceType type);
226void gvGetChannelName(GVDevice device, GVDeviceType type, int channel, gsi_char name[GV_CHANNEL_NAME_LEN]);
227void gvSetChannel(GVDevice device, GVDeviceType type, int channel);
228int gvGetChannel(GVDevice device, GVDeviceType type);
229
230#if defined(__cplusplus)
231}
232#endif
233
234#endif
Definition gv.h:119
Definition gv.h:110
Definition gvDevice.h:58