spAudio
Loading...
Searching...
No Matches
spAudio.h
Go to the documentation of this file.
1
4#ifndef __SPAUDIO_H
5#define __SPAUDIO_H
6
7#if defined(_MSC_VER)
8#pragma comment ( lib, "winmm" )
9#endif
10
11#include <sp/spDefs.h>
12#include <sp/spOption.h>
13#include <sp/spAudioDefs.h>
14
15#if defined(SGI) || defined(linux) || defined(OSS) || defined(_WIN32) || defined(sun) || defined(MACOS) || defined(ANDROID)
16#define SP_SUPPORT_AUDIO
17#endif
18
19/*
20#if defined(MACOSX64)
21#undef SP_SUPPORT_AUDIO
22#endif
23*/
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
32 /*----@addtogroup spAudioGroup----*/
33
56typedef struct _spAudio *spAudio;
58#define SP_AUDIO_BLOCKING 0
59#define SP_AUDIO_NONBLOCKING 1
61#define SP_AUDIO_CAPS_OPTION_DIALOG (1<<5)
62
63typedef unsigned long spAudioCallbackType;
65#define SP_AUDIO_NO_CALLBACK 0
66#define SP_AUDIO_OUTPUT_POSITION_CALLBACK (1<<0)
67#define SP_AUDIO_OUTPUT_BUFFER_CALLBACK (1<<2)
69#if 0
70/* reserved */
71#define SP_AUDIO_OUTPUT_FINISHED_CALLBACK (1<<3) /* data1: void *buffer, data2: long *buffer_length */
72#define SP_AUDIO_OUTPUT_BUFFER_REQUEST_CALLBACK (1<<4) /* data1: void *buffer, data2: long *buffer_length */
73#define SP_AUDIO_INPUT_POSITION_CALLBACK (1<<5) /* data1: void *buffer, data2: long *buffer_length */
74#define SP_AUDIO_INPUT_BUFFER_CALLBACK (1<<6) /* data1: void *buffer, data2: long *buffer_length */
75#define SP_AUDIO_INPUT_FINISHED_CALLBACK (1<<7) /* data1: void *buffer, data2: long *buffer_length */
76#define SP_AUDIO_INPUT_BUFFER_REQUEST_CALLBACK (1<<8) /* data1: void *buffer, data2: long *buffer_length */
77#endif
78
80typedef spBool (*spAudioCallbackFunc)(spAudio audio, spAudioCallbackType call_type, void *data1, void *data2, void *user_data);
81
82 /*----@addtogroup spAudioGroup----*/
83
84#if defined(MACOS)
85#pragma import on
86#endif
87
89 /*----@addtogroup spAudioGroup----*/
90
92extern int spGetNumAudioDriver(void);
93
97extern char *xspGetAudioDriverName(int index);
98
103extern int spGetNumAudioDriverDevice(const char *driver_name);
104
110extern char *xspGetAudioDriverDeviceName(const char *driver_name, int index);
111 /*----@addtogroup spAudioGroup----*/
112
121extern spAudio spInitAudioDriver(const char *driver_name);
126extern spAudio spInitAudio(void);
130extern void _spFreeAudioDriver(spAudio audio);
135extern spBool spAddAudioExitCallback(spAudio audio, spExitCallbackFunc callback);
145extern spBool spGetNumAudioDevice(spAudio audio, int *num_device);
152extern char *xspGetAudioDeviceName(spAudio audio, int device_index);
159extern spBool spSelectAudioDevice(spAudio audio, int device_index);
166extern spBool spIsAudioOptionDialogExist(spAudio audio);
171extern spBool spDisplayAudioOptionDialog(spAudio audio);
172
180extern spBool spSetAudioSampleRate(spAudio audio, double samp_rate);
186extern spBool spGetAudioSampleRate(spAudio audio, double *samp_rate);
192extern spBool spSetAudioChannel(spAudio audio, int num_channel);
198extern spBool spGetAudioChannel(spAudio audio, int *num_channel);
204extern spBool spSetAudioBufferSize(spAudio audio, int buffer_size);
210extern spBool spGetAudioBufferSize(spAudio audio, int *buffer_size);
216extern spBool spSetAudioNumBuffer(spAudio audio, int num_buffer);
222extern spBool spGetAudioNumBuffer(spAudio audio, int *num_buffer);
228extern spBool spSetAudioBlockingMode(spAudio audio, int block_mode);
234extern spBool spGetAudioBlockingMode(spAudio audio, int *block_mode);
241extern spBool spSetAudioSampleBit(spAudio audio, int samp_bit);
247extern spBool spGetAudioSampleBit(spAudio audio, int *samp_bit);
253extern spBool spGetAudioSpecifiedSampleBit(spAudio audio, int *specified_samp_bit);
265 spAudioCallbackFunc call_func, void *call_data);
277extern spBool spOpenAudioDevice(spAudio audio, const char *mode);
295extern long spReadAudio(spAudio audio, void *data, long length);
296extern long spReadAudioBuffer(spAudio audio, char *buffer, long size);
304extern long spWriteAudio(spAudio audio, void *data, long length);
305extern long spWriteAudioBuffer(spAudio audio, char *buffer, long size);
314extern long spReadAudioDoubleWeighted(spAudio audio, double *data, long length, double weight);
322extern long spReadAudioDouble(spAudio audio, double *data, long length);
331extern long spWriteAudioDoubleWeighted(spAudio audio, double *data, long length, double weight);
339extern long spWriteAudioDouble(spAudio audio, double *data, long length);
350extern spBool spGetAudioOutputPosition(spAudio audio, spLong *position);
364#if defined(MACOS)
365#pragma import off
366#endif
367
373#define spFreeAudioDriver(audio) {_spFreeAudioDriver(audio); (audio) = NULL;}
377#define spFreeAudio(audio) spFreeAudioDriver(audio)
380#ifdef __cplusplus
381} /* Close scope of 'extern "C"' declaration */
382#endif
383
384#endif /* __SPAUDIO_H */
A class to handle audio I/O.
spAudioCallbackType spSetAudioCallbackFunc(spAudio audio, spAudioCallbackType call_type, spAudioCallbackFunc call_func, void *call_data)
spAudio spInitAudioDriver(const char *driver_name)
spBool spGetAudioSampleRate(spAudio audio, double *samp_rate)
spBool spGetAudioChannel(spAudio audio, int *num_channel)
spBool spStopAudio(spAudio audio)
spBool spSetAudioBlockingMode(spAudio audio, int block_mode)
spBool spGetAudioSampleBit(spAudio audio, int *samp_bit)
spBool spGetNumAudioDevice(spAudio audio, int *num_device)
long spWriteAudio(spAudio audio, void *data, long length)
spBool spSetAudioBufferSize(spAudio audio, int buffer_size)
spBool spGetAudioOutputPosition(spAudio audio, spLong *position)
char * xspGetAudioDeviceName(spAudio audio, int device_index)
void _spFreeAudioDriver(spAudio audio)
spBool spSetAudioSampleBit(spAudio audio, int samp_bit)
long spReadAudioDouble(spAudio audio, double *data, long length)
long spWriteAudioDouble(spAudio audio, double *data, long length)
spBool spSelectAudioDevice(spAudio audio, int device_index)
spBool spGetAudioBlockingMode(spAudio audio, int *block_mode)
spBool spSetAudioSampleRate(spAudio audio, double samp_rate)
spBool spOpenAudioDevice(spAudio audio, const char *mode)
spBool spSyncAudio(spAudio audio)
spBool spSetAudioNumBuffer(spAudio audio, int num_buffer)
long spReadAudioDoubleWeighted(spAudio audio, double *data, long length, double weight)
spBool spGetAudioSpecifiedSampleBit(spAudio audio, int *specified_samp_bit)
spAudio spInitAudio(void)
spBool spGetAudioBufferSize(spAudio audio, int *buffer_size)
long spReadAudio(spAudio audio, void *data, long length)
spBool spSetAudioChannel(spAudio audio, int num_channel)
spBool spCloseAudioDevice(spAudio audio)
spBool spGetAudioNumBuffer(spAudio audio, int *num_buffer)
long spWriteAudioDoubleWeighted(spAudio audio, double *data, long length, double weight)
struct _spAudio * spAudio
Definition spAudio.h:56
char * xspGetAudioDriverName(int index)
spBool(* spAudioCallbackFunc)(spAudio audio, spAudioCallbackType call_type, void *data1, void *data2, void *user_data)
Definition spAudio.h:80
char * xspGetAudioDriverDeviceName(const char *driver_name, int index)
unsigned long spAudioCallbackType
Definition spAudio.h:63
int spGetNumAudioDriver(void)
int spGetNumAudioDriverDevice(const char *driver_name)
int spBool