├── .gitignore ├── Makefile ├── README.md ├── RtAudio.cpp ├── RtAudio.h ├── bin └── libspeexdsp-1.dll ├── from_file.cpp ├── from_mic.cpp ├── include ├── dsound.h └── speex │ ├── speex_echo.h │ ├── speex_jitter.h │ ├── speex_preprocess.h │ ├── speex_resampler.h │ ├── speexdsp_config_types.h │ └── speexdsp_types.h ├── lib ├── libspeexdsp.a ├── libspeexdsp.dll.a ├── libspeexdsp.la └── pkgconfig │ └── speexdsp.pc ├── remote.pcm ├── speex_func.cpp ├── speex_func.h ├── test.exe ├── 消除效果图1.png └── 消除效果图2.png /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | exe 3 | ./*.exe 4 | test.exe 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: from_mic from_file 2 | 3 | 4 | from_mic: *.cpp 5 | g++ -o from_mic -static -Wall \ 6 | from_mic.cpp RtAudio.cpp speex_func.cpp \ 7 | -std=c++11 \ 8 | -lole32 -lwinmm -ldsound \ 9 | -lspeexdsp \ 10 | -I./include \ 11 | -I/G/install/include \ 12 | -L./lib \ 13 | -D__WINDOWS_DS__ \ 14 | 15 | 16 | 17 | from_file: *.cpp 18 | g++ -o from_file -static -Wall \ 19 | from_file.cpp RtAudio.cpp speex_func.cpp \ 20 | -std=c++11 \ 21 | -lole32 -lwinmm -ldsound \ 22 | -lspeexdsp \ 23 | -I./include \ 24 | -I/G/install/include \ 25 | -L./lib \ 26 | -D__WINDOWS_DS__ \ 27 | 28 | 29 | clean: 30 | rm -rf from_file from_mic -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rtaudio_speex 2 | 3 | #### 项目介绍 4 | 用rtaudio来采集、播放,并用speexdsp来做回声消除。 5 | 6 | multi_thread 分支在windows 下测试效果挺好的。 7 | 8 | remote.pcm 假装是远端发来的声音。 9 | cap.pcm 就是mic直接抓到的声音。 10 | cancel.pcm 就是经过speex回音消除处理之后的输出声音。 -------------------------------------------------------------------------------- /RtAudio.h: -------------------------------------------------------------------------------- 1 | /************************************************************************/ 2 | /*! \class RtAudio 3 | \brief Realtime audio i/o C++ classes. 4 | 5 | RtAudio provides a common API (Application Programming Interface) 6 | for realtime audio input/output across Linux (native ALSA, Jack, 7 | and OSS), Macintosh OS X (CoreAudio and Jack), and Windows 8 | (DirectSound, ASIO and WASAPI) operating systems. 9 | 10 | RtAudio WWW site: http://www.music.mcgill.ca/~gary/rtaudio/ 11 | 12 | RtAudio: realtime audio i/o C++ classes 13 | Copyright (c) 2001-2017 Gary P. Scavone 14 | 15 | Permission is hereby granted, free of charge, to any person 16 | obtaining a copy of this software and associated documentation files 17 | (the "Software"), to deal in the Software without restriction, 18 | including without limitation the rights to use, copy, modify, merge, 19 | publish, distribute, sublicense, and/or sell copies of the Software, 20 | and to permit persons to whom the Software is furnished to do so, 21 | subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be 24 | included in all copies or substantial portions of the Software. 25 | 26 | Any person wishing to distribute modifications to the Software is 27 | asked to send the modifications to the original developer so that 28 | they can be incorporated into the canonical version. This is, 29 | however, not a binding provision of this license. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 32 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 33 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 34 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 35 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 36 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 37 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38 | */ 39 | /************************************************************************/ 40 | 41 | /*! 42 | \file RtAudio.h 43 | */ 44 | 45 | #ifndef __RTAUDIO_H 46 | #define __RTAUDIO_H 47 | 48 | #define RTAUDIO_VERSION "5.0.0" 49 | 50 | #include 51 | #include 52 | #include 53 | #include 54 | 55 | /*! \typedef typedef unsigned long RtAudioFormat; 56 | \brief RtAudio data format type. 57 | 58 | Support for signed integers and floats. Audio data fed to/from an 59 | RtAudio stream is assumed to ALWAYS be in host byte order. The 60 | internal routines will automatically take care of any necessary 61 | byte-swapping between the host format and the soundcard. Thus, 62 | endian-ness is not a concern in the following format definitions. 63 | 64 | - \e RTAUDIO_SINT8: 8-bit signed integer. 65 | - \e RTAUDIO_SINT16: 16-bit signed integer. 66 | - \e RTAUDIO_SINT24: 24-bit signed integer. 67 | - \e RTAUDIO_SINT32: 32-bit signed integer. 68 | - \e RTAUDIO_FLOAT32: Normalized between plus/minus 1.0. 69 | - \e RTAUDIO_FLOAT64: Normalized between plus/minus 1.0. 70 | */ 71 | typedef unsigned long RtAudioFormat; 72 | static const RtAudioFormat RTAUDIO_SINT8 = 0x1; // 8-bit signed integer. 73 | static const RtAudioFormat RTAUDIO_SINT16 = 0x2; // 16-bit signed integer. 74 | static const RtAudioFormat RTAUDIO_SINT24 = 0x4; // 24-bit signed integer. 75 | static const RtAudioFormat RTAUDIO_SINT32 = 0x8; // 32-bit signed integer. 76 | static const RtAudioFormat RTAUDIO_FLOAT32 = 0x10; // Normalized between plus/minus 1.0. 77 | static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; // Normalized between plus/minus 1.0. 78 | 79 | /*! \typedef typedef unsigned long RtAudioStreamFlags; 80 | \brief RtAudio stream option flags. 81 | 82 | The following flags can be OR'ed together to allow a client to 83 | make changes to the default stream behavior: 84 | 85 | - \e RTAUDIO_NONINTERLEAVED: Use non-interleaved buffers (default = interleaved). 86 | - \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency. 87 | - \e RTAUDIO_HOG_DEVICE: Attempt grab device for exclusive use. 88 | - \e RTAUDIO_ALSA_USE_DEFAULT: Use the "default" PCM device (ALSA only). 89 | - \e RTAUDIO_JACK_DONT_CONNECT: Do not automatically connect ports (JACK only). 90 | 91 | By default, RtAudio streams pass and receive audio data from the 92 | client in an interleaved format. By passing the 93 | RTAUDIO_NONINTERLEAVED flag to the openStream() function, audio 94 | data will instead be presented in non-interleaved buffers. In 95 | this case, each buffer argument in the RtAudioCallback function 96 | will point to a single array of data, with \c nFrames samples for 97 | each channel concatenated back-to-back. For example, the first 98 | sample of data for the second channel would be located at index \c 99 | nFrames (assuming the \c buffer pointer was recast to the correct 100 | data type for the stream). 101 | 102 | Certain audio APIs offer a number of parameters that influence the 103 | I/O latency of a stream. By default, RtAudio will attempt to set 104 | these parameters internally for robust (glitch-free) performance 105 | (though some APIs, like Windows Direct Sound, make this difficult). 106 | By passing the RTAUDIO_MINIMIZE_LATENCY flag to the openStream() 107 | function, internal stream settings will be influenced in an attempt 108 | to minimize stream latency, though possibly at the expense of stream 109 | performance. 110 | 111 | If the RTAUDIO_HOG_DEVICE flag is set, RtAudio will attempt to 112 | open the input and/or output stream device(s) for exclusive use. 113 | Note that this is not possible with all supported audio APIs. 114 | 115 | If the RTAUDIO_SCHEDULE_REALTIME flag is set, RtAudio will attempt 116 | to select realtime scheduling (round-robin) for the callback thread. 117 | 118 | If the RTAUDIO_ALSA_USE_DEFAULT flag is set, RtAudio will attempt to 119 | open the "default" PCM device when using the ALSA API. Note that this 120 | will override any specified input or output device id. 121 | 122 | If the RTAUDIO_JACK_DONT_CONNECT flag is set, RtAudio will not attempt 123 | to automatically connect the ports of the client to the audio device. 124 | */ 125 | typedef unsigned int RtAudioStreamFlags; 126 | static const RtAudioStreamFlags RTAUDIO_NONINTERLEAVED = 0x1; // Use non-interleaved buffers (default = interleaved). 127 | static const RtAudioStreamFlags RTAUDIO_MINIMIZE_LATENCY = 0x2; // Attempt to set stream parameters for lowest possible latency. 128 | static const RtAudioStreamFlags RTAUDIO_HOG_DEVICE = 0x4; // Attempt grab device and prevent use by others. 129 | static const RtAudioStreamFlags RTAUDIO_SCHEDULE_REALTIME = 0x8; // Try to select realtime scheduling for callback thread. 130 | static const RtAudioStreamFlags RTAUDIO_ALSA_USE_DEFAULT = 0x10; // Use the "default" PCM device (ALSA only). 131 | static const RtAudioStreamFlags RTAUDIO_JACK_DONT_CONNECT = 0x20; // Do not automatically connect ports (JACK only). 132 | 133 | /*! \typedef typedef unsigned long RtAudioStreamStatus; 134 | \brief RtAudio stream status (over- or underflow) flags. 135 | 136 | Notification of a stream over- or underflow is indicated by a 137 | non-zero stream \c status argument in the RtAudioCallback function. 138 | The stream status can be one of the following two options, 139 | depending on whether the stream is open for output and/or input: 140 | 141 | - \e RTAUDIO_INPUT_OVERFLOW: Input data was discarded because of an overflow condition at the driver. 142 | - \e RTAUDIO_OUTPUT_UNDERFLOW: The output buffer ran low, likely producing a break in the output sound. 143 | */ 144 | typedef unsigned int RtAudioStreamStatus; 145 | static const RtAudioStreamStatus RTAUDIO_INPUT_OVERFLOW = 0x1; // Input data was discarded because of an overflow condition at the driver. 146 | static const RtAudioStreamStatus RTAUDIO_OUTPUT_UNDERFLOW = 0x2; // The output buffer ran low, likely causing a gap in the output sound. 147 | 148 | //! RtAudio callback function prototype. 149 | /*! 150 | All RtAudio clients must create a function of type RtAudioCallback 151 | to read and/or write data from/to the audio stream. When the 152 | underlying audio system is ready for new input or output data, this 153 | function will be invoked. 154 | 155 | \param outputBuffer For output (or duplex) streams, the client 156 | should write \c nFrames of audio sample frames into this 157 | buffer. This argument should be recast to the datatype 158 | specified when the stream was opened. For input-only 159 | streams, this argument will be NULL. 160 | 161 | \param inputBuffer For input (or duplex) streams, this buffer will 162 | hold \c nFrames of input audio sample frames. This 163 | argument should be recast to the datatype specified when the 164 | stream was opened. For output-only streams, this argument 165 | will be NULL. 166 | 167 | \param nFrames The number of sample frames of input or output 168 | data in the buffers. The actual buffer size in bytes is 169 | dependent on the data type and number of channels in use. 170 | 171 | \param streamTime The number of seconds that have elapsed since the 172 | stream was started. 173 | 174 | \param status If non-zero, this argument indicates a data overflow 175 | or underflow condition for the stream. The particular 176 | condition can be determined by comparison with the 177 | RtAudioStreamStatus flags. 178 | 179 | \param userData A pointer to optional data provided by the client 180 | when opening the stream (default = NULL). 181 | 182 | To continue normal stream operation, the RtAudioCallback function 183 | should return a value of zero. To stop the stream and drain the 184 | output buffer, the function should return a value of one. To abort 185 | the stream immediately, the client should return a value of two. 186 | */ 187 | typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer, 188 | unsigned int nFrames, 189 | double streamTime, 190 | RtAudioStreamStatus status, 191 | void *userData ); 192 | 193 | /************************************************************************/ 194 | /*! \class RtAudioError 195 | \brief Exception handling class for RtAudio. 196 | 197 | The RtAudioError class is quite simple but it does allow errors to be 198 | "caught" by RtAudioError::Type. See the RtAudio documentation to know 199 | which methods can throw an RtAudioError. 200 | */ 201 | /************************************************************************/ 202 | 203 | class RtAudioError : public std::runtime_error 204 | { 205 | public: 206 | //! Defined RtAudioError types. 207 | enum Type { 208 | WARNING, /*!< A non-critical error. */ 209 | DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */ 210 | UNSPECIFIED, /*!< The default, unspecified error type. */ 211 | NO_DEVICES_FOUND, /*!< No devices found on system. */ 212 | INVALID_DEVICE, /*!< An invalid device ID was specified. */ 213 | MEMORY_ERROR, /*!< An error occured during memory allocation. */ 214 | INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */ 215 | INVALID_USE, /*!< The function was called incorrectly. */ 216 | DRIVER_ERROR, /*!< A system driver error occured. */ 217 | SYSTEM_ERROR, /*!< A system error occured. */ 218 | THREAD_ERROR /*!< A thread error occured. */ 219 | }; 220 | 221 | //! The constructor. 222 | RtAudioError( const std::string& message, 223 | Type type = RtAudioError::UNSPECIFIED ) 224 | : std::runtime_error(message), type_(type) {} 225 | 226 | //! Prints thrown error message to stderr. 227 | virtual void printMessage( void ) const 228 | { std::cerr << '\n' << what() << "\n\n"; } 229 | 230 | //! Returns the thrown error message type. 231 | virtual const Type& getType(void) const { return type_; } 232 | 233 | //! Returns the thrown error message string. 234 | virtual const std::string getMessage(void) const 235 | { return std::string(what()); } 236 | 237 | protected: 238 | Type type_; 239 | }; 240 | 241 | //! RtAudio error callback function prototype. 242 | /*! 243 | \param type Type of error. 244 | \param errorText Error description. 245 | */ 246 | typedef void (*RtAudioErrorCallback)( RtAudioError::Type type, const std::string &errorText ); 247 | 248 | // **************************************************************** // 249 | // 250 | // RtAudio class declaration. 251 | // 252 | // RtAudio is a "controller" used to select an available audio i/o 253 | // interface. It presents a common API for the user to call but all 254 | // functionality is implemented by the class RtApi and its 255 | // subclasses. RtAudio creates an instance of an RtApi subclass 256 | // based on the user's API choice. If no choice is made, RtAudio 257 | // attempts to make a "logical" API selection. 258 | // 259 | // **************************************************************** // 260 | 261 | class RtApi; 262 | 263 | class RtAudio 264 | { 265 | public: 266 | 267 | //! Audio API specifier arguments. 268 | enum Api { 269 | UNSPECIFIED, /*!< Search for a working compiled API. */ 270 | LINUX_ALSA, /*!< The Advanced Linux Sound Architecture API. */ 271 | LINUX_PULSE, /*!< The Linux PulseAudio API. */ 272 | LINUX_OSS, /*!< The Linux Open Sound System API. */ 273 | UNIX_JACK, /*!< The Jack Low-Latency Audio Server API. */ 274 | MACOSX_CORE, /*!< Macintosh OS-X Core Audio API. */ 275 | WINDOWS_WASAPI, /*!< The Microsoft WASAPI API. */ 276 | WINDOWS_ASIO, /*!< The Steinberg Audio Stream I/O API. */ 277 | WINDOWS_DS, /*!< The Microsoft Direct Sound API. */ 278 | RTAUDIO_DUMMY /*!< A compilable but non-functional API. */ 279 | }; 280 | 281 | //! The public device information structure for returning queried values. 282 | struct DeviceInfo { 283 | bool probed; /*!< true if the device capabilities were successfully probed. */ 284 | std::string name; /*!< Character string device identifier. */ 285 | unsigned int outputChannels; /*!< Maximum output channels supported by device. */ 286 | unsigned int inputChannels; /*!< Maximum input channels supported by device. */ 287 | unsigned int duplexChannels; /*!< Maximum simultaneous input/output channels supported by device. */ 288 | bool isDefaultOutput; /*!< true if this is the default output device. */ 289 | bool isDefaultInput; /*!< true if this is the default input device. */ 290 | std::vector sampleRates; /*!< Supported sample rates (queried from list of standard rates). */ 291 | unsigned int preferredSampleRate; /*!< Preferred sample rate, eg. for WASAPI the system sample rate. */ 292 | RtAudioFormat nativeFormats; /*!< Bit mask of supported data formats. */ 293 | 294 | // Default constructor. 295 | DeviceInfo() 296 | :probed(false), outputChannels(0), inputChannels(0), duplexChannels(0), 297 | isDefaultOutput(false), isDefaultInput(false), preferredSampleRate(0), nativeFormats(0) {} 298 | }; 299 | 300 | //! The structure for specifying input or ouput stream parameters. 301 | struct StreamParameters { 302 | unsigned int deviceId; /*!< Device index (0 to getDeviceCount() - 1). */ 303 | unsigned int nChannels; /*!< Number of channels. */ 304 | unsigned int firstChannel; /*!< First channel index on device (default = 0). */ 305 | 306 | // Default constructor. 307 | StreamParameters() 308 | : deviceId(0), nChannels(0), firstChannel(0) {} 309 | }; 310 | 311 | //! The structure for specifying stream options. 312 | /*! 313 | The following flags can be OR'ed together to allow a client to 314 | make changes to the default stream behavior: 315 | 316 | - \e RTAUDIO_NONINTERLEAVED: Use non-interleaved buffers (default = interleaved). 317 | - \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency. 318 | - \e RTAUDIO_HOG_DEVICE: Attempt grab device for exclusive use. 319 | - \e RTAUDIO_SCHEDULE_REALTIME: Attempt to select realtime scheduling for callback thread. 320 | - \e RTAUDIO_ALSA_USE_DEFAULT: Use the "default" PCM device (ALSA only). 321 | 322 | By default, RtAudio streams pass and receive audio data from the 323 | client in an interleaved format. By passing the 324 | RTAUDIO_NONINTERLEAVED flag to the openStream() function, audio 325 | data will instead be presented in non-interleaved buffers. In 326 | this case, each buffer argument in the RtAudioCallback function 327 | will point to a single array of data, with \c nFrames samples for 328 | each channel concatenated back-to-back. For example, the first 329 | sample of data for the second channel would be located at index \c 330 | nFrames (assuming the \c buffer pointer was recast to the correct 331 | data type for the stream). 332 | 333 | Certain audio APIs offer a number of parameters that influence the 334 | I/O latency of a stream. By default, RtAudio will attempt to set 335 | these parameters internally for robust (glitch-free) performance 336 | (though some APIs, like Windows Direct Sound, make this difficult). 337 | By passing the RTAUDIO_MINIMIZE_LATENCY flag to the openStream() 338 | function, internal stream settings will be influenced in an attempt 339 | to minimize stream latency, though possibly at the expense of stream 340 | performance. 341 | 342 | If the RTAUDIO_HOG_DEVICE flag is set, RtAudio will attempt to 343 | open the input and/or output stream device(s) for exclusive use. 344 | Note that this is not possible with all supported audio APIs. 345 | 346 | If the RTAUDIO_SCHEDULE_REALTIME flag is set, RtAudio will attempt 347 | to select realtime scheduling (round-robin) for the callback thread. 348 | The \c priority parameter will only be used if the RTAUDIO_SCHEDULE_REALTIME 349 | flag is set. It defines the thread's realtime priority. 350 | 351 | If the RTAUDIO_ALSA_USE_DEFAULT flag is set, RtAudio will attempt to 352 | open the "default" PCM device when using the ALSA API. Note that this 353 | will override any specified input or output device id. 354 | 355 | The \c numberOfBuffers parameter can be used to control stream 356 | latency in the Windows DirectSound, Linux OSS, and Linux Alsa APIs 357 | only. A value of two is usually the smallest allowed. Larger 358 | numbers can potentially result in more robust stream performance, 359 | though likely at the cost of stream latency. The value set by the 360 | user is replaced during execution of the RtAudio::openStream() 361 | function by the value actually used by the system. 362 | 363 | The \c streamName parameter can be used to set the client name 364 | when using the Jack API. By default, the client name is set to 365 | RtApiJack. However, if you wish to create multiple instances of 366 | RtAudio with Jack, each instance must have a unique client name. 367 | */ 368 | struct StreamOptions { 369 | RtAudioStreamFlags flags; /*!< A bit-mask of stream flags (RTAUDIO_NONINTERLEAVED, RTAUDIO_MINIMIZE_LATENCY, RTAUDIO_HOG_DEVICE, RTAUDIO_ALSA_USE_DEFAULT). */ 370 | unsigned int numberOfBuffers; /*!< Number of stream buffers. */ 371 | std::string streamName; /*!< A stream name (currently used only in Jack). */ 372 | int priority; /*!< Scheduling priority of callback thread (only used with flag RTAUDIO_SCHEDULE_REALTIME). */ 373 | 374 | // Default constructor. 375 | StreamOptions() 376 | : flags(0), numberOfBuffers(0), priority(0) {} 377 | }; 378 | 379 | //! A static function to determine the current RtAudio version. 380 | static std::string getVersion( void ); 381 | 382 | //! A static function to determine the available compiled audio APIs. 383 | /*! 384 | The values returned in the std::vector can be compared against 385 | the enumerated list values. Note that there can be more than one 386 | API compiled for certain operating systems. 387 | */ 388 | static void getCompiledApi( std::vector &apis ); 389 | 390 | //! The class constructor. 391 | /*! 392 | The constructor performs minor initialization tasks. An exception 393 | can be thrown if no API support is compiled. 394 | 395 | If no API argument is specified and multiple API support has been 396 | compiled, the default order of use is JACK, ALSA, OSS (Linux 397 | systems) and ASIO, DS (Windows systems). 398 | */ 399 | RtAudio( RtAudio::Api api=UNSPECIFIED ); 400 | 401 | //! The destructor. 402 | /*! 403 | If a stream is running or open, it will be stopped and closed 404 | automatically. 405 | */ 406 | ~RtAudio(); 407 | 408 | //! Returns the audio API specifier for the current instance of RtAudio. 409 | RtAudio::Api getCurrentApi( void ); 410 | 411 | //! A public function that queries for the number of audio devices available. 412 | /*! 413 | This function performs a system query of available devices each time it 414 | is called, thus supporting devices connected \e after instantiation. If 415 | a system error occurs during processing, a warning will be issued. 416 | */ 417 | unsigned int getDeviceCount( void ); 418 | 419 | //! Return an RtAudio::DeviceInfo structure for a specified device number. 420 | /*! 421 | 422 | Any device integer between 0 and getDeviceCount() - 1 is valid. 423 | If an invalid argument is provided, an RtAudioError (type = INVALID_USE) 424 | will be thrown. If a device is busy or otherwise unavailable, the 425 | structure member "probed" will have a value of "false" and all 426 | other members are undefined. If the specified device is the 427 | current default input or output device, the corresponding 428 | "isDefault" member will have a value of "true". 429 | */ 430 | RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); 431 | 432 | //! A function that returns the index of the default output device. 433 | /*! 434 | If the underlying audio API does not provide a "default 435 | device", or if no devices are available, the return value will be 436 | 0. Note that this is a valid device identifier and it is the 437 | client's responsibility to verify that a device is available 438 | before attempting to open a stream. 439 | */ 440 | unsigned int getDefaultOutputDevice( void ); 441 | 442 | //! A function that returns the index of the default input device. 443 | /*! 444 | If the underlying audio API does not provide a "default 445 | device", or if no devices are available, the return value will be 446 | 0. Note that this is a valid device identifier and it is the 447 | client's responsibility to verify that a device is available 448 | before attempting to open a stream. 449 | */ 450 | unsigned int getDefaultInputDevice( void ); 451 | 452 | //! A public function for opening a stream with the specified parameters. 453 | /*! 454 | An RtAudioError (type = SYSTEM_ERROR) is thrown if a stream cannot be 455 | opened with the specified parameters or an error occurs during 456 | processing. An RtAudioError (type = INVALID_USE) is thrown if any 457 | invalid device ID or channel number parameters are specified. 458 | 459 | \param outputParameters Specifies output stream parameters to use 460 | when opening a stream, including a device ID, number of channels, 461 | and starting channel number. For input-only streams, this 462 | argument should be NULL. The device ID is an index value between 463 | 0 and getDeviceCount() - 1. 464 | \param inputParameters Specifies input stream parameters to use 465 | when opening a stream, including a device ID, number of channels, 466 | and starting channel number. For output-only streams, this 467 | argument should be NULL. The device ID is an index value between 468 | 0 and getDeviceCount() - 1. 469 | \param format An RtAudioFormat specifying the desired sample data format. 470 | \param sampleRate The desired sample rate (sample frames per second). 471 | \param *bufferFrames A pointer to a value indicating the desired 472 | internal buffer size in sample frames. The actual value 473 | used by the device is returned via the same pointer. A 474 | value of zero can be specified, in which case the lowest 475 | allowable value is determined. 476 | \param callback A client-defined function that will be invoked 477 | when input data is available and/or output data is needed. 478 | \param userData An optional pointer to data that can be accessed 479 | from within the callback function. 480 | \param options An optional pointer to a structure containing various 481 | global stream options, including a list of OR'ed RtAudioStreamFlags 482 | and a suggested number of stream buffers that can be used to 483 | control stream latency. More buffers typically result in more 484 | robust performance, though at a cost of greater latency. If a 485 | value of zero is specified, a system-specific median value is 486 | chosen. If the RTAUDIO_MINIMIZE_LATENCY flag bit is set, the 487 | lowest allowable value is used. The actual value used is 488 | returned via the structure argument. The parameter is API dependent. 489 | \param errorCallback A client-defined function that will be invoked 490 | when an error has occured. 491 | */ 492 | void openStream( RtAudio::StreamParameters *outputParameters, 493 | RtAudio::StreamParameters *inputParameters, 494 | RtAudioFormat format, unsigned int sampleRate, 495 | unsigned int *bufferFrames, RtAudioCallback callback, 496 | void *userData = NULL, RtAudio::StreamOptions *options = NULL, RtAudioErrorCallback errorCallback = NULL ); 497 | 498 | //! A function that closes a stream and frees any associated stream memory. 499 | /*! 500 | If a stream is not open, this function issues a warning and 501 | returns (no exception is thrown). 502 | */ 503 | void closeStream( void ); 504 | 505 | //! A function that starts a stream. 506 | /*! 507 | An RtAudioError (type = SYSTEM_ERROR) is thrown if an error occurs 508 | during processing. An RtAudioError (type = INVALID_USE) is thrown if a 509 | stream is not open. A warning is issued if the stream is already 510 | running. 511 | */ 512 | void startStream( void ); 513 | 514 | //! Stop a stream, allowing any samples remaining in the output queue to be played. 515 | /*! 516 | An RtAudioError (type = SYSTEM_ERROR) is thrown if an error occurs 517 | during processing. An RtAudioError (type = INVALID_USE) is thrown if a 518 | stream is not open. A warning is issued if the stream is already 519 | stopped. 520 | */ 521 | void stopStream( void ); 522 | 523 | //! Stop a stream, discarding any samples remaining in the input/output queue. 524 | /*! 525 | An RtAudioError (type = SYSTEM_ERROR) is thrown if an error occurs 526 | during processing. An RtAudioError (type = INVALID_USE) is thrown if a 527 | stream is not open. A warning is issued if the stream is already 528 | stopped. 529 | */ 530 | void abortStream( void ); 531 | 532 | //! Returns true if a stream is open and false if not. 533 | bool isStreamOpen( void ) const; 534 | 535 | //! Returns true if the stream is running and false if it is stopped or not open. 536 | bool isStreamRunning( void ) const; 537 | 538 | //! Returns the number of elapsed seconds since the stream was started. 539 | /*! 540 | If a stream is not open, an RtAudioError (type = INVALID_USE) will be thrown. 541 | */ 542 | double getStreamTime( void ); 543 | 544 | //! Set the stream time to a time in seconds greater than or equal to 0.0. 545 | /*! 546 | If a stream is not open, an RtAudioError (type = INVALID_USE) will be thrown. 547 | */ 548 | void setStreamTime( double time ); 549 | 550 | //! Returns the internal stream latency in sample frames. 551 | /*! 552 | The stream latency refers to delay in audio input and/or output 553 | caused by internal buffering by the audio system and/or hardware. 554 | For duplex streams, the returned value will represent the sum of 555 | the input and output latencies. If a stream is not open, an 556 | RtAudioError (type = INVALID_USE) will be thrown. If the API does not 557 | report latency, the return value will be zero. 558 | */ 559 | long getStreamLatency( void ); 560 | 561 | //! Returns actual sample rate in use by the stream. 562 | /*! 563 | On some systems, the sample rate used may be slightly different 564 | than that specified in the stream parameters. If a stream is not 565 | open, an RtAudioError (type = INVALID_USE) will be thrown. 566 | */ 567 | unsigned int getStreamSampleRate( void ); 568 | 569 | //! Specify whether warning messages should be printed to stderr. 570 | void showWarnings( bool value = true ); 571 | 572 | protected: 573 | 574 | void openRtApi( RtAudio::Api api ); 575 | RtApi *rtapi_; 576 | }; 577 | 578 | // Operating system dependent thread functionality. 579 | #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_WASAPI__) 580 | 581 | #ifndef NOMINMAX 582 | #define NOMINMAX 583 | #endif 584 | #include 585 | #include 586 | 587 | typedef uintptr_t ThreadHandle; 588 | typedef CRITICAL_SECTION StreamMutex; 589 | 590 | #elif defined(__LINUX_ALSA__) || defined(__LINUX_PULSE__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__) 591 | // Using pthread library for various flavors of unix. 592 | #include 593 | 594 | typedef pthread_t ThreadHandle; 595 | typedef pthread_mutex_t StreamMutex; 596 | 597 | #else // Setup for "dummy" behavior 598 | 599 | #define __RTAUDIO_DUMMY__ 600 | typedef int ThreadHandle; 601 | typedef int StreamMutex; 602 | 603 | #endif 604 | 605 | // This global structure type is used to pass callback information 606 | // between the private RtAudio stream structure and global callback 607 | // handling functions. 608 | struct CallbackInfo { 609 | void *object; // Used as a "this" pointer. 610 | ThreadHandle thread; 611 | void *callback; 612 | void *userData; 613 | void *errorCallback; 614 | void *apiInfo; // void pointer for API specific callback information 615 | bool isRunning; 616 | bool doRealtime; 617 | int priority; 618 | 619 | // Default constructor. 620 | CallbackInfo() 621 | :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false), priority(0) {} 622 | }; 623 | 624 | // **************************************************************** // 625 | // 626 | // RtApi class declaration. 627 | // 628 | // Subclasses of RtApi contain all API- and OS-specific code necessary 629 | // to fully implement the RtAudio API. 630 | // 631 | // Note that RtApi is an abstract base class and cannot be 632 | // explicitly instantiated. The class RtAudio will create an 633 | // instance of an RtApi subclass (RtApiOss, RtApiAlsa, 634 | // RtApiJack, RtApiCore, RtApiDs, or RtApiAsio). 635 | // 636 | // **************************************************************** // 637 | 638 | #pragma pack(push, 1) 639 | class S24 { 640 | 641 | protected: 642 | unsigned char c3[3]; 643 | 644 | public: 645 | S24() {} 646 | 647 | S24& operator = ( const int& i ) { 648 | c3[0] = (i & 0x000000ff); 649 | c3[1] = (i & 0x0000ff00) >> 8; 650 | c3[2] = (i & 0x00ff0000) >> 16; 651 | return *this; 652 | } 653 | 654 | S24( const S24& v ) { *this = v; } 655 | S24( const double& d ) { *this = (int) d; } 656 | S24( const float& f ) { *this = (int) f; } 657 | S24( const signed short& s ) { *this = (int) s; } 658 | S24( const char& c ) { *this = (int) c; } 659 | 660 | int asInt() { 661 | int i = c3[0] | (c3[1] << 8) | (c3[2] << 16); 662 | if (i & 0x800000) i |= ~0xffffff; 663 | return i; 664 | } 665 | }; 666 | #pragma pack(pop) 667 | 668 | #if defined( HAVE_GETTIMEOFDAY ) 669 | #include 670 | #endif 671 | 672 | #include 673 | 674 | class RtApi 675 | { 676 | public: 677 | 678 | RtApi(); 679 | virtual ~RtApi(); 680 | virtual RtAudio::Api getCurrentApi( void ) = 0; 681 | virtual unsigned int getDeviceCount( void ) = 0; 682 | virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0; 683 | virtual unsigned int getDefaultInputDevice( void ); 684 | virtual unsigned int getDefaultOutputDevice( void ); 685 | void openStream( RtAudio::StreamParameters *outputParameters, 686 | RtAudio::StreamParameters *inputParameters, 687 | RtAudioFormat format, unsigned int sampleRate, 688 | unsigned int *bufferFrames, RtAudioCallback callback, 689 | void *userData, RtAudio::StreamOptions *options, 690 | RtAudioErrorCallback errorCallback ); 691 | virtual void closeStream( void ); 692 | virtual void startStream( void ) = 0; 693 | virtual void stopStream( void ) = 0; 694 | virtual void abortStream( void ) = 0; 695 | long getStreamLatency( void ); 696 | unsigned int getStreamSampleRate( void ); 697 | virtual double getStreamTime( void ); 698 | virtual void setStreamTime( double time ); 699 | bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; } 700 | bool isStreamRunning( void ) const { return stream_.state == STREAM_RUNNING; } 701 | void showWarnings( bool value ) { showWarnings_ = value; } 702 | 703 | 704 | protected: 705 | 706 | static const unsigned int MAX_SAMPLE_RATES; 707 | static const unsigned int SAMPLE_RATES[]; 708 | 709 | enum { FAILURE, SUCCESS }; 710 | 711 | enum StreamState { 712 | STREAM_STOPPED, 713 | STREAM_STOPPING, 714 | STREAM_RUNNING, 715 | STREAM_CLOSED = -50 716 | }; 717 | 718 | enum StreamMode { 719 | OUTPUT, 720 | INPUT, 721 | DUPLEX, 722 | UNINITIALIZED = -75 723 | }; 724 | 725 | // A protected structure used for buffer conversion. 726 | struct ConvertInfo { 727 | int channels; 728 | int inJump, outJump; 729 | RtAudioFormat inFormat, outFormat; 730 | std::vector inOffset; 731 | std::vector outOffset; 732 | }; 733 | 734 | // A protected structure for audio streams. 735 | struct RtApiStream { 736 | unsigned int device[2]; // Playback and record, respectively. 737 | void *apiHandle; // void pointer for API specific stream handle information 738 | StreamMode mode; // OUTPUT, INPUT, or DUPLEX. 739 | StreamState state; // STOPPED, RUNNING, or CLOSED 740 | char *userBuffer[2]; // Playback and record, respectively. 741 | char *deviceBuffer; 742 | bool doConvertBuffer[2]; // Playback and record, respectively. 743 | bool userInterleaved; 744 | bool deviceInterleaved[2]; // Playback and record, respectively. 745 | bool doByteSwap[2]; // Playback and record, respectively. 746 | unsigned int sampleRate; 747 | unsigned int bufferSize; 748 | unsigned int nBuffers; 749 | unsigned int nUserChannels[2]; // Playback and record, respectively. 750 | unsigned int nDeviceChannels[2]; // Playback and record channels, respectively. 751 | unsigned int channelOffset[2]; // Playback and record, respectively. 752 | unsigned long latency[2]; // Playback and record, respectively. 753 | RtAudioFormat userFormat; 754 | RtAudioFormat deviceFormat[2]; // Playback and record, respectively. 755 | StreamMutex mutex; 756 | CallbackInfo callbackInfo; 757 | ConvertInfo convertInfo[2]; 758 | double streamTime; // Number of elapsed seconds since the stream started. 759 | 760 | #if defined(HAVE_GETTIMEOFDAY) 761 | struct timeval lastTickTimestamp; 762 | #endif 763 | 764 | RtApiStream() 765 | :apiHandle(0), deviceBuffer(0) { device[0] = 11111; device[1] = 11111; } 766 | }; 767 | 768 | typedef S24 Int24; 769 | typedef signed short Int16; 770 | typedef signed int Int32; 771 | typedef float Float32; 772 | typedef double Float64; 773 | 774 | std::ostringstream errorStream_; 775 | std::string errorText_; 776 | bool showWarnings_; 777 | RtApiStream stream_; 778 | bool firstErrorOccurred_; 779 | 780 | /*! 781 | Protected, api-specific method that attempts to open a device 782 | with the given parameters. This function MUST be implemented by 783 | all subclasses. If an error is encountered during the probe, a 784 | "warning" message is reported and FAILURE is returned. A 785 | successful probe is indicated by a return value of SUCCESS. 786 | */ 787 | virtual bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 788 | unsigned int firstChannel, unsigned int sampleRate, 789 | RtAudioFormat format, unsigned int *bufferSize, 790 | RtAudio::StreamOptions *options ); 791 | 792 | //! A protected function used to increment the stream time. 793 | void tickStreamTime( void ); 794 | 795 | //! Protected common method to clear an RtApiStream structure. 796 | void clearStreamInfo(); 797 | 798 | /*! 799 | Protected common method that throws an RtAudioError (type = 800 | INVALID_USE) if a stream is not open. 801 | */ 802 | void verifyStream( void ); 803 | 804 | //! Protected common error method to allow global control over error handling. 805 | void error( RtAudioError::Type type ); 806 | 807 | /*! 808 | Protected method used to perform format, channel number, and/or interleaving 809 | conversions between the user and device buffers. 810 | */ 811 | void convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info ); 812 | 813 | //! Protected common method used to perform byte-swapping on buffers. 814 | void byteSwapBuffer( char *buffer, unsigned int samples, RtAudioFormat format ); 815 | 816 | //! Protected common method that returns the number of bytes for a given format. 817 | unsigned int formatBytes( RtAudioFormat format ); 818 | 819 | //! Protected common method that sets up the parameters for buffer conversion. 820 | void setConvertInfo( StreamMode mode, unsigned int firstChannel ); 821 | }; 822 | 823 | // **************************************************************** // 824 | // 825 | // Inline RtAudio definitions. 826 | // 827 | // **************************************************************** // 828 | 829 | inline RtAudio::Api RtAudio :: getCurrentApi( void ) { return rtapi_->getCurrentApi(); } 830 | inline unsigned int RtAudio :: getDeviceCount( void ) { return rtapi_->getDeviceCount(); } 831 | inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); } 832 | inline unsigned int RtAudio :: getDefaultInputDevice( void ) { return rtapi_->getDefaultInputDevice(); } 833 | inline unsigned int RtAudio :: getDefaultOutputDevice( void ) { return rtapi_->getDefaultOutputDevice(); } 834 | inline void RtAudio :: closeStream( void ) { return rtapi_->closeStream(); } 835 | inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); } 836 | inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); } 837 | inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); } 838 | inline bool RtAudio :: isStreamOpen( void ) const { return rtapi_->isStreamOpen(); } 839 | inline bool RtAudio :: isStreamRunning( void ) const { return rtapi_->isStreamRunning(); } 840 | inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); } 841 | inline unsigned int RtAudio :: getStreamSampleRate( void ) { return rtapi_->getStreamSampleRate(); } 842 | inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); } 843 | inline void RtAudio :: setStreamTime( double time ) { return rtapi_->setStreamTime( time ); } 844 | inline void RtAudio :: showWarnings( bool value ) { rtapi_->showWarnings( value ); } 845 | 846 | // RtApi Subclass prototypes. 847 | 848 | #if defined(__MACOSX_CORE__) 849 | 850 | #include 851 | 852 | class RtApiCore: public RtApi 853 | { 854 | public: 855 | 856 | RtApiCore(); 857 | ~RtApiCore(); 858 | RtAudio::Api getCurrentApi( void ) { return RtAudio::MACOSX_CORE; } 859 | unsigned int getDeviceCount( void ); 860 | RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); 861 | unsigned int getDefaultOutputDevice( void ); 862 | unsigned int getDefaultInputDevice( void ); 863 | void closeStream( void ); 864 | void startStream( void ); 865 | void stopStream( void ); 866 | void abortStream( void ); 867 | long getStreamLatency( void ); 868 | 869 | // This function is intended for internal use only. It must be 870 | // public because it is called by the internal callback handler, 871 | // which is not a member of RtAudio. External use of this function 872 | // will most likely produce highly undesireable results! 873 | bool callbackEvent( AudioDeviceID deviceId, 874 | const AudioBufferList *inBufferList, 875 | const AudioBufferList *outBufferList ); 876 | 877 | private: 878 | 879 | bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 880 | unsigned int firstChannel, unsigned int sampleRate, 881 | RtAudioFormat format, unsigned int *bufferSize, 882 | RtAudio::StreamOptions *options ); 883 | static const char* getErrorCode( OSStatus code ); 884 | }; 885 | 886 | #endif 887 | 888 | #if defined(__UNIX_JACK__) 889 | 890 | class RtApiJack: public RtApi 891 | { 892 | public: 893 | 894 | RtApiJack(); 895 | ~RtApiJack(); 896 | RtAudio::Api getCurrentApi( void ) { return RtAudio::UNIX_JACK; } 897 | unsigned int getDeviceCount( void ); 898 | RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); 899 | void closeStream( void ); 900 | void startStream( void ); 901 | void stopStream( void ); 902 | void abortStream( void ); 903 | long getStreamLatency( void ); 904 | 905 | // This function is intended for internal use only. It must be 906 | // public because it is called by the internal callback handler, 907 | // which is not a member of RtAudio. External use of this function 908 | // will most likely produce highly undesireable results! 909 | bool callbackEvent( unsigned long nframes ); 910 | 911 | private: 912 | 913 | bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 914 | unsigned int firstChannel, unsigned int sampleRate, 915 | RtAudioFormat format, unsigned int *bufferSize, 916 | RtAudio::StreamOptions *options ); 917 | 918 | bool shouldAutoconnect_; 919 | }; 920 | 921 | #endif 922 | 923 | #if defined(__WINDOWS_ASIO__) 924 | 925 | class RtApiAsio: public RtApi 926 | { 927 | public: 928 | 929 | RtApiAsio(); 930 | ~RtApiAsio(); 931 | RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_ASIO; } 932 | unsigned int getDeviceCount( void ); 933 | RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); 934 | void closeStream( void ); 935 | void startStream( void ); 936 | void stopStream( void ); 937 | void abortStream( void ); 938 | long getStreamLatency( void ); 939 | 940 | // This function is intended for internal use only. It must be 941 | // public because it is called by the internal callback handler, 942 | // which is not a member of RtAudio. External use of this function 943 | // will most likely produce highly undesireable results! 944 | bool callbackEvent( long bufferIndex ); 945 | 946 | private: 947 | 948 | std::vector devices_; 949 | void saveDeviceInfo( void ); 950 | bool coInitialized_; 951 | bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 952 | unsigned int firstChannel, unsigned int sampleRate, 953 | RtAudioFormat format, unsigned int *bufferSize, 954 | RtAudio::StreamOptions *options ); 955 | }; 956 | 957 | #endif 958 | 959 | #if defined(__WINDOWS_DS__) 960 | 961 | class RtApiDs: public RtApi 962 | { 963 | public: 964 | 965 | RtApiDs(); 966 | ~RtApiDs(); 967 | RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_DS; } 968 | unsigned int getDeviceCount( void ); 969 | unsigned int getDefaultOutputDevice( void ); 970 | unsigned int getDefaultInputDevice( void ); 971 | RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); 972 | void closeStream( void ); 973 | void startStream( void ); 974 | void stopStream( void ); 975 | void abortStream( void ); 976 | long getStreamLatency( void ); 977 | 978 | // This function is intended for internal use only. It must be 979 | // public because it is called by the internal callback handler, 980 | // which is not a member of RtAudio. External use of this function 981 | // will most likely produce highly undesireable results! 982 | void callbackEvent( void ); 983 | 984 | private: 985 | 986 | bool coInitialized_; 987 | bool buffersRolling; 988 | long duplexPrerollBytes; 989 | std::vector dsDevices; 990 | bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 991 | unsigned int firstChannel, unsigned int sampleRate, 992 | RtAudioFormat format, unsigned int *bufferSize, 993 | RtAudio::StreamOptions *options ); 994 | }; 995 | 996 | #endif 997 | 998 | #if defined(__WINDOWS_WASAPI__) 999 | 1000 | struct IMMDeviceEnumerator; 1001 | 1002 | class RtApiWasapi : public RtApi 1003 | { 1004 | public: 1005 | RtApiWasapi(); 1006 | ~RtApiWasapi(); 1007 | 1008 | RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_WASAPI; } 1009 | unsigned int getDeviceCount( void ); 1010 | RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); 1011 | unsigned int getDefaultOutputDevice( void ); 1012 | unsigned int getDefaultInputDevice( void ); 1013 | void closeStream( void ); 1014 | void startStream( void ); 1015 | void stopStream( void ); 1016 | void abortStream( void ); 1017 | 1018 | private: 1019 | bool coInitialized_; 1020 | IMMDeviceEnumerator* deviceEnumerator_; 1021 | 1022 | bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 1023 | unsigned int firstChannel, unsigned int sampleRate, 1024 | RtAudioFormat format, unsigned int* bufferSize, 1025 | RtAudio::StreamOptions* options ); 1026 | 1027 | static DWORD WINAPI runWasapiThread( void* wasapiPtr ); 1028 | static DWORD WINAPI stopWasapiThread( void* wasapiPtr ); 1029 | static DWORD WINAPI abortWasapiThread( void* wasapiPtr ); 1030 | void wasapiThread(); 1031 | }; 1032 | 1033 | #endif 1034 | 1035 | #if defined(__LINUX_ALSA__) 1036 | 1037 | class RtApiAlsa: public RtApi 1038 | { 1039 | public: 1040 | 1041 | RtApiAlsa(); 1042 | ~RtApiAlsa(); 1043 | RtAudio::Api getCurrentApi() { return RtAudio::LINUX_ALSA; } 1044 | unsigned int getDeviceCount( void ); 1045 | RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); 1046 | void closeStream( void ); 1047 | void startStream( void ); 1048 | void stopStream( void ); 1049 | void abortStream( void ); 1050 | 1051 | // This function is intended for internal use only. It must be 1052 | // public because it is called by the internal callback handler, 1053 | // which is not a member of RtAudio. External use of this function 1054 | // will most likely produce highly undesireable results! 1055 | void callbackEvent( void ); 1056 | 1057 | private: 1058 | 1059 | std::vector devices_; 1060 | void saveDeviceInfo( void ); 1061 | bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 1062 | unsigned int firstChannel, unsigned int sampleRate, 1063 | RtAudioFormat format, unsigned int *bufferSize, 1064 | RtAudio::StreamOptions *options ); 1065 | }; 1066 | 1067 | #endif 1068 | 1069 | #if defined(__LINUX_PULSE__) 1070 | 1071 | class RtApiPulse: public RtApi 1072 | { 1073 | public: 1074 | ~RtApiPulse(); 1075 | RtAudio::Api getCurrentApi() { return RtAudio::LINUX_PULSE; } 1076 | unsigned int getDeviceCount( void ); 1077 | RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); 1078 | void closeStream( void ); 1079 | void startStream( void ); 1080 | void stopStream( void ); 1081 | void abortStream( void ); 1082 | 1083 | // This function is intended for internal use only. It must be 1084 | // public because it is called by the internal callback handler, 1085 | // which is not a member of RtAudio. External use of this function 1086 | // will most likely produce highly undesireable results! 1087 | void callbackEvent( void ); 1088 | 1089 | private: 1090 | 1091 | std::vector devices_; 1092 | void saveDeviceInfo( void ); 1093 | bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 1094 | unsigned int firstChannel, unsigned int sampleRate, 1095 | RtAudioFormat format, unsigned int *bufferSize, 1096 | RtAudio::StreamOptions *options ); 1097 | }; 1098 | 1099 | #endif 1100 | 1101 | #if defined(__LINUX_OSS__) 1102 | 1103 | class RtApiOss: public RtApi 1104 | { 1105 | public: 1106 | 1107 | RtApiOss(); 1108 | ~RtApiOss(); 1109 | RtAudio::Api getCurrentApi() { return RtAudio::LINUX_OSS; } 1110 | unsigned int getDeviceCount( void ); 1111 | RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); 1112 | void closeStream( void ); 1113 | void startStream( void ); 1114 | void stopStream( void ); 1115 | void abortStream( void ); 1116 | 1117 | // This function is intended for internal use only. It must be 1118 | // public because it is called by the internal callback handler, 1119 | // which is not a member of RtAudio. External use of this function 1120 | // will most likely produce highly undesireable results! 1121 | void callbackEvent( void ); 1122 | 1123 | private: 1124 | 1125 | bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 1126 | unsigned int firstChannel, unsigned int sampleRate, 1127 | RtAudioFormat format, unsigned int *bufferSize, 1128 | RtAudio::StreamOptions *options ); 1129 | }; 1130 | 1131 | #endif 1132 | 1133 | #if defined(__RTAUDIO_DUMMY__) 1134 | 1135 | class RtApiDummy: public RtApi 1136 | { 1137 | public: 1138 | 1139 | RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( RtAudioError::WARNING ); } 1140 | RtAudio::Api getCurrentApi( void ) { return RtAudio::RTAUDIO_DUMMY; } 1141 | unsigned int getDeviceCount( void ) { return 0; } 1142 | RtAudio::DeviceInfo getDeviceInfo( unsigned int /*device*/ ) { RtAudio::DeviceInfo info; return info; } 1143 | void closeStream( void ) {} 1144 | void startStream( void ) {} 1145 | void stopStream( void ) {} 1146 | void abortStream( void ) {} 1147 | 1148 | private: 1149 | 1150 | bool probeDeviceOpen( unsigned int /*device*/, StreamMode /*mode*/, unsigned int /*channels*/, 1151 | unsigned int /*firstChannel*/, unsigned int /*sampleRate*/, 1152 | RtAudioFormat /*format*/, unsigned int * /*bufferSize*/, 1153 | RtAudio::StreamOptions * /*options*/ ) { return false; } 1154 | }; 1155 | 1156 | #endif 1157 | 1158 | #endif 1159 | 1160 | // Indentation settings for Vim and Emacs 1161 | // 1162 | // Local Variables: 1163 | // c-basic-offset: 2 1164 | // indent-tabs-mode: nil 1165 | // End: 1166 | // 1167 | // vim: et sts=2 sw=2 1168 | -------------------------------------------------------------------------------- /bin/libspeexdsp-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingyuejingque/rtaudio_speex/e77f7ad9e66f26e8283bd2313ea9213557b8d7f7/bin/libspeexdsp-1.dll -------------------------------------------------------------------------------- /from_file.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "RtAudio.h" 10 | #include "speex_func.h" 11 | 12 | //测试目标: 13 | /* 14 | 1 改成从文件读入数据,当作远端传来的音频 remote.pcm 15 | 2 把mic读到数据写到文件 cap.pcm 16 | 3 把speex 处理后的数据写到文件 cancel.pcm 17 | */ 18 | 19 | const int delay_count = 1; 20 | const int channels = 1; 21 | const int fmt = RTAUDIO_SINT16; 22 | static unsigned int sampleRate = 8000; 23 | static unsigned int bufferFrames = 160; 24 | static unsigned int tail = bufferFrames * 8; 25 | std::mutex g_mutex; 26 | 27 | typedef struct buffer_s { 28 | unsigned short buff[320]; 29 | } buffer_t; 30 | 31 | 32 | std::queue inputq; 33 | 34 | int input_cb(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, 35 | double streamTime, RtAudioStreamStatus status, void *userData) 36 | { 37 | if (status) 38 | std::cout << "Stream overflow detected!" << status << std::endl; 39 | // Do something with the data in the "inputBuffer" buffer. 40 | 41 | size_t size = nBufferFrames * channels * 2; 42 | 43 | static FILE* fi = fopen("./cap.pcm", "wb"); 44 | fwrite(inputBuffer, 1, size, fi); 45 | 46 | std::lock_guard guard(g_mutex); 47 | buffer_t bf; 48 | memcpy(bf.buff, inputBuffer, size); 49 | inputq.push(bf); 50 | 51 | return 0; 52 | } 53 | 54 | int output_cb(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, 55 | double streamTime, RtAudioStreamStatus status, void *userData) 56 | { 57 | if (status) 58 | std::cout << "Stream overflow detected!" << status << std::endl; 59 | // Do something with the data in the "inputBuffer" buffer. 60 | 61 | size_t want_size = nBufferFrames * channels * 2; 62 | static FILE* fp = fopen("remote.pcm", "rb"); 63 | fread(outputBuffer, 1, want_size, fp); 64 | 65 | buffer_t in; 66 | memset(in.buff, 0, sizeof(in.buff)); 67 | std::lock_guard guard(g_mutex); 68 | if (inputq.size() >= delay_count) { 69 | memcpy(in.buff, inputq.front().buff, sizeof(in.buff)); 70 | inputq.pop(); 71 | } 72 | static buffer_t out; 73 | static FILE* fr = fopen("cancel.pcm", "wb"); 74 | speex_func_echo_cancel((short*)in.buff, (short*)outputBuffer, (short*)out.buff); 75 | fwrite(out.buff, 1, want_size, fr); 76 | //降噪后的输出缓冲区 77 | 78 | return 0; 79 | } 80 | 81 | void stream_filter() { 82 | RtAudio adc_input, adc_output; 83 | if (adc_input.getDeviceCount() < 1) { 84 | std::cout << "\nNo audio devices found!\n"; 85 | exit(0); 86 | } 87 | RtAudio::StreamParameters in; 88 | in.deviceId = adc_input.getDefaultInputDevice(); 89 | in.nChannels = channels; 90 | in.firstChannel = 0; 91 | 92 | auto out = in; 93 | out.deviceId = adc_output.getDefaultOutputDevice(); 94 | std::cout << "input device: " << in.deviceId 95 | << " output device: " << out.deviceId 96 | << std::endl; 97 | try { 98 | adc_input.openStream(nullptr, &in, fmt, 99 | sampleRate, &bufferFrames, &input_cb, &adc_input); 100 | adc_input.startStream(); 101 | 102 | adc_output.openStream(&out, nullptr, fmt, 103 | sampleRate, &bufferFrames, &output_cb, &adc_output); 104 | adc_output.startStream(); 105 | } 106 | catch (RtAudioError& e) { 107 | e.printMessage(); 108 | exit(0); 109 | } 110 | 111 | char input; 112 | std::cout << "\nRecording ... press to quit.\n"; 113 | std::cin.get(input); 114 | try { 115 | // Stop the stream 116 | adc_output.stopStream(); 117 | adc_input.stopStream(); 118 | } 119 | catch (RtAudioError& e) { 120 | e.printMessage(); 121 | } 122 | if (adc_input.isStreamOpen()) adc_input.closeStream(); 123 | if (adc_output.isStreamOpen()) adc_output.closeStream(); 124 | } 125 | 126 | int main() 127 | { 128 | speex_func_init(bufferFrames, tail, sampleRate); 129 | stream_filter(); 130 | speex_func_destroy(); 131 | return 0; 132 | } 133 | 134 | -------------------------------------------------------------------------------- /from_mic.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "RtAudio.h" 10 | #include "speex_func.h" 11 | 12 | /* 13 | 从mic 里捕获的数据,发送给喇叭之前缓存一下, 14 | 作为speex的参考。 15 | */ 16 | 17 | const int delay_count = 1; 18 | const int channels = 1; 19 | const int fmt = RTAUDIO_SINT16; 20 | unsigned int sampleRate = 8000; 21 | unsigned int bufferFrames = 160; 22 | std::mutex g_mutex; 23 | 24 | typedef struct buffer_s { 25 | char buff[320]; 26 | } buffer_t; 27 | 28 | std::queue capq; //capture form mic. 29 | std::queue refq; //ref by speexdsp. 30 | 31 | int input_cb(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, 32 | double streamTime, RtAudioStreamStatus status, void *userData) 33 | { 34 | if (status) 35 | std::cout << "Stream overflow detected!" << status << std::endl; 36 | // Do something with the data in the "inputBuffer" buffer. 37 | 38 | size_t size = nBufferFrames * channels * 2; 39 | std::lock_guard guard(g_mutex); 40 | buffer_t bf; 41 | memcpy(bf.buff, inputBuffer, size); 42 | capq.push(bf); 43 | #ifdef DEBUG 44 | std::cout << "\t\t\t\t\t" << __func__ 45 | << " tid: " << std::this_thread::get_id() 46 | << " put bytes: " << size 47 | << std::endl; 48 | #endif 49 | if (refq.size() >= delay_count) { 50 | static buffer_t sbuf; 51 | static FILE* fp = fopen("cal.pcm", "wb"); 52 | speex_func_echo_cancel((short*)inputBuffer, (short*)refq.front().buff, (short*)sbuf.buff); 53 | fwrite(sbuf.buff, 1, size, fp); 54 | //降噪后的输出缓冲区 55 | } 56 | 57 | #if 0 58 | static FILE* fp = fopen("./out.pcm", "wb"); 59 | fwrite(inputBuffer, 1, size, fp); 60 | #endif 61 | return 0; 62 | } 63 | 64 | int output_cb(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, 65 | double streamTime, RtAudioStreamStatus status, void *userData) 66 | { 67 | if (status) 68 | std::cout << "Stream overflow detected!" << status << std::endl; 69 | // Do something with the data in the "inputBuffer" buffer. 70 | 71 | size_t want_size = nBufferFrames * channels * 2; 72 | 73 | #if 1 74 | size_t buf_size = 0; 75 | do { 76 | std::lock_guard guard(g_mutex); 77 | buf_size = capq.size(); 78 | if (buf_size > 0) { 79 | memcpy(outputBuffer, capq.front().buff, want_size); 80 | capq.pop(); 81 | 82 | buffer_t bf; 83 | memcpy(bf.buff, outputBuffer, want_size); 84 | refq.push(bf); 85 | break; 86 | } 87 | std::this_thread::yield(); 88 | } while(buf_size == 0); 89 | #endif 90 | 91 | static FILE* fp = fopen("play.pcm", "wb"); 92 | fwrite(outputBuffer, 1, want_size, fp); 93 | #ifdef DEBUG 94 | std::cout << __func__ 95 | << " tid: " << std::this_thread::get_id() 96 | << " writes bytes: " 97 | << want_size 98 | << " buff.size: " << capq.size() 99 | << std::endl; 100 | #endif 101 | return 0; 102 | } 103 | 104 | void stream_filter() { 105 | RtAudio adc_input, adc_output; 106 | if (adc_input.getDeviceCount() < 1) { 107 | std::cout << "\nNo audio devices found!\n"; 108 | exit(0); 109 | } 110 | RtAudio::StreamParameters in; 111 | in.deviceId = adc_input.getDefaultInputDevice(); 112 | in.nChannels = channels; 113 | in.firstChannel = 0; 114 | 115 | auto out = in; 116 | out.deviceId = adc_output.getDefaultOutputDevice(); 117 | std::cout << "input device: " << in.deviceId 118 | << " output device: " << out.deviceId 119 | << std::endl; 120 | try { 121 | adc_input.openStream(nullptr, &in, fmt, 122 | sampleRate, &bufferFrames, &input_cb, &adc_input); 123 | adc_input.startStream(); 124 | 125 | adc_output.openStream(&out, nullptr, fmt, 126 | sampleRate, &bufferFrames, &output_cb, &adc_output); 127 | adc_output.startStream(); 128 | } 129 | catch (RtAudioError& e) { 130 | e.printMessage(); 131 | exit(0); 132 | } 133 | 134 | char input; 135 | std::cout << "\nRecording ... press to quit.\n"; 136 | std::cin.get(input); 137 | try { 138 | // Stop the stream 139 | adc_output.stopStream(); 140 | adc_input.stopStream(); 141 | } 142 | catch (RtAudioError& e) { 143 | e.printMessage(); 144 | } 145 | if (adc_input.isStreamOpen()) adc_input.closeStream(); 146 | if (adc_output.isStreamOpen()) adc_output.closeStream(); 147 | } 148 | 149 | int main() 150 | { 151 | speex_func_init(bufferFrames, bufferFrames * 2, sampleRate); 152 | stream_filter(); 153 | speex_func_destroy(); 154 | return 0; 155 | } 156 | 157 | -------------------------------------------------------------------------------- /include/dsound.h: -------------------------------------------------------------------------------- 1 | /*==========================================================================; 2 | * 3 | * Copyright (c) Microsoft Corporation. All rights reserved. 4 | * 5 | * File: dsound.h 6 | * Content: DirectSound include file 7 | * 8 | **************************************************************************/ 9 | 10 | #define COM_NO_WINDOWS_H 11 | #include 12 | #include 13 | 14 | #ifndef DIRECTSOUND_VERSION 15 | #define DIRECTSOUND_VERSION 0x0900 /* Version 9.0 */ 16 | #endif 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif // __cplusplus 21 | 22 | #ifndef __DSOUND_INCLUDED__ 23 | #define __DSOUND_INCLUDED__ 24 | 25 | /* Type definitions shared with Direct3D */ 26 | 27 | #ifndef DX_SHARED_DEFINES 28 | 29 | typedef float D3DVALUE, *LPD3DVALUE; 30 | 31 | #ifndef D3DCOLOR_DEFINED 32 | typedef DWORD D3DCOLOR; 33 | #define D3DCOLOR_DEFINED 34 | #endif 35 | 36 | #ifndef LPD3DCOLOR_DEFINED 37 | typedef DWORD *LPD3DCOLOR; 38 | #define LPD3DCOLOR_DEFINED 39 | #endif 40 | 41 | #ifndef D3DVECTOR_DEFINED 42 | typedef struct _D3DVECTOR { 43 | float x; 44 | float y; 45 | float z; 46 | } D3DVECTOR; 47 | #define D3DVECTOR_DEFINED 48 | #endif 49 | 50 | #ifndef LPD3DVECTOR_DEFINED 51 | typedef D3DVECTOR *LPD3DVECTOR; 52 | #define LPD3DVECTOR_DEFINED 53 | #endif 54 | 55 | #define DX_SHARED_DEFINES 56 | #endif // DX_SHARED_DEFINES 57 | 58 | #define _FACDS 0x878 /* DirectSound's facility code */ 59 | #define MAKE_DSHRESULT(code) MAKE_HRESULT(1, _FACDS, code) 60 | 61 | // DirectSound Component GUID {47D4D946-62E8-11CF-93BC-444553540000} 62 | DEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); 63 | 64 | // DirectSound 8.0 Component GUID {3901CC3F-84B5-4FA4-BA35-AA8172B8A09B} 65 | DEFINE_GUID(CLSID_DirectSound8, 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b); 66 | 67 | // DirectSound Capture Component GUID {B0210780-89CD-11D0-AF08-00A0C925CD16} 68 | DEFINE_GUID(CLSID_DirectSoundCapture, 0xb0210780, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); 69 | 70 | // DirectSound 8.0 Capture Component GUID {E4BCAC13-7F99-4908-9A8E-74E3BF24B6E1} 71 | DEFINE_GUID(CLSID_DirectSoundCapture8, 0xe4bcac13, 0x7f99, 0x4908, 0x9a, 0x8e, 0x74, 0xe3, 0xbf, 0x24, 0xb6, 0xe1); 72 | 73 | // DirectSound Full Duplex Component GUID {FEA4300C-7959-4147-B26A-2377B9E7A91D} 74 | DEFINE_GUID(CLSID_DirectSoundFullDuplex, 0xfea4300c, 0x7959, 0x4147, 0xb2, 0x6a, 0x23, 0x77, 0xb9, 0xe7, 0xa9, 0x1d); 75 | 76 | 77 | // DirectSound default playback device GUID {DEF00000-9C6D-47ED-AAF1-4DDA8F2B5C03} 78 | DEFINE_GUID(DSDEVID_DefaultPlayback, 0xdef00000, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); 79 | 80 | // DirectSound default capture device GUID {DEF00001-9C6D-47ED-AAF1-4DDA8F2B5C03} 81 | DEFINE_GUID(DSDEVID_DefaultCapture, 0xdef00001, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); 82 | 83 | // DirectSound default device for voice playback {DEF00002-9C6D-47ED-AAF1-4DDA8F2B5C03} 84 | DEFINE_GUID(DSDEVID_DefaultVoicePlayback, 0xdef00002, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); 85 | 86 | // DirectSound default device for voice capture {DEF00003-9C6D-47ED-AAF1-4DDA8F2B5C03} 87 | DEFINE_GUID(DSDEVID_DefaultVoiceCapture, 0xdef00003, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); 88 | 89 | 90 | // 91 | // Forward declarations for interfaces. 92 | // 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined 93 | // 94 | 95 | #ifdef __cplusplus 96 | struct IDirectSound; 97 | struct IDirectSoundBuffer; 98 | struct IDirectSound3DListener; 99 | struct IDirectSound3DBuffer; 100 | struct IDirectSoundCapture; 101 | struct IDirectSoundCaptureBuffer; 102 | struct IDirectSoundNotify; 103 | #endif // __cplusplus 104 | 105 | 106 | // 107 | // DirectSound 8.0 interfaces. 108 | // 109 | 110 | #if DIRECTSOUND_VERSION >= 0x0800 111 | 112 | #ifdef __cplusplus 113 | struct IDirectSound8; 114 | struct IDirectSoundBuffer8; 115 | struct IDirectSoundCaptureBuffer8; 116 | struct IDirectSoundFXGargle; 117 | struct IDirectSoundFXChorus; 118 | struct IDirectSoundFXFlanger; 119 | struct IDirectSoundFXEcho; 120 | struct IDirectSoundFXDistortion; 121 | struct IDirectSoundFXCompressor; 122 | struct IDirectSoundFXParamEq; 123 | struct IDirectSoundFXWavesReverb; 124 | struct IDirectSoundFXI3DL2Reverb; 125 | struct IDirectSoundCaptureFXAec; 126 | struct IDirectSoundCaptureFXNoiseSuppress; 127 | struct IDirectSoundFullDuplex; 128 | #endif // __cplusplus 129 | 130 | // IDirectSound8, IDirectSoundBuffer8 and IDirectSoundCaptureBuffer8 are the 131 | // only DirectSound 7.0 interfaces with changed functionality in version 8.0. 132 | // The other level 8 interfaces as equivalent to their level 7 counterparts: 133 | 134 | #define IDirectSoundCapture8 IDirectSoundCapture 135 | #define IDirectSound3DListener8 IDirectSound3DListener 136 | #define IDirectSound3DBuffer8 IDirectSound3DBuffer 137 | #define IDirectSoundNotify8 IDirectSoundNotify 138 | #define IDirectSoundFXGargle8 IDirectSoundFXGargle 139 | #define IDirectSoundFXChorus8 IDirectSoundFXChorus 140 | #define IDirectSoundFXFlanger8 IDirectSoundFXFlanger 141 | #define IDirectSoundFXEcho8 IDirectSoundFXEcho 142 | #define IDirectSoundFXDistortion8 IDirectSoundFXDistortion 143 | #define IDirectSoundFXCompressor8 IDirectSoundFXCompressor 144 | #define IDirectSoundFXParamEq8 IDirectSoundFXParamEq 145 | #define IDirectSoundFXWavesReverb8 IDirectSoundFXWavesReverb 146 | #define IDirectSoundFXI3DL2Reverb8 IDirectSoundFXI3DL2Reverb 147 | #define IDirectSoundCaptureFXAec8 IDirectSoundCaptureFXAec 148 | #define IDirectSoundCaptureFXNoiseSuppress8 IDirectSoundCaptureFXNoiseSuppress 149 | #define IDirectSoundFullDuplex8 IDirectSoundFullDuplex 150 | 151 | #endif // DIRECTSOUND_VERSION >= 0x0800 152 | 153 | typedef struct IDirectSound *LPDIRECTSOUND; 154 | typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER; 155 | typedef struct IDirectSound3DListener *LPDIRECTSOUND3DLISTENER; 156 | typedef struct IDirectSound3DBuffer *LPDIRECTSOUND3DBUFFER; 157 | typedef struct IDirectSoundCapture *LPDIRECTSOUNDCAPTURE; 158 | typedef struct IDirectSoundCaptureBuffer *LPDIRECTSOUNDCAPTUREBUFFER; 159 | typedef struct IDirectSoundNotify *LPDIRECTSOUNDNOTIFY; 160 | 161 | 162 | #if DIRECTSOUND_VERSION >= 0x0800 163 | 164 | typedef struct IDirectSoundFXGargle *LPDIRECTSOUNDFXGARGLE; 165 | typedef struct IDirectSoundFXChorus *LPDIRECTSOUNDFXCHORUS; 166 | typedef struct IDirectSoundFXFlanger *LPDIRECTSOUNDFXFLANGER; 167 | typedef struct IDirectSoundFXEcho *LPDIRECTSOUNDFXECHO; 168 | typedef struct IDirectSoundFXDistortion *LPDIRECTSOUNDFXDISTORTION; 169 | typedef struct IDirectSoundFXCompressor *LPDIRECTSOUNDFXCOMPRESSOR; 170 | typedef struct IDirectSoundFXParamEq *LPDIRECTSOUNDFXPARAMEQ; 171 | typedef struct IDirectSoundFXWavesReverb *LPDIRECTSOUNDFXWAVESREVERB; 172 | typedef struct IDirectSoundFXI3DL2Reverb *LPDIRECTSOUNDFXI3DL2REVERB; 173 | typedef struct IDirectSoundCaptureFXAec *LPDIRECTSOUNDCAPTUREFXAEC; 174 | typedef struct IDirectSoundCaptureFXNoiseSuppress *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS; 175 | typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; 176 | 177 | typedef struct IDirectSound8 *LPDIRECTSOUND8; 178 | typedef struct IDirectSoundBuffer8 *LPDIRECTSOUNDBUFFER8; 179 | typedef struct IDirectSound3DListener8 *LPDIRECTSOUND3DLISTENER8; 180 | typedef struct IDirectSound3DBuffer8 *LPDIRECTSOUND3DBUFFER8; 181 | typedef struct IDirectSoundCapture8 *LPDIRECTSOUNDCAPTURE8; 182 | typedef struct IDirectSoundCaptureBuffer8 *LPDIRECTSOUNDCAPTUREBUFFER8; 183 | typedef struct IDirectSoundNotify8 *LPDIRECTSOUNDNOTIFY8; 184 | typedef struct IDirectSoundFXGargle8 *LPDIRECTSOUNDFXGARGLE8; 185 | typedef struct IDirectSoundFXChorus8 *LPDIRECTSOUNDFXCHORUS8; 186 | typedef struct IDirectSoundFXFlanger8 *LPDIRECTSOUNDFXFLANGER8; 187 | typedef struct IDirectSoundFXEcho8 *LPDIRECTSOUNDFXECHO8; 188 | typedef struct IDirectSoundFXDistortion8 *LPDIRECTSOUNDFXDISTORTION8; 189 | typedef struct IDirectSoundFXCompressor8 *LPDIRECTSOUNDFXCOMPRESSOR8; 190 | typedef struct IDirectSoundFXParamEq8 *LPDIRECTSOUNDFXPARAMEQ8; 191 | typedef struct IDirectSoundFXWavesReverb8 *LPDIRECTSOUNDFXWAVESREVERB8; 192 | typedef struct IDirectSoundFXI3DL2Reverb8 *LPDIRECTSOUNDFXI3DL2REVERB8; 193 | typedef struct IDirectSoundCaptureFXAec8 *LPDIRECTSOUNDCAPTUREFXAEC8; 194 | typedef struct IDirectSoundCaptureFXNoiseSuppress8 *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS8; 195 | typedef struct IDirectSoundFullDuplex8 *LPDIRECTSOUNDFULLDUPLEX8; 196 | 197 | #endif // DIRECTSOUND_VERSION >= 0x0800 198 | 199 | // 200 | // IID definitions for the unchanged DirectSound 8.0 interfaces 201 | // 202 | 203 | #if DIRECTSOUND_VERSION >= 0x0800 204 | 205 | #define IID_IDirectSoundCapture8 IID_IDirectSoundCapture 206 | #define IID_IDirectSound3DListener8 IID_IDirectSound3DListener 207 | #define IID_IDirectSound3DBuffer8 IID_IDirectSound3DBuffer 208 | #define IID_IDirectSoundNotify8 IID_IDirectSoundNotify 209 | #define IID_IDirectSoundFXGargle8 IID_IDirectSoundFXGargle 210 | #define IID_IDirectSoundFXChorus8 IID_IDirectSoundFXChorus 211 | #define IID_IDirectSoundFXFlanger8 IID_IDirectSoundFXFlanger 212 | #define IID_IDirectSoundFXEcho8 IID_IDirectSoundFXEcho 213 | #define IID_IDirectSoundFXDistortion8 IID_IDirectSoundFXDistortion 214 | #define IID_IDirectSoundFXCompressor8 IID_IDirectSoundFXCompressor 215 | #define IID_IDirectSoundFXParamEq8 IID_IDirectSoundFXParamEq 216 | #define IID_IDirectSoundFXWavesReverb8 IID_IDirectSoundFXWavesReverb 217 | #define IID_IDirectSoundFXI3DL2Reverb8 IID_IDirectSoundFXI3DL2Reverb 218 | #define IID_IDirectSoundCaptureFXAec8 IID_IDirectSoundCaptureFXAec 219 | #define IID_IDirectSoundCaptureFXNoiseSuppress8 IID_IDirectSoundCaptureFXNoiseSuppress 220 | #define IID_IDirectSoundFullDuplex8 IID_IDirectSoundFullDuplex 221 | 222 | #endif // DIRECTSOUND_VERSION >= 0x0800 223 | 224 | // 225 | // Compatibility typedefs 226 | // 227 | 228 | #ifndef _LPCWAVEFORMATEX_DEFINED 229 | #define _LPCWAVEFORMATEX_DEFINED 230 | typedef const WAVEFORMATEX *LPCWAVEFORMATEX; 231 | #endif // _LPCWAVEFORMATEX_DEFINED 232 | 233 | #ifndef __LPCGUID_DEFINED__ 234 | #define __LPCGUID_DEFINED__ 235 | typedef const GUID *LPCGUID; 236 | #endif // __LPCGUID_DEFINED__ 237 | 238 | typedef LPDIRECTSOUND *LPLPDIRECTSOUND; 239 | typedef LPDIRECTSOUNDBUFFER *LPLPDIRECTSOUNDBUFFER; 240 | typedef LPDIRECTSOUND3DLISTENER *LPLPDIRECTSOUND3DLISTENER; 241 | typedef LPDIRECTSOUND3DBUFFER *LPLPDIRECTSOUND3DBUFFER; 242 | typedef LPDIRECTSOUNDCAPTURE *LPLPDIRECTSOUNDCAPTURE; 243 | typedef LPDIRECTSOUNDCAPTUREBUFFER *LPLPDIRECTSOUNDCAPTUREBUFFER; 244 | typedef LPDIRECTSOUNDNOTIFY *LPLPDIRECTSOUNDNOTIFY; 245 | 246 | #if DIRECTSOUND_VERSION >= 0x0800 247 | typedef LPDIRECTSOUND8 *LPLPDIRECTSOUND8; 248 | typedef LPDIRECTSOUNDBUFFER8 *LPLPDIRECTSOUNDBUFFER8; 249 | typedef LPDIRECTSOUNDCAPTURE8 *LPLPDIRECTSOUNDCAPTURE8; 250 | typedef LPDIRECTSOUNDCAPTUREBUFFER8 *LPLPDIRECTSOUNDCAPTUREBUFFER8; 251 | #endif // DIRECTSOUND_VERSION >= 0x0800 252 | 253 | // 254 | // Structures 255 | // 256 | 257 | typedef struct _DSCAPS 258 | { 259 | DWORD dwSize; 260 | DWORD dwFlags; 261 | DWORD dwMinSecondarySampleRate; 262 | DWORD dwMaxSecondarySampleRate; 263 | DWORD dwPrimaryBuffers; 264 | DWORD dwMaxHwMixingAllBuffers; 265 | DWORD dwMaxHwMixingStaticBuffers; 266 | DWORD dwMaxHwMixingStreamingBuffers; 267 | DWORD dwFreeHwMixingAllBuffers; 268 | DWORD dwFreeHwMixingStaticBuffers; 269 | DWORD dwFreeHwMixingStreamingBuffers; 270 | DWORD dwMaxHw3DAllBuffers; 271 | DWORD dwMaxHw3DStaticBuffers; 272 | DWORD dwMaxHw3DStreamingBuffers; 273 | DWORD dwFreeHw3DAllBuffers; 274 | DWORD dwFreeHw3DStaticBuffers; 275 | DWORD dwFreeHw3DStreamingBuffers; 276 | DWORD dwTotalHwMemBytes; 277 | DWORD dwFreeHwMemBytes; 278 | DWORD dwMaxContigFreeHwMemBytes; 279 | DWORD dwUnlockTransferRateHwBuffers; 280 | DWORD dwPlayCpuOverheadSwBuffers; 281 | DWORD dwReserved1; 282 | DWORD dwReserved2; 283 | } DSCAPS, *LPDSCAPS; 284 | 285 | typedef const DSCAPS *LPCDSCAPS; 286 | 287 | typedef struct _DSBCAPS 288 | { 289 | DWORD dwSize; 290 | DWORD dwFlags; 291 | DWORD dwBufferBytes; 292 | DWORD dwUnlockTransferRate; 293 | DWORD dwPlayCpuOverhead; 294 | } DSBCAPS, *LPDSBCAPS; 295 | 296 | typedef const DSBCAPS *LPCDSBCAPS; 297 | 298 | #if DIRECTSOUND_VERSION >= 0x0800 299 | 300 | typedef struct _DSEFFECTDESC 301 | { 302 | DWORD dwSize; 303 | DWORD dwFlags; 304 | GUID guidDSFXClass; 305 | DWORD_PTR dwReserved1; 306 | DWORD_PTR dwReserved2; 307 | } DSEFFECTDESC, *LPDSEFFECTDESC; 308 | typedef const DSEFFECTDESC *LPCDSEFFECTDESC; 309 | 310 | #define DSFX_LOCHARDWARE 0x00000001 311 | #define DSFX_LOCSOFTWARE 0x00000002 312 | 313 | enum 314 | { 315 | DSFXR_PRESENT, // 0 316 | DSFXR_LOCHARDWARE, // 1 317 | DSFXR_LOCSOFTWARE, // 2 318 | DSFXR_UNALLOCATED, // 3 319 | DSFXR_FAILED, // 4 320 | DSFXR_UNKNOWN, // 5 321 | DSFXR_SENDLOOP // 6 322 | }; 323 | 324 | typedef struct _DSCEFFECTDESC 325 | { 326 | DWORD dwSize; 327 | DWORD dwFlags; 328 | GUID guidDSCFXClass; 329 | GUID guidDSCFXInstance; 330 | DWORD dwReserved1; 331 | DWORD dwReserved2; 332 | } DSCEFFECTDESC, *LPDSCEFFECTDESC; 333 | typedef const DSCEFFECTDESC *LPCDSCEFFECTDESC; 334 | 335 | #define DSCFX_LOCHARDWARE 0x00000001 336 | #define DSCFX_LOCSOFTWARE 0x00000002 337 | 338 | #define DSCFXR_LOCHARDWARE 0x00000010 339 | #define DSCFXR_LOCSOFTWARE 0x00000020 340 | 341 | #endif // DIRECTSOUND_VERSION >= 0x0800 342 | 343 | typedef struct _DSBUFFERDESC 344 | { 345 | DWORD dwSize; 346 | DWORD dwFlags; 347 | DWORD dwBufferBytes; 348 | DWORD dwReserved; 349 | LPWAVEFORMATEX lpwfxFormat; 350 | #if DIRECTSOUND_VERSION >= 0x0700 351 | GUID guid3DAlgorithm; 352 | #endif 353 | } DSBUFFERDESC, *LPDSBUFFERDESC; 354 | 355 | typedef const DSBUFFERDESC *LPCDSBUFFERDESC; 356 | 357 | // Older version of this structure: 358 | 359 | typedef struct _DSBUFFERDESC1 360 | { 361 | DWORD dwSize; 362 | DWORD dwFlags; 363 | DWORD dwBufferBytes; 364 | DWORD dwReserved; 365 | LPWAVEFORMATEX lpwfxFormat; 366 | } DSBUFFERDESC1, *LPDSBUFFERDESC1; 367 | 368 | typedef const DSBUFFERDESC1 *LPCDSBUFFERDESC1; 369 | 370 | typedef struct _DS3DBUFFER 371 | { 372 | DWORD dwSize; 373 | D3DVECTOR vPosition; 374 | D3DVECTOR vVelocity; 375 | DWORD dwInsideConeAngle; 376 | DWORD dwOutsideConeAngle; 377 | D3DVECTOR vConeOrientation; 378 | LONG lConeOutsideVolume; 379 | D3DVALUE flMinDistance; 380 | D3DVALUE flMaxDistance; 381 | DWORD dwMode; 382 | } DS3DBUFFER, *LPDS3DBUFFER; 383 | 384 | typedef const DS3DBUFFER *LPCDS3DBUFFER; 385 | 386 | typedef struct _DS3DLISTENER 387 | { 388 | DWORD dwSize; 389 | D3DVECTOR vPosition; 390 | D3DVECTOR vVelocity; 391 | D3DVECTOR vOrientFront; 392 | D3DVECTOR vOrientTop; 393 | D3DVALUE flDistanceFactor; 394 | D3DVALUE flRolloffFactor; 395 | D3DVALUE flDopplerFactor; 396 | } DS3DLISTENER, *LPDS3DLISTENER; 397 | 398 | typedef const DS3DLISTENER *LPCDS3DLISTENER; 399 | 400 | typedef struct _DSCCAPS 401 | { 402 | DWORD dwSize; 403 | DWORD dwFlags; 404 | DWORD dwFormats; 405 | DWORD dwChannels; 406 | } DSCCAPS, *LPDSCCAPS; 407 | 408 | typedef const DSCCAPS *LPCDSCCAPS; 409 | 410 | typedef struct _DSCBUFFERDESC1 411 | { 412 | DWORD dwSize; 413 | DWORD dwFlags; 414 | DWORD dwBufferBytes; 415 | DWORD dwReserved; 416 | LPWAVEFORMATEX lpwfxFormat; 417 | } DSCBUFFERDESC1, *LPDSCBUFFERDESC1; 418 | 419 | typedef struct _DSCBUFFERDESC 420 | { 421 | DWORD dwSize; 422 | DWORD dwFlags; 423 | DWORD dwBufferBytes; 424 | DWORD dwReserved; 425 | LPWAVEFORMATEX lpwfxFormat; 426 | #if DIRECTSOUND_VERSION >= 0x0800 427 | DWORD dwFXCount; 428 | LPDSCEFFECTDESC lpDSCFXDesc; 429 | #endif 430 | } DSCBUFFERDESC, *LPDSCBUFFERDESC; 431 | 432 | typedef const DSCBUFFERDESC *LPCDSCBUFFERDESC; 433 | 434 | typedef struct _DSCBCAPS 435 | { 436 | DWORD dwSize; 437 | DWORD dwFlags; 438 | DWORD dwBufferBytes; 439 | DWORD dwReserved; 440 | } DSCBCAPS, *LPDSCBCAPS; 441 | 442 | typedef const DSCBCAPS *LPCDSCBCAPS; 443 | 444 | typedef struct _DSBPOSITIONNOTIFY 445 | { 446 | DWORD dwOffset; 447 | HANDLE hEventNotify; 448 | } DSBPOSITIONNOTIFY, *LPDSBPOSITIONNOTIFY; 449 | 450 | typedef const DSBPOSITIONNOTIFY *LPCDSBPOSITIONNOTIFY; 451 | 452 | // 453 | // DirectSound API 454 | // 455 | 456 | typedef BOOL (CALLBACK *LPDSENUMCALLBACKA)(LPGUID, LPCSTR, LPCSTR, LPVOID); 457 | typedef BOOL (CALLBACK *LPDSENUMCALLBACKW)(LPGUID, LPCWSTR, LPCWSTR, LPVOID); 458 | 459 | extern HRESULT WINAPI DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter); 460 | extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); 461 | extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); 462 | 463 | extern HRESULT WINAPI DirectSoundCaptureCreate(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter); 464 | extern HRESULT WINAPI DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); 465 | extern HRESULT WINAPI DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); 466 | 467 | #if DIRECTSOUND_VERSION >= 0x0800 468 | extern HRESULT WINAPI DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter); 469 | extern HRESULT WINAPI DirectSoundCaptureCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter); 470 | extern HRESULT WINAPI DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice, 471 | LPCDSCBUFFERDESC pcDSCBufferDesc, LPCDSBUFFERDESC pcDSBufferDesc, HWND hWnd, 472 | DWORD dwLevel, LPDIRECTSOUNDFULLDUPLEX* ppDSFD, LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8, 473 | LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, LPUNKNOWN pUnkOuter); 474 | #define DirectSoundFullDuplexCreate8 DirectSoundFullDuplexCreate 475 | 476 | extern HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest); 477 | #endif // DIRECTSOUND_VERSION >= 0x0800 478 | 479 | #ifdef UNICODE 480 | #define LPDSENUMCALLBACK LPDSENUMCALLBACKW 481 | #define DirectSoundEnumerate DirectSoundEnumerateW 482 | #define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateW 483 | #else // UNICODE 484 | #define LPDSENUMCALLBACK LPDSENUMCALLBACKA 485 | #define DirectSoundEnumerate DirectSoundEnumerateA 486 | #define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateA 487 | #endif // UNICODE 488 | 489 | // 490 | // IUnknown 491 | // 492 | 493 | #if !defined(__cplusplus) || defined(CINTERFACE) 494 | #ifndef IUnknown_QueryInterface 495 | #define IUnknown_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) 496 | #endif // IUnknown_QueryInterface 497 | #ifndef IUnknown_AddRef 498 | #define IUnknown_AddRef(p) (p)->lpVtbl->AddRef(p) 499 | #endif // IUnknown_AddRef 500 | #ifndef IUnknown_Release 501 | #define IUnknown_Release(p) (p)->lpVtbl->Release(p) 502 | #endif // IUnknown_Release 503 | #else // !defined(__cplusplus) || defined(CINTERFACE) 504 | #ifndef IUnknown_QueryInterface 505 | #define IUnknown_QueryInterface(p,a,b) (p)->QueryInterface(a,b) 506 | #endif // IUnknown_QueryInterface 507 | #ifndef IUnknown_AddRef 508 | #define IUnknown_AddRef(p) (p)->AddRef() 509 | #endif // IUnknown_AddRef 510 | #ifndef IUnknown_Release 511 | #define IUnknown_Release(p) (p)->Release() 512 | #endif // IUnknown_Release 513 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 514 | 515 | #ifndef __IReferenceClock_INTERFACE_DEFINED__ 516 | #define __IReferenceClock_INTERFACE_DEFINED__ 517 | 518 | typedef LONGLONG REFERENCE_TIME; 519 | typedef REFERENCE_TIME *LPREFERENCE_TIME; 520 | 521 | DEFINE_GUID(IID_IReferenceClock, 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); 522 | 523 | #undef INTERFACE 524 | #define INTERFACE IReferenceClock 525 | 526 | DECLARE_INTERFACE_(IReferenceClock, IUnknown) 527 | { 528 | // IUnknown methods 529 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 530 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 531 | STDMETHOD_(ULONG,Release) (THIS) PURE; 532 | 533 | // IReferenceClock methods 534 | STDMETHOD(GetTime) (THIS_ REFERENCE_TIME *pTime) PURE; 535 | STDMETHOD(AdviseTime) (THIS_ REFERENCE_TIME rtBaseTime, REFERENCE_TIME rtStreamTime, 536 | HANDLE hEvent, LPDWORD pdwAdviseCookie) PURE; 537 | STDMETHOD(AdvisePeriodic) (THIS_ REFERENCE_TIME rtStartTime, REFERENCE_TIME rtPeriodTime, 538 | HANDLE hSemaphore, LPDWORD pdwAdviseCookie) PURE; 539 | STDMETHOD(Unadvise) (THIS_ DWORD dwAdviseCookie) PURE; 540 | }; 541 | 542 | #endif // __IReferenceClock_INTERFACE_DEFINED__ 543 | 544 | #ifndef IReferenceClock_QueryInterface 545 | 546 | #define IReferenceClock_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 547 | #define IReferenceClock_AddRef(p) IUnknown_AddRef(p) 548 | #define IReferenceClock_Release(p) IUnknown_Release(p) 549 | 550 | #if !defined(__cplusplus) || defined(CINTERFACE) 551 | #define IReferenceClock_GetTime(p,a) (p)->lpVtbl->GetTime(p,a) 552 | #define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->lpVtbl->AdviseTime(p,a,b,c,d) 553 | #define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->lpVtbl->AdvisePeriodic(p,a,b,c,d) 554 | #define IReferenceClock_Unadvise(p,a) (p)->lpVtbl->Unadvise(p,a) 555 | #else // !defined(__cplusplus) || defined(CINTERFACE) 556 | #define IReferenceClock_GetTime(p,a) (p)->GetTime(a) 557 | #define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->AdviseTime(a,b,c,d) 558 | #define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->AdvisePeriodic(a,b,c,d) 559 | #define IReferenceClock_Unadvise(p,a) (p)->Unadvise(a) 560 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 561 | 562 | #endif // IReferenceClock_QueryInterface 563 | 564 | // 565 | // IDirectSound 566 | // 567 | 568 | DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); 569 | 570 | #undef INTERFACE 571 | #define INTERFACE IDirectSound 572 | 573 | DECLARE_INTERFACE_(IDirectSound, IUnknown) 574 | { 575 | // IUnknown methods 576 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 577 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 578 | STDMETHOD_(ULONG,Release) (THIS) PURE; 579 | 580 | // IDirectSound methods 581 | STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; 582 | STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; 583 | STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; 584 | STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; 585 | STDMETHOD(Compact) (THIS) PURE; 586 | STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; 587 | STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; 588 | STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; 589 | }; 590 | 591 | #define IDirectSound_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 592 | #define IDirectSound_AddRef(p) IUnknown_AddRef(p) 593 | #define IDirectSound_Release(p) IUnknown_Release(p) 594 | 595 | #if !defined(__cplusplus) || defined(CINTERFACE) 596 | #define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c) 597 | #define IDirectSound_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) 598 | #define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b) 599 | #define IDirectSound_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) 600 | #define IDirectSound_Compact(p) (p)->lpVtbl->Compact(p) 601 | #define IDirectSound_GetSpeakerConfig(p,a) (p)->lpVtbl->GetSpeakerConfig(p,a) 602 | #define IDirectSound_SetSpeakerConfig(p,b) (p)->lpVtbl->SetSpeakerConfig(p,b) 603 | #define IDirectSound_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) 604 | #else // !defined(__cplusplus) || defined(CINTERFACE) 605 | #define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->CreateSoundBuffer(a,b,c) 606 | #define IDirectSound_GetCaps(p,a) (p)->GetCaps(a) 607 | #define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->DuplicateSoundBuffer(a,b) 608 | #define IDirectSound_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) 609 | #define IDirectSound_Compact(p) (p)->Compact() 610 | #define IDirectSound_GetSpeakerConfig(p,a) (p)->GetSpeakerConfig(a) 611 | #define IDirectSound_SetSpeakerConfig(p,b) (p)->SetSpeakerConfig(b) 612 | #define IDirectSound_Initialize(p,a) (p)->Initialize(a) 613 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 614 | 615 | #if DIRECTSOUND_VERSION >= 0x0800 616 | 617 | // 618 | // IDirectSound8 619 | // 620 | 621 | DEFINE_GUID(IID_IDirectSound8, 0xC50A7E93, 0xF395, 0x4834, 0x9E, 0xF6, 0x7F, 0xA9, 0x9D, 0xE5, 0x09, 0x66); 622 | 623 | #undef INTERFACE 624 | #define INTERFACE IDirectSound8 625 | 626 | DECLARE_INTERFACE_(IDirectSound8, IDirectSound) 627 | { 628 | // IUnknown methods 629 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 630 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 631 | STDMETHOD_(ULONG,Release) (THIS) PURE; 632 | 633 | // IDirectSound methods 634 | STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; 635 | STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; 636 | STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; 637 | STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; 638 | STDMETHOD(Compact) (THIS) PURE; 639 | STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; 640 | STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; 641 | STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; 642 | 643 | // IDirectSound8 methods 644 | STDMETHOD(VerifyCertification) (THIS_ LPDWORD pdwCertified) PURE; 645 | }; 646 | 647 | #define IDirectSound8_QueryInterface(p,a,b) IDirectSound_QueryInterface(p,a,b) 648 | #define IDirectSound8_AddRef(p) IDirectSound_AddRef(p) 649 | #define IDirectSound8_Release(p) IDirectSound_Release(p) 650 | #define IDirectSound8_CreateSoundBuffer(p,a,b,c) IDirectSound_CreateSoundBuffer(p,a,b,c) 651 | #define IDirectSound8_GetCaps(p,a) IDirectSound_GetCaps(p,a) 652 | #define IDirectSound8_DuplicateSoundBuffer(p,a,b) IDirectSound_DuplicateSoundBuffer(p,a,b) 653 | #define IDirectSound8_SetCooperativeLevel(p,a,b) IDirectSound_SetCooperativeLevel(p,a,b) 654 | #define IDirectSound8_Compact(p) IDirectSound_Compact(p) 655 | #define IDirectSound8_GetSpeakerConfig(p,a) IDirectSound_GetSpeakerConfig(p,a) 656 | #define IDirectSound8_SetSpeakerConfig(p,a) IDirectSound_SetSpeakerConfig(p,a) 657 | #define IDirectSound8_Initialize(p,a) IDirectSound_Initialize(p,a) 658 | 659 | #if !defined(__cplusplus) || defined(CINTERFACE) 660 | #define IDirectSound8_VerifyCertification(p,a) (p)->lpVtbl->VerifyCertification(p,a) 661 | #else // !defined(__cplusplus) || defined(CINTERFACE) 662 | #define IDirectSound8_VerifyCertification(p,a) (p)->VerifyCertification(a) 663 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 664 | 665 | #endif // DIRECTSOUND_VERSION >= 0x0800 666 | 667 | // 668 | // IDirectSoundBuffer 669 | // 670 | 671 | DEFINE_GUID(IID_IDirectSoundBuffer, 0x279AFA85, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); 672 | 673 | #undef INTERFACE 674 | #define INTERFACE IDirectSoundBuffer 675 | 676 | DECLARE_INTERFACE_(IDirectSoundBuffer, IUnknown) 677 | { 678 | // IUnknown methods 679 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 680 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 681 | STDMETHOD_(ULONG,Release) (THIS) PURE; 682 | 683 | // IDirectSoundBuffer methods 684 | STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; 685 | STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; 686 | STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; 687 | STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; 688 | STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; 689 | STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; 690 | STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; 691 | STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; 692 | STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, 693 | LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; 694 | STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; 695 | STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; 696 | STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; 697 | STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; 698 | STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; 699 | STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; 700 | STDMETHOD(Stop) (THIS) PURE; 701 | STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; 702 | STDMETHOD(Restore) (THIS) PURE; 703 | }; 704 | 705 | #define IDirectSoundBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 706 | #define IDirectSoundBuffer_AddRef(p) IUnknown_AddRef(p) 707 | #define IDirectSoundBuffer_Release(p) IUnknown_Release(p) 708 | 709 | #if !defined(__cplusplus) || defined(CINTERFACE) 710 | #define IDirectSoundBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) 711 | #define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) 712 | #define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) 713 | #define IDirectSoundBuffer_GetVolume(p,a) (p)->lpVtbl->GetVolume(p,a) 714 | #define IDirectSoundBuffer_GetPan(p,a) (p)->lpVtbl->GetPan(p,a) 715 | #define IDirectSoundBuffer_GetFrequency(p,a) (p)->lpVtbl->GetFrequency(p,a) 716 | #define IDirectSoundBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) 717 | #define IDirectSoundBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) 718 | #define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) 719 | #define IDirectSoundBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c) 720 | #define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->lpVtbl->SetCurrentPosition(p,a) 721 | #define IDirectSoundBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a) 722 | #define IDirectSoundBuffer_SetVolume(p,a) (p)->lpVtbl->SetVolume(p,a) 723 | #define IDirectSoundBuffer_SetPan(p,a) (p)->lpVtbl->SetPan(p,a) 724 | #define IDirectSoundBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a) 725 | #define IDirectSoundBuffer_Stop(p) (p)->lpVtbl->Stop(p) 726 | #define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) 727 | #define IDirectSoundBuffer_Restore(p) (p)->lpVtbl->Restore(p) 728 | #else // !defined(__cplusplus) || defined(CINTERFACE) 729 | #define IDirectSoundBuffer_GetCaps(p,a) (p)->GetCaps(a) 730 | #define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) 731 | #define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) 732 | #define IDirectSoundBuffer_GetVolume(p,a) (p)->GetVolume(a) 733 | #define IDirectSoundBuffer_GetPan(p,a) (p)->GetPan(a) 734 | #define IDirectSoundBuffer_GetFrequency(p,a) (p)->GetFrequency(a) 735 | #define IDirectSoundBuffer_GetStatus(p,a) (p)->GetStatus(a) 736 | #define IDirectSoundBuffer_Initialize(p,a,b) (p)->Initialize(a,b) 737 | #define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) 738 | #define IDirectSoundBuffer_Play(p,a,b,c) (p)->Play(a,b,c) 739 | #define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->SetCurrentPosition(a) 740 | #define IDirectSoundBuffer_SetFormat(p,a) (p)->SetFormat(a) 741 | #define IDirectSoundBuffer_SetVolume(p,a) (p)->SetVolume(a) 742 | #define IDirectSoundBuffer_SetPan(p,a) (p)->SetPan(a) 743 | #define IDirectSoundBuffer_SetFrequency(p,a) (p)->SetFrequency(a) 744 | #define IDirectSoundBuffer_Stop(p) (p)->Stop() 745 | #define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) 746 | #define IDirectSoundBuffer_Restore(p) (p)->Restore() 747 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 748 | 749 | #if DIRECTSOUND_VERSION >= 0x0800 750 | 751 | // 752 | // IDirectSoundBuffer8 753 | // 754 | 755 | DEFINE_GUID(IID_IDirectSoundBuffer8, 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e); 756 | 757 | #undef INTERFACE 758 | #define INTERFACE IDirectSoundBuffer8 759 | 760 | DECLARE_INTERFACE_(IDirectSoundBuffer8, IDirectSoundBuffer) 761 | { 762 | // IUnknown methods 763 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 764 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 765 | STDMETHOD_(ULONG,Release) (THIS) PURE; 766 | 767 | // IDirectSoundBuffer methods 768 | STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; 769 | STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; 770 | STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; 771 | STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; 772 | STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; 773 | STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; 774 | STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; 775 | STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; 776 | STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, 777 | LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; 778 | STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; 779 | STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; 780 | STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; 781 | STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; 782 | STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; 783 | STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; 784 | STDMETHOD(Stop) (THIS) PURE; 785 | STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; 786 | STDMETHOD(Restore) (THIS) PURE; 787 | 788 | // IDirectSoundBuffer8 methods 789 | STDMETHOD(SetFX) (THIS_ DWORD dwEffectsCount, LPDSEFFECTDESC pDSFXDesc, LPDWORD pdwResultCodes) PURE; 790 | STDMETHOD(AcquireResources) (THIS_ DWORD dwFlags, DWORD dwEffectsCount, LPDWORD pdwResultCodes) PURE; 791 | STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; 792 | }; 793 | 794 | // Special GUID meaning "select all objects" for use in GetObjectInPath() 795 | DEFINE_GUID(GUID_All_Objects, 0xaa114de5, 0xc262, 0x4169, 0xa1, 0xc8, 0x23, 0xd6, 0x98, 0xcc, 0x73, 0xb5); 796 | 797 | #define IDirectSoundBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 798 | #define IDirectSoundBuffer8_AddRef(p) IUnknown_AddRef(p) 799 | #define IDirectSoundBuffer8_Release(p) IUnknown_Release(p) 800 | 801 | #define IDirectSoundBuffer8_GetCaps(p,a) IDirectSoundBuffer_GetCaps(p,a) 802 | #define IDirectSoundBuffer8_GetCurrentPosition(p,a,b) IDirectSoundBuffer_GetCurrentPosition(p,a,b) 803 | #define IDirectSoundBuffer8_GetFormat(p,a,b,c) IDirectSoundBuffer_GetFormat(p,a,b,c) 804 | #define IDirectSoundBuffer8_GetVolume(p,a) IDirectSoundBuffer_GetVolume(p,a) 805 | #define IDirectSoundBuffer8_GetPan(p,a) IDirectSoundBuffer_GetPan(p,a) 806 | #define IDirectSoundBuffer8_GetFrequency(p,a) IDirectSoundBuffer_GetFrequency(p,a) 807 | #define IDirectSoundBuffer8_GetStatus(p,a) IDirectSoundBuffer_GetStatus(p,a) 808 | #define IDirectSoundBuffer8_Initialize(p,a,b) IDirectSoundBuffer_Initialize(p,a,b) 809 | #define IDirectSoundBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) 810 | #define IDirectSoundBuffer8_Play(p,a,b,c) IDirectSoundBuffer_Play(p,a,b,c) 811 | #define IDirectSoundBuffer8_SetCurrentPosition(p,a) IDirectSoundBuffer_SetCurrentPosition(p,a) 812 | #define IDirectSoundBuffer8_SetFormat(p,a) IDirectSoundBuffer_SetFormat(p,a) 813 | #define IDirectSoundBuffer8_SetVolume(p,a) IDirectSoundBuffer_SetVolume(p,a) 814 | #define IDirectSoundBuffer8_SetPan(p,a) IDirectSoundBuffer_SetPan(p,a) 815 | #define IDirectSoundBuffer8_SetFrequency(p,a) IDirectSoundBuffer_SetFrequency(p,a) 816 | #define IDirectSoundBuffer8_Stop(p) IDirectSoundBuffer_Stop(p) 817 | #define IDirectSoundBuffer8_Unlock(p,a,b,c,d) IDirectSoundBuffer_Unlock(p,a,b,c,d) 818 | #define IDirectSoundBuffer8_Restore(p) IDirectSoundBuffer_Restore(p) 819 | 820 | #if !defined(__cplusplus) || defined(CINTERFACE) 821 | #define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->lpVtbl->SetFX(p,a,b,c) 822 | #define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->lpVtbl->AcquireResources(p,a,b,c) 823 | #define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) 824 | #else // !defined(__cplusplus) || defined(CINTERFACE) 825 | #define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->SetFX(a,b,c) 826 | #define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->AcquireResources(a,b,c) 827 | #define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) 828 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 829 | 830 | #endif // DIRECTSOUND_VERSION >= 0x0800 831 | 832 | // 833 | // IDirectSound3DListener 834 | // 835 | 836 | DEFINE_GUID(IID_IDirectSound3DListener, 0x279AFA84, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); 837 | 838 | #undef INTERFACE 839 | #define INTERFACE IDirectSound3DListener 840 | 841 | DECLARE_INTERFACE_(IDirectSound3DListener, IUnknown) 842 | { 843 | // IUnknown methods 844 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 845 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 846 | STDMETHOD_(ULONG,Release) (THIS) PURE; 847 | 848 | // IDirectSound3DListener methods 849 | STDMETHOD(GetAllParameters) (THIS_ LPDS3DLISTENER pListener) PURE; 850 | STDMETHOD(GetDistanceFactor) (THIS_ D3DVALUE* pflDistanceFactor) PURE; 851 | STDMETHOD(GetDopplerFactor) (THIS_ D3DVALUE* pflDopplerFactor) PURE; 852 | STDMETHOD(GetOrientation) (THIS_ D3DVECTOR* pvOrientFront, D3DVECTOR* pvOrientTop) PURE; 853 | STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; 854 | STDMETHOD(GetRolloffFactor) (THIS_ D3DVALUE* pflRolloffFactor) PURE; 855 | STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; 856 | STDMETHOD(SetAllParameters) (THIS_ LPCDS3DLISTENER pcListener, DWORD dwApply) PURE; 857 | STDMETHOD(SetDistanceFactor) (THIS_ D3DVALUE flDistanceFactor, DWORD dwApply) PURE; 858 | STDMETHOD(SetDopplerFactor) (THIS_ D3DVALUE flDopplerFactor, DWORD dwApply) PURE; 859 | STDMETHOD(SetOrientation) (THIS_ D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront, 860 | D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop, DWORD dwApply) PURE; 861 | STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; 862 | STDMETHOD(SetRolloffFactor) (THIS_ D3DVALUE flRolloffFactor, DWORD dwApply) PURE; 863 | STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; 864 | STDMETHOD(CommitDeferredSettings) (THIS) PURE; 865 | }; 866 | 867 | #define IDirectSound3DListener_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 868 | #define IDirectSound3DListener_AddRef(p) IUnknown_AddRef(p) 869 | #define IDirectSound3DListener_Release(p) IUnknown_Release(p) 870 | 871 | #if !defined(__cplusplus) || defined(CINTERFACE) 872 | #define IDirectSound3DListener_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 873 | #define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->lpVtbl->GetDistanceFactor(p,a) 874 | #define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->lpVtbl->GetDopplerFactor(p,a) 875 | #define IDirectSound3DListener_GetOrientation(p,a,b) (p)->lpVtbl->GetOrientation(p,a,b) 876 | #define IDirectSound3DListener_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) 877 | #define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->lpVtbl->GetRolloffFactor(p,a) 878 | #define IDirectSound3DListener_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) 879 | #define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) 880 | #define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->lpVtbl->SetDistanceFactor(p,a,b) 881 | #define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->lpVtbl->SetDopplerFactor(p,a,b) 882 | #define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g) 883 | #define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) 884 | #define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->lpVtbl->SetRolloffFactor(p,a,b) 885 | #define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) 886 | #define IDirectSound3DListener_CommitDeferredSettings(p) (p)->lpVtbl->CommitDeferredSettings(p) 887 | #else // !defined(__cplusplus) || defined(CINTERFACE) 888 | #define IDirectSound3DListener_GetAllParameters(p,a) (p)->GetAllParameters(a) 889 | #define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->GetDistanceFactor(a) 890 | #define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->GetDopplerFactor(a) 891 | #define IDirectSound3DListener_GetOrientation(p,a,b) (p)->GetOrientation(a,b) 892 | #define IDirectSound3DListener_GetPosition(p,a) (p)->GetPosition(a) 893 | #define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->GetRolloffFactor(a) 894 | #define IDirectSound3DListener_GetVelocity(p,a) (p)->GetVelocity(a) 895 | #define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) 896 | #define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->SetDistanceFactor(a,b) 897 | #define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->SetDopplerFactor(a,b) 898 | #define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->SetOrientation(a,b,c,d,e,f,g) 899 | #define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) 900 | #define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->SetRolloffFactor(a,b) 901 | #define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) 902 | #define IDirectSound3DListener_CommitDeferredSettings(p) (p)->CommitDeferredSettings() 903 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 904 | 905 | // 906 | // IDirectSound3DBuffer 907 | // 908 | 909 | DEFINE_GUID(IID_IDirectSound3DBuffer, 0x279AFA86, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); 910 | 911 | #undef INTERFACE 912 | #define INTERFACE IDirectSound3DBuffer 913 | 914 | DECLARE_INTERFACE_(IDirectSound3DBuffer, IUnknown) 915 | { 916 | // IUnknown methods 917 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 918 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 919 | STDMETHOD_(ULONG,Release) (THIS) PURE; 920 | 921 | // IDirectSound3DBuffer methods 922 | STDMETHOD(GetAllParameters) (THIS_ LPDS3DBUFFER pDs3dBuffer) PURE; 923 | STDMETHOD(GetConeAngles) (THIS_ LPDWORD pdwInsideConeAngle, LPDWORD pdwOutsideConeAngle) PURE; 924 | STDMETHOD(GetConeOrientation) (THIS_ D3DVECTOR* pvOrientation) PURE; 925 | STDMETHOD(GetConeOutsideVolume) (THIS_ LPLONG plConeOutsideVolume) PURE; 926 | STDMETHOD(GetMaxDistance) (THIS_ D3DVALUE* pflMaxDistance) PURE; 927 | STDMETHOD(GetMinDistance) (THIS_ D3DVALUE* pflMinDistance) PURE; 928 | STDMETHOD(GetMode) (THIS_ LPDWORD pdwMode) PURE; 929 | STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; 930 | STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; 931 | STDMETHOD(SetAllParameters) (THIS_ LPCDS3DBUFFER pcDs3dBuffer, DWORD dwApply) PURE; 932 | STDMETHOD(SetConeAngles) (THIS_ DWORD dwInsideConeAngle, DWORD dwOutsideConeAngle, DWORD dwApply) PURE; 933 | STDMETHOD(SetConeOrientation) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; 934 | STDMETHOD(SetConeOutsideVolume) (THIS_ LONG lConeOutsideVolume, DWORD dwApply) PURE; 935 | STDMETHOD(SetMaxDistance) (THIS_ D3DVALUE flMaxDistance, DWORD dwApply) PURE; 936 | STDMETHOD(SetMinDistance) (THIS_ D3DVALUE flMinDistance, DWORD dwApply) PURE; 937 | STDMETHOD(SetMode) (THIS_ DWORD dwMode, DWORD dwApply) PURE; 938 | STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; 939 | STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; 940 | }; 941 | 942 | #define IDirectSound3DBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 943 | #define IDirectSound3DBuffer_AddRef(p) IUnknown_AddRef(p) 944 | #define IDirectSound3DBuffer_Release(p) IUnknown_Release(p) 945 | 946 | #if !defined(__cplusplus) || defined(CINTERFACE) 947 | #define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 948 | #define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->lpVtbl->GetConeAngles(p,a,b) 949 | #define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->lpVtbl->GetConeOrientation(p,a) 950 | #define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->lpVtbl->GetConeOutsideVolume(p,a) 951 | #define IDirectSound3DBuffer_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) 952 | #define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->lpVtbl->GetMinDistance(p,a) 953 | #define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->lpVtbl->GetMaxDistance(p,a) 954 | #define IDirectSound3DBuffer_GetMode(p,a) (p)->lpVtbl->GetMode(p,a) 955 | #define IDirectSound3DBuffer_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) 956 | #define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) 957 | #define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->lpVtbl->SetConeAngles(p,a,b,c) 958 | #define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->lpVtbl->SetConeOrientation(p,a,b,c,d) 959 | #define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->lpVtbl->SetConeOutsideVolume(p,a,b) 960 | #define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) 961 | #define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->lpVtbl->SetMinDistance(p,a,b) 962 | #define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->lpVtbl->SetMaxDistance(p,a,b) 963 | #define IDirectSound3DBuffer_SetMode(p,a,b) (p)->lpVtbl->SetMode(p,a,b) 964 | #define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) 965 | #else // !defined(__cplusplus) || defined(CINTERFACE) 966 | #define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->GetAllParameters(a) 967 | #define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->GetConeAngles(a,b) 968 | #define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->GetConeOrientation(a) 969 | #define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->GetConeOutsideVolume(a) 970 | #define IDirectSound3DBuffer_GetPosition(p,a) (p)->GetPosition(a) 971 | #define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->GetMinDistance(a) 972 | #define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->GetMaxDistance(a) 973 | #define IDirectSound3DBuffer_GetMode(p,a) (p)->GetMode(a) 974 | #define IDirectSound3DBuffer_GetVelocity(p,a) (p)->GetVelocity(a) 975 | #define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) 976 | #define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->SetConeAngles(a,b,c) 977 | #define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d) 978 | #define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->SetConeOutsideVolume(a,b) 979 | #define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) 980 | #define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->SetMinDistance(a,b) 981 | #define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->SetMaxDistance(a,b) 982 | #define IDirectSound3DBuffer_SetMode(p,a,b) (p)->SetMode(a,b) 983 | #define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) 984 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 985 | 986 | // 987 | // IDirectSoundCapture 988 | // 989 | 990 | DEFINE_GUID(IID_IDirectSoundCapture, 0xb0210781, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); 991 | 992 | #undef INTERFACE 993 | #define INTERFACE IDirectSoundCapture 994 | 995 | DECLARE_INTERFACE_(IDirectSoundCapture, IUnknown) 996 | { 997 | // IUnknown methods 998 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 999 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1000 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1001 | 1002 | // IDirectSoundCapture methods 1003 | STDMETHOD(CreateCaptureBuffer) (THIS_ LPCDSCBUFFERDESC pcDSCBufferDesc, LPDIRECTSOUNDCAPTUREBUFFER *ppDSCBuffer, LPUNKNOWN pUnkOuter) PURE; 1004 | STDMETHOD(GetCaps) (THIS_ LPDSCCAPS pDSCCaps) PURE; 1005 | STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; 1006 | }; 1007 | 1008 | #define IDirectSoundCapture_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1009 | #define IDirectSoundCapture_AddRef(p) IUnknown_AddRef(p) 1010 | #define IDirectSoundCapture_Release(p) IUnknown_Release(p) 1011 | 1012 | #if !defined(__cplusplus) || defined(CINTERFACE) 1013 | #define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->lpVtbl->CreateCaptureBuffer(p,a,b,c) 1014 | #define IDirectSoundCapture_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) 1015 | #define IDirectSoundCapture_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) 1016 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1017 | #define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->CreateCaptureBuffer(a,b,c) 1018 | #define IDirectSoundCapture_GetCaps(p,a) (p)->GetCaps(a) 1019 | #define IDirectSoundCapture_Initialize(p,a) (p)->Initialize(a) 1020 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1021 | 1022 | // 1023 | // IDirectSoundCaptureBuffer 1024 | // 1025 | 1026 | DEFINE_GUID(IID_IDirectSoundCaptureBuffer, 0xb0210782, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); 1027 | 1028 | #undef INTERFACE 1029 | #define INTERFACE IDirectSoundCaptureBuffer 1030 | 1031 | DECLARE_INTERFACE_(IDirectSoundCaptureBuffer, IUnknown) 1032 | { 1033 | // IUnknown methods 1034 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1035 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1036 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1037 | 1038 | // IDirectSoundCaptureBuffer methods 1039 | STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; 1040 | STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; 1041 | STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; 1042 | STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; 1043 | STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; 1044 | STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, 1045 | LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; 1046 | STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; 1047 | STDMETHOD(Stop) (THIS) PURE; 1048 | STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; 1049 | }; 1050 | 1051 | #define IDirectSoundCaptureBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1052 | #define IDirectSoundCaptureBuffer_AddRef(p) IUnknown_AddRef(p) 1053 | #define IDirectSoundCaptureBuffer_Release(p) IUnknown_Release(p) 1054 | 1055 | #if !defined(__cplusplus) || defined(CINTERFACE) 1056 | #define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) 1057 | #define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) 1058 | #define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) 1059 | #define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) 1060 | #define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) 1061 | #define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) 1062 | #define IDirectSoundCaptureBuffer_Start(p,a) (p)->lpVtbl->Start(p,a) 1063 | #define IDirectSoundCaptureBuffer_Stop(p) (p)->lpVtbl->Stop(p) 1064 | #define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) 1065 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1066 | #define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->GetCaps(a) 1067 | #define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) 1068 | #define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) 1069 | #define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->GetStatus(a) 1070 | #define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->Initialize(a,b) 1071 | #define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) 1072 | #define IDirectSoundCaptureBuffer_Start(p,a) (p)->Start(a) 1073 | #define IDirectSoundCaptureBuffer_Stop(p) (p)->Stop() 1074 | #define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) 1075 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1076 | 1077 | 1078 | #if DIRECTSOUND_VERSION >= 0x0800 1079 | 1080 | // 1081 | // IDirectSoundCaptureBuffer8 1082 | // 1083 | 1084 | DEFINE_GUID(IID_IDirectSoundCaptureBuffer8, 0x990df4, 0xdbb, 0x4872, 0x83, 0x3e, 0x6d, 0x30, 0x3e, 0x80, 0xae, 0xb6); 1085 | 1086 | #undef INTERFACE 1087 | #define INTERFACE IDirectSoundCaptureBuffer8 1088 | 1089 | DECLARE_INTERFACE_(IDirectSoundCaptureBuffer8, IDirectSoundCaptureBuffer) 1090 | { 1091 | // IUnknown methods 1092 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1093 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1094 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1095 | 1096 | // IDirectSoundCaptureBuffer methods 1097 | STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; 1098 | STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; 1099 | STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; 1100 | STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; 1101 | STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; 1102 | STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, 1103 | LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; 1104 | STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; 1105 | STDMETHOD(Stop) (THIS) PURE; 1106 | STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; 1107 | 1108 | // IDirectSoundCaptureBuffer8 methods 1109 | STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; 1110 | STDMETHOD(GetFXStatus) (DWORD dwFXCount, LPDWORD pdwFXStatus) PURE; 1111 | }; 1112 | 1113 | #define IDirectSoundCaptureBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1114 | #define IDirectSoundCaptureBuffer8_AddRef(p) IUnknown_AddRef(p) 1115 | #define IDirectSoundCaptureBuffer8_Release(p) IUnknown_Release(p) 1116 | 1117 | #define IDirectSoundCaptureBuffer8_GetCaps(p,a) IDirectSoundCaptureBuffer_GetCaps(p,a) 1118 | #define IDirectSoundCaptureBuffer8_GetCurrentPosition(p,a,b) IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) 1119 | #define IDirectSoundCaptureBuffer8_GetFormat(p,a,b,c) IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) 1120 | #define IDirectSoundCaptureBuffer8_GetStatus(p,a) IDirectSoundCaptureBuffer_GetStatus(p,a) 1121 | #define IDirectSoundCaptureBuffer8_Initialize(p,a,b) IDirectSoundCaptureBuffer_Initialize(p,a,b) 1122 | #define IDirectSoundCaptureBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) 1123 | #define IDirectSoundCaptureBuffer8_Start(p,a) IDirectSoundCaptureBuffer_Start(p,a) 1124 | #define IDirectSoundCaptureBuffer8_Stop(p) IDirectSoundCaptureBuffer_Stop(p)) 1125 | #define IDirectSoundCaptureBuffer8_Unlock(p,a,b,c,d) IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) 1126 | 1127 | #if !defined(__cplusplus) || defined(CINTERFACE) 1128 | #define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) 1129 | #define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->lpVtbl->GetFXStatus(p,a,b) 1130 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1131 | #define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) 1132 | #define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->GetFXStatus(a,b) 1133 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1134 | 1135 | #endif // DIRECTSOUND_VERSION >= 0x0800 1136 | 1137 | // 1138 | // IDirectSoundNotify 1139 | // 1140 | 1141 | DEFINE_GUID(IID_IDirectSoundNotify, 0xb0210783, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); 1142 | 1143 | #undef INTERFACE 1144 | #define INTERFACE IDirectSoundNotify 1145 | 1146 | DECLARE_INTERFACE_(IDirectSoundNotify, IUnknown) 1147 | { 1148 | // IUnknown methods 1149 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1150 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1151 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1152 | 1153 | // IDirectSoundNotify methods 1154 | STDMETHOD(SetNotificationPositions) (THIS_ DWORD dwPositionNotifies, LPCDSBPOSITIONNOTIFY pcPositionNotifies) PURE; 1155 | }; 1156 | 1157 | #define IDirectSoundNotify_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1158 | #define IDirectSoundNotify_AddRef(p) IUnknown_AddRef(p) 1159 | #define IDirectSoundNotify_Release(p) IUnknown_Release(p) 1160 | 1161 | #if !defined(__cplusplus) || defined(CINTERFACE) 1162 | #define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->lpVtbl->SetNotificationPositions(p,a,b) 1163 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1164 | #define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->SetNotificationPositions(a,b) 1165 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1166 | 1167 | // 1168 | // IKsPropertySet 1169 | // 1170 | 1171 | #ifndef _IKsPropertySet_ 1172 | #define _IKsPropertySet_ 1173 | 1174 | #ifdef __cplusplus 1175 | // 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined 1176 | struct IKsPropertySet; 1177 | #endif // __cplusplus 1178 | 1179 | typedef struct IKsPropertySet *LPKSPROPERTYSET; 1180 | 1181 | #define KSPROPERTY_SUPPORT_GET 0x00000001 1182 | #define KSPROPERTY_SUPPORT_SET 0x00000002 1183 | 1184 | DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93); 1185 | 1186 | #undef INTERFACE 1187 | #define INTERFACE IKsPropertySet 1188 | 1189 | DECLARE_INTERFACE_(IKsPropertySet, IUnknown) 1190 | { 1191 | // IUnknown methods 1192 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1193 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1194 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1195 | 1196 | // IKsPropertySet methods 1197 | STDMETHOD(Get) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, 1198 | LPVOID pPropertyData, ULONG ulDataLength, PULONG pulBytesReturned) PURE; 1199 | STDMETHOD(Set) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, 1200 | LPVOID pPropertyData, ULONG ulDataLength) PURE; 1201 | STDMETHOD(QuerySupport) (THIS_ REFGUID rguidPropSet, ULONG ulId, PULONG pulTypeSupport) PURE; 1202 | }; 1203 | 1204 | #define IKsPropertySet_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1205 | #define IKsPropertySet_AddRef(p) IUnknown_AddRef(p) 1206 | #define IKsPropertySet_Release(p) IUnknown_Release(p) 1207 | 1208 | #if !defined(__cplusplus) || defined(CINTERFACE) 1209 | #define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->lpVtbl->Get(p,a,b,c,d,e,f,g) 1210 | #define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->lpVtbl->Set(p,a,b,c,d,e,f) 1211 | #define IKsPropertySet_QuerySupport(p,a,b,c) (p)->lpVtbl->QuerySupport(p,a,b,c) 1212 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1213 | #define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->Get(a,b,c,d,e,f,g) 1214 | #define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->Set(a,b,c,d,e,f) 1215 | #define IKsPropertySet_QuerySupport(p,a,b,c) (p)->QuerySupport(a,b,c) 1216 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1217 | 1218 | #endif // _IKsPropertySet_ 1219 | 1220 | #if DIRECTSOUND_VERSION >= 0x0800 1221 | 1222 | // 1223 | // IDirectSoundFXGargle 1224 | // 1225 | 1226 | DEFINE_GUID(IID_IDirectSoundFXGargle, 0xd616f352, 0xd622, 0x11ce, 0xaa, 0xc5, 0x00, 0x20, 0xaf, 0x0b, 0x99, 0xa3); 1227 | 1228 | typedef struct _DSFXGargle 1229 | { 1230 | DWORD dwRateHz; // Rate of modulation in hz 1231 | DWORD dwWaveShape; // DSFXGARGLE_WAVE_xxx 1232 | } DSFXGargle, *LPDSFXGargle; 1233 | 1234 | #define DSFXGARGLE_WAVE_TRIANGLE 0 1235 | #define DSFXGARGLE_WAVE_SQUARE 1 1236 | 1237 | typedef const DSFXGargle *LPCDSFXGargle; 1238 | 1239 | #define DSFXGARGLE_RATEHZ_MIN 1 1240 | #define DSFXGARGLE_RATEHZ_MAX 1000 1241 | 1242 | #undef INTERFACE 1243 | #define INTERFACE IDirectSoundFXGargle 1244 | 1245 | DECLARE_INTERFACE_(IDirectSoundFXGargle, IUnknown) 1246 | { 1247 | // IUnknown methods 1248 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1249 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1250 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1251 | 1252 | // IDirectSoundFXGargle methods 1253 | STDMETHOD(SetAllParameters) (THIS_ LPCDSFXGargle pcDsFxGargle) PURE; 1254 | STDMETHOD(GetAllParameters) (THIS_ LPDSFXGargle pDsFxGargle) PURE; 1255 | }; 1256 | 1257 | #define IDirectSoundFXGargle_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1258 | #define IDirectSoundFXGargle_AddRef(p) IUnknown_AddRef(p) 1259 | #define IDirectSoundFXGargle_Release(p) IUnknown_Release(p) 1260 | 1261 | #if !defined(__cplusplus) || defined(CINTERFACE) 1262 | #define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1263 | #define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1264 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1265 | #define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->SetAllParameters(a) 1266 | #define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->GetAllParameters(a) 1267 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1268 | 1269 | // 1270 | // IDirectSoundFXChorus 1271 | // 1272 | 1273 | DEFINE_GUID(IID_IDirectSoundFXChorus, 0x880842e3, 0x145f, 0x43e6, 0xa9, 0x34, 0xa7, 0x18, 0x06, 0xe5, 0x05, 0x47); 1274 | 1275 | typedef struct _DSFXChorus 1276 | { 1277 | FLOAT fWetDryMix; 1278 | FLOAT fDepth; 1279 | FLOAT fFeedback; 1280 | FLOAT fFrequency; 1281 | LONG lWaveform; // LFO shape; DSFXCHORUS_WAVE_xxx 1282 | FLOAT fDelay; 1283 | LONG lPhase; 1284 | } DSFXChorus, *LPDSFXChorus; 1285 | 1286 | typedef const DSFXChorus *LPCDSFXChorus; 1287 | 1288 | #define DSFXCHORUS_WAVE_TRIANGLE 0 1289 | #define DSFXCHORUS_WAVE_SIN 1 1290 | 1291 | #define DSFXCHORUS_WETDRYMIX_MIN 0.0f 1292 | #define DSFXCHORUS_WETDRYMIX_MAX 100.0f 1293 | #define DSFXCHORUS_DEPTH_MIN 0.0f 1294 | #define DSFXCHORUS_DEPTH_MAX 100.0f 1295 | #define DSFXCHORUS_FEEDBACK_MIN -99.0f 1296 | #define DSFXCHORUS_FEEDBACK_MAX 99.0f 1297 | #define DSFXCHORUS_FREQUENCY_MIN 0.0f 1298 | #define DSFXCHORUS_FREQUENCY_MAX 10.0f 1299 | #define DSFXCHORUS_DELAY_MIN 0.0f 1300 | #define DSFXCHORUS_DELAY_MAX 20.0f 1301 | #define DSFXCHORUS_PHASE_MIN 0 1302 | #define DSFXCHORUS_PHASE_MAX 4 1303 | 1304 | #define DSFXCHORUS_PHASE_NEG_180 0 1305 | #define DSFXCHORUS_PHASE_NEG_90 1 1306 | #define DSFXCHORUS_PHASE_ZERO 2 1307 | #define DSFXCHORUS_PHASE_90 3 1308 | #define DSFXCHORUS_PHASE_180 4 1309 | 1310 | #undef INTERFACE 1311 | #define INTERFACE IDirectSoundFXChorus 1312 | 1313 | DECLARE_INTERFACE_(IDirectSoundFXChorus, IUnknown) 1314 | { 1315 | // IUnknown methods 1316 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1317 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1318 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1319 | 1320 | // IDirectSoundFXChorus methods 1321 | STDMETHOD(SetAllParameters) (THIS_ LPCDSFXChorus pcDsFxChorus) PURE; 1322 | STDMETHOD(GetAllParameters) (THIS_ LPDSFXChorus pDsFxChorus) PURE; 1323 | }; 1324 | 1325 | #define IDirectSoundFXChorus_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1326 | #define IDirectSoundFXChorus_AddRef(p) IUnknown_AddRef(p) 1327 | #define IDirectSoundFXChorus_Release(p) IUnknown_Release(p) 1328 | 1329 | #if !defined(__cplusplus) || defined(CINTERFACE) 1330 | #define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1331 | #define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1332 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1333 | #define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->SetAllParameters(a) 1334 | #define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->GetAllParameters(a) 1335 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1336 | 1337 | // 1338 | // IDirectSoundFXFlanger 1339 | // 1340 | 1341 | DEFINE_GUID(IID_IDirectSoundFXFlanger, 0x903e9878, 0x2c92, 0x4072, 0x9b, 0x2c, 0xea, 0x68, 0xf5, 0x39, 0x67, 0x83); 1342 | 1343 | typedef struct _DSFXFlanger 1344 | { 1345 | FLOAT fWetDryMix; 1346 | FLOAT fDepth; 1347 | FLOAT fFeedback; 1348 | FLOAT fFrequency; 1349 | LONG lWaveform; 1350 | FLOAT fDelay; 1351 | LONG lPhase; 1352 | } DSFXFlanger, *LPDSFXFlanger; 1353 | 1354 | typedef const DSFXFlanger *LPCDSFXFlanger; 1355 | 1356 | #define DSFXFLANGER_WAVE_TRIANGLE 0 1357 | #define DSFXFLANGER_WAVE_SIN 1 1358 | 1359 | #define DSFXFLANGER_WETDRYMIX_MIN 0.0f 1360 | #define DSFXFLANGER_WETDRYMIX_MAX 100.0f 1361 | #define DSFXFLANGER_FREQUENCY_MIN 0.0f 1362 | #define DSFXFLANGER_FREQUENCY_MAX 10.0f 1363 | #define DSFXFLANGER_DEPTH_MIN 0.0f 1364 | #define DSFXFLANGER_DEPTH_MAX 100.0f 1365 | #define DSFXFLANGER_PHASE_MIN 0 1366 | #define DSFXFLANGER_PHASE_MAX 4 1367 | #define DSFXFLANGER_FEEDBACK_MIN -99.0f 1368 | #define DSFXFLANGER_FEEDBACK_MAX 99.0f 1369 | #define DSFXFLANGER_DELAY_MIN 0.0f 1370 | #define DSFXFLANGER_DELAY_MAX 4.0f 1371 | 1372 | #define DSFXFLANGER_PHASE_NEG_180 0 1373 | #define DSFXFLANGER_PHASE_NEG_90 1 1374 | #define DSFXFLANGER_PHASE_ZERO 2 1375 | #define DSFXFLANGER_PHASE_90 3 1376 | #define DSFXFLANGER_PHASE_180 4 1377 | 1378 | #undef INTERFACE 1379 | #define INTERFACE IDirectSoundFXFlanger 1380 | 1381 | DECLARE_INTERFACE_(IDirectSoundFXFlanger, IUnknown) 1382 | { 1383 | // IUnknown methods 1384 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1385 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1386 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1387 | 1388 | // IDirectSoundFXFlanger methods 1389 | STDMETHOD(SetAllParameters) (THIS_ LPCDSFXFlanger pcDsFxFlanger) PURE; 1390 | STDMETHOD(GetAllParameters) (THIS_ LPDSFXFlanger pDsFxFlanger) PURE; 1391 | }; 1392 | 1393 | #define IDirectSoundFXFlanger_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1394 | #define IDirectSoundFXFlanger_AddRef(p) IUnknown_AddRef(p) 1395 | #define IDirectSoundFXFlanger_Release(p) IUnknown_Release(p) 1396 | 1397 | #if !defined(__cplusplus) || defined(CINTERFACE) 1398 | #define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1399 | #define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1400 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1401 | #define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->SetAllParameters(a) 1402 | #define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->GetAllParameters(a) 1403 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1404 | 1405 | // 1406 | // IDirectSoundFXEcho 1407 | // 1408 | 1409 | DEFINE_GUID(IID_IDirectSoundFXEcho, 0x8bd28edf, 0x50db, 0x4e92, 0xa2, 0xbd, 0x44, 0x54, 0x88, 0xd1, 0xed, 0x42); 1410 | 1411 | typedef struct _DSFXEcho 1412 | { 1413 | FLOAT fWetDryMix; 1414 | FLOAT fFeedback; 1415 | FLOAT fLeftDelay; 1416 | FLOAT fRightDelay; 1417 | LONG lPanDelay; 1418 | } DSFXEcho, *LPDSFXEcho; 1419 | 1420 | typedef const DSFXEcho *LPCDSFXEcho; 1421 | 1422 | #define DSFXECHO_WETDRYMIX_MIN 0.0f 1423 | #define DSFXECHO_WETDRYMIX_MAX 100.0f 1424 | #define DSFXECHO_FEEDBACK_MIN 0.0f 1425 | #define DSFXECHO_FEEDBACK_MAX 100.0f 1426 | #define DSFXECHO_LEFTDELAY_MIN 1.0f 1427 | #define DSFXECHO_LEFTDELAY_MAX 2000.0f 1428 | #define DSFXECHO_RIGHTDELAY_MIN 1.0f 1429 | #define DSFXECHO_RIGHTDELAY_MAX 2000.0f 1430 | #define DSFXECHO_PANDELAY_MIN 0 1431 | #define DSFXECHO_PANDELAY_MAX 1 1432 | 1433 | #undef INTERFACE 1434 | #define INTERFACE IDirectSoundFXEcho 1435 | 1436 | DECLARE_INTERFACE_(IDirectSoundFXEcho, IUnknown) 1437 | { 1438 | // IUnknown methods 1439 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1440 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1441 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1442 | 1443 | // IDirectSoundFXEcho methods 1444 | STDMETHOD(SetAllParameters) (THIS_ LPCDSFXEcho pcDsFxEcho) PURE; 1445 | STDMETHOD(GetAllParameters) (THIS_ LPDSFXEcho pDsFxEcho) PURE; 1446 | }; 1447 | 1448 | #define IDirectSoundFXEcho_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1449 | #define IDirectSoundFXEcho_AddRef(p) IUnknown_AddRef(p) 1450 | #define IDirectSoundFXEcho_Release(p) IUnknown_Release(p) 1451 | 1452 | #if !defined(__cplusplus) || defined(CINTERFACE) 1453 | #define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1454 | #define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1455 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1456 | #define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->SetAllParameters(a) 1457 | #define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->GetAllParameters(a) 1458 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1459 | 1460 | // 1461 | // IDirectSoundFXDistortion 1462 | // 1463 | 1464 | DEFINE_GUID(IID_IDirectSoundFXDistortion, 0x8ecf4326, 0x455f, 0x4d8b, 0xbd, 0xa9, 0x8d, 0x5d, 0x3e, 0x9e, 0x3e, 0x0b); 1465 | 1466 | typedef struct _DSFXDistortion 1467 | { 1468 | FLOAT fGain; 1469 | FLOAT fEdge; 1470 | FLOAT fPostEQCenterFrequency; 1471 | FLOAT fPostEQBandwidth; 1472 | FLOAT fPreLowpassCutoff; 1473 | } DSFXDistortion, *LPDSFXDistortion; 1474 | 1475 | typedef const DSFXDistortion *LPCDSFXDistortion; 1476 | 1477 | #define DSFXDISTORTION_GAIN_MIN -60.0f 1478 | #define DSFXDISTORTION_GAIN_MAX 0.0f 1479 | #define DSFXDISTORTION_EDGE_MIN 0.0f 1480 | #define DSFXDISTORTION_EDGE_MAX 100.0f 1481 | #define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MIN 100.0f 1482 | #define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MAX 8000.0f 1483 | #define DSFXDISTORTION_POSTEQBANDWIDTH_MIN 100.0f 1484 | #define DSFXDISTORTION_POSTEQBANDWIDTH_MAX 8000.0f 1485 | #define DSFXDISTORTION_PRELOWPASSCUTOFF_MIN 100.0f 1486 | #define DSFXDISTORTION_PRELOWPASSCUTOFF_MAX 8000.0f 1487 | 1488 | #undef INTERFACE 1489 | #define INTERFACE IDirectSoundFXDistortion 1490 | 1491 | DECLARE_INTERFACE_(IDirectSoundFXDistortion, IUnknown) 1492 | { 1493 | // IUnknown methods 1494 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1495 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1496 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1497 | 1498 | // IDirectSoundFXDistortion methods 1499 | STDMETHOD(SetAllParameters) (THIS_ LPCDSFXDistortion pcDsFxDistortion) PURE; 1500 | STDMETHOD(GetAllParameters) (THIS_ LPDSFXDistortion pDsFxDistortion) PURE; 1501 | }; 1502 | 1503 | #define IDirectSoundFXDistortion_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1504 | #define IDirectSoundFXDistortion_AddRef(p) IUnknown_AddRef(p) 1505 | #define IDirectSoundFXDistortion_Release(p) IUnknown_Release(p) 1506 | 1507 | #if !defined(__cplusplus) || defined(CINTERFACE) 1508 | #define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1509 | #define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1510 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1511 | #define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->SetAllParameters(a) 1512 | #define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->GetAllParameters(a) 1513 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1514 | 1515 | // 1516 | // IDirectSoundFXCompressor 1517 | // 1518 | 1519 | DEFINE_GUID(IID_IDirectSoundFXCompressor, 0x4bbd1154, 0x62f6, 0x4e2c, 0xa1, 0x5c, 0xd3, 0xb6, 0xc4, 0x17, 0xf7, 0xa0); 1520 | 1521 | typedef struct _DSFXCompressor 1522 | { 1523 | FLOAT fGain; 1524 | FLOAT fAttack; 1525 | FLOAT fRelease; 1526 | FLOAT fThreshold; 1527 | FLOAT fRatio; 1528 | FLOAT fPredelay; 1529 | } DSFXCompressor, *LPDSFXCompressor; 1530 | 1531 | typedef const DSFXCompressor *LPCDSFXCompressor; 1532 | 1533 | #define DSFXCOMPRESSOR_GAIN_MIN -60.0f 1534 | #define DSFXCOMPRESSOR_GAIN_MAX 60.0f 1535 | #define DSFXCOMPRESSOR_ATTACK_MIN 0.01f 1536 | #define DSFXCOMPRESSOR_ATTACK_MAX 500.0f 1537 | #define DSFXCOMPRESSOR_RELEASE_MIN 50.0f 1538 | #define DSFXCOMPRESSOR_RELEASE_MAX 3000.0f 1539 | #define DSFXCOMPRESSOR_THRESHOLD_MIN -60.0f 1540 | #define DSFXCOMPRESSOR_THRESHOLD_MAX 0.0f 1541 | #define DSFXCOMPRESSOR_RATIO_MIN 1.0f 1542 | #define DSFXCOMPRESSOR_RATIO_MAX 100.0f 1543 | #define DSFXCOMPRESSOR_PREDELAY_MIN 0.0f 1544 | #define DSFXCOMPRESSOR_PREDELAY_MAX 4.0f 1545 | 1546 | #undef INTERFACE 1547 | #define INTERFACE IDirectSoundFXCompressor 1548 | 1549 | DECLARE_INTERFACE_(IDirectSoundFXCompressor, IUnknown) 1550 | { 1551 | // IUnknown methods 1552 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1553 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1554 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1555 | 1556 | // IDirectSoundFXCompressor methods 1557 | STDMETHOD(SetAllParameters) (THIS_ LPCDSFXCompressor pcDsFxCompressor) PURE; 1558 | STDMETHOD(GetAllParameters) (THIS_ LPDSFXCompressor pDsFxCompressor) PURE; 1559 | }; 1560 | 1561 | #define IDirectSoundFXCompressor_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1562 | #define IDirectSoundFXCompressor_AddRef(p) IUnknown_AddRef(p) 1563 | #define IDirectSoundFXCompressor_Release(p) IUnknown_Release(p) 1564 | 1565 | #if !defined(__cplusplus) || defined(CINTERFACE) 1566 | #define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1567 | #define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1568 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1569 | #define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->SetAllParameters(a) 1570 | #define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->GetAllParameters(a) 1571 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1572 | 1573 | // 1574 | // IDirectSoundFXParamEq 1575 | // 1576 | 1577 | DEFINE_GUID(IID_IDirectSoundFXParamEq, 0xc03ca9fe, 0xfe90, 0x4204, 0x80, 0x78, 0x82, 0x33, 0x4c, 0xd1, 0x77, 0xda); 1578 | 1579 | typedef struct _DSFXParamEq 1580 | { 1581 | FLOAT fCenter; 1582 | FLOAT fBandwidth; 1583 | FLOAT fGain; 1584 | } DSFXParamEq, *LPDSFXParamEq; 1585 | 1586 | typedef const DSFXParamEq *LPCDSFXParamEq; 1587 | 1588 | #define DSFXPARAMEQ_CENTER_MIN 80.0f 1589 | #define DSFXPARAMEQ_CENTER_MAX 16000.0f 1590 | #define DSFXPARAMEQ_BANDWIDTH_MIN 1.0f 1591 | #define DSFXPARAMEQ_BANDWIDTH_MAX 36.0f 1592 | #define DSFXPARAMEQ_GAIN_MIN -15.0f 1593 | #define DSFXPARAMEQ_GAIN_MAX 15.0f 1594 | 1595 | #undef INTERFACE 1596 | #define INTERFACE IDirectSoundFXParamEq 1597 | 1598 | DECLARE_INTERFACE_(IDirectSoundFXParamEq, IUnknown) 1599 | { 1600 | // IUnknown methods 1601 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1602 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1603 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1604 | 1605 | // IDirectSoundFXParamEq methods 1606 | STDMETHOD(SetAllParameters) (THIS_ LPCDSFXParamEq pcDsFxParamEq) PURE; 1607 | STDMETHOD(GetAllParameters) (THIS_ LPDSFXParamEq pDsFxParamEq) PURE; 1608 | }; 1609 | 1610 | #define IDirectSoundFXParamEq_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1611 | #define IDirectSoundFXParamEq_AddRef(p) IUnknown_AddRef(p) 1612 | #define IDirectSoundFXParamEq_Release(p) IUnknown_Release(p) 1613 | 1614 | #if !defined(__cplusplus) || defined(CINTERFACE) 1615 | #define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1616 | #define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1617 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1618 | #define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->SetAllParameters(a) 1619 | #define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->GetAllParameters(a) 1620 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1621 | 1622 | // 1623 | // IDirectSoundFXI3DL2Reverb 1624 | // 1625 | 1626 | DEFINE_GUID(IID_IDirectSoundFXI3DL2Reverb, 0x4b166a6a, 0x0d66, 0x43f3, 0x80, 0xe3, 0xee, 0x62, 0x80, 0xde, 0xe1, 0xa4); 1627 | 1628 | typedef struct _DSFXI3DL2Reverb 1629 | { 1630 | LONG lRoom; // [-10000, 0] default: -1000 mB 1631 | LONG lRoomHF; // [-10000, 0] default: 0 mB 1632 | FLOAT flRoomRolloffFactor; // [0.0, 10.0] default: 0.0 1633 | FLOAT flDecayTime; // [0.1, 20.0] default: 1.49s 1634 | FLOAT flDecayHFRatio; // [0.1, 2.0] default: 0.83 1635 | LONG lReflections; // [-10000, 1000] default: -2602 mB 1636 | FLOAT flReflectionsDelay; // [0.0, 0.3] default: 0.007 s 1637 | LONG lReverb; // [-10000, 2000] default: 200 mB 1638 | FLOAT flReverbDelay; // [0.0, 0.1] default: 0.011 s 1639 | FLOAT flDiffusion; // [0.0, 100.0] default: 100.0 % 1640 | FLOAT flDensity; // [0.0, 100.0] default: 100.0 % 1641 | FLOAT flHFReference; // [20.0, 20000.0] default: 5000.0 Hz 1642 | } DSFXI3DL2Reverb, *LPDSFXI3DL2Reverb; 1643 | 1644 | typedef const DSFXI3DL2Reverb *LPCDSFXI3DL2Reverb; 1645 | 1646 | #define DSFX_I3DL2REVERB_ROOM_MIN (-10000) 1647 | #define DSFX_I3DL2REVERB_ROOM_MAX 0 1648 | #define DSFX_I3DL2REVERB_ROOM_DEFAULT (-1000) 1649 | 1650 | #define DSFX_I3DL2REVERB_ROOMHF_MIN (-10000) 1651 | #define DSFX_I3DL2REVERB_ROOMHF_MAX 0 1652 | #define DSFX_I3DL2REVERB_ROOMHF_DEFAULT (-100) 1653 | 1654 | #define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MIN 0.0f 1655 | #define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MAX 10.0f 1656 | #define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_DEFAULT 0.0f 1657 | 1658 | #define DSFX_I3DL2REVERB_DECAYTIME_MIN 0.1f 1659 | #define DSFX_I3DL2REVERB_DECAYTIME_MAX 20.0f 1660 | #define DSFX_I3DL2REVERB_DECAYTIME_DEFAULT 1.49f 1661 | 1662 | #define DSFX_I3DL2REVERB_DECAYHFRATIO_MIN 0.1f 1663 | #define DSFX_I3DL2REVERB_DECAYHFRATIO_MAX 2.0f 1664 | #define DSFX_I3DL2REVERB_DECAYHFRATIO_DEFAULT 0.83f 1665 | 1666 | #define DSFX_I3DL2REVERB_REFLECTIONS_MIN (-10000) 1667 | #define DSFX_I3DL2REVERB_REFLECTIONS_MAX 1000 1668 | #define DSFX_I3DL2REVERB_REFLECTIONS_DEFAULT (-2602) 1669 | 1670 | #define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MIN 0.0f 1671 | #define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MAX 0.3f 1672 | #define DSFX_I3DL2REVERB_REFLECTIONSDELAY_DEFAULT 0.007f 1673 | 1674 | #define DSFX_I3DL2REVERB_REVERB_MIN (-10000) 1675 | #define DSFX_I3DL2REVERB_REVERB_MAX 2000 1676 | #define DSFX_I3DL2REVERB_REVERB_DEFAULT (200) 1677 | 1678 | #define DSFX_I3DL2REVERB_REVERBDELAY_MIN 0.0f 1679 | #define DSFX_I3DL2REVERB_REVERBDELAY_MAX 0.1f 1680 | #define DSFX_I3DL2REVERB_REVERBDELAY_DEFAULT 0.011f 1681 | 1682 | #define DSFX_I3DL2REVERB_DIFFUSION_MIN 0.0f 1683 | #define DSFX_I3DL2REVERB_DIFFUSION_MAX 100.0f 1684 | #define DSFX_I3DL2REVERB_DIFFUSION_DEFAULT 100.0f 1685 | 1686 | #define DSFX_I3DL2REVERB_DENSITY_MIN 0.0f 1687 | #define DSFX_I3DL2REVERB_DENSITY_MAX 100.0f 1688 | #define DSFX_I3DL2REVERB_DENSITY_DEFAULT 100.0f 1689 | 1690 | #define DSFX_I3DL2REVERB_HFREFERENCE_MIN 20.0f 1691 | #define DSFX_I3DL2REVERB_HFREFERENCE_MAX 20000.0f 1692 | #define DSFX_I3DL2REVERB_HFREFERENCE_DEFAULT 5000.0f 1693 | 1694 | #define DSFX_I3DL2REVERB_QUALITY_MIN 0 1695 | #define DSFX_I3DL2REVERB_QUALITY_MAX 3 1696 | #define DSFX_I3DL2REVERB_QUALITY_DEFAULT 2 1697 | 1698 | #undef INTERFACE 1699 | #define INTERFACE IDirectSoundFXI3DL2Reverb 1700 | 1701 | DECLARE_INTERFACE_(IDirectSoundFXI3DL2Reverb, IUnknown) 1702 | { 1703 | // IUnknown methods 1704 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1705 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1706 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1707 | 1708 | // IDirectSoundFXI3DL2Reverb methods 1709 | STDMETHOD(SetAllParameters) (THIS_ LPCDSFXI3DL2Reverb pcDsFxI3DL2Reverb) PURE; 1710 | STDMETHOD(GetAllParameters) (THIS_ LPDSFXI3DL2Reverb pDsFxI3DL2Reverb) PURE; 1711 | STDMETHOD(SetPreset) (THIS_ DWORD dwPreset) PURE; 1712 | STDMETHOD(GetPreset) (THIS_ LPDWORD pdwPreset) PURE; 1713 | STDMETHOD(SetQuality) (THIS_ LONG lQuality) PURE; 1714 | STDMETHOD(GetQuality) (THIS_ LONG *plQuality) PURE; 1715 | }; 1716 | 1717 | #define IDirectSoundFXI3DL2Reverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1718 | #define IDirectSoundFXI3DL2Reverb_AddRef(p) IUnknown_AddRef(p) 1719 | #define IDirectSoundFXI3DL2Reverb_Release(p) IUnknown_Release(p) 1720 | 1721 | #if !defined(__cplusplus) || defined(CINTERFACE) 1722 | #define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1723 | #define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1724 | #define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->lpVtbl->SetPreset(p,a) 1725 | #define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->lpVtbl->GetPreset(p,a) 1726 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1727 | #define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->SetAllParameters(a) 1728 | #define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->GetAllParameters(a) 1729 | #define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->SetPreset(a) 1730 | #define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->GetPreset(a) 1731 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1732 | 1733 | // 1734 | // IDirectSoundFXWavesReverb 1735 | // 1736 | 1737 | DEFINE_GUID(IID_IDirectSoundFXWavesReverb,0x46858c3a,0x0dc6,0x45e3,0xb7,0x60,0xd4,0xee,0xf1,0x6c,0xb3,0x25); 1738 | 1739 | typedef struct _DSFXWavesReverb 1740 | { 1741 | FLOAT fInGain; // [-96.0,0.0] default: 0.0 dB 1742 | FLOAT fReverbMix; // [-96.0,0.0] default: 0.0 db 1743 | FLOAT fReverbTime; // [0.001,3000.0] default: 1000.0 ms 1744 | FLOAT fHighFreqRTRatio; // [0.001,0.999] default: 0.001 1745 | } DSFXWavesReverb, *LPDSFXWavesReverb; 1746 | 1747 | typedef const DSFXWavesReverb *LPCDSFXWavesReverb; 1748 | 1749 | #define DSFX_WAVESREVERB_INGAIN_MIN -96.0f 1750 | #define DSFX_WAVESREVERB_INGAIN_MAX 0.0f 1751 | #define DSFX_WAVESREVERB_INGAIN_DEFAULT 0.0f 1752 | #define DSFX_WAVESREVERB_REVERBMIX_MIN -96.0f 1753 | #define DSFX_WAVESREVERB_REVERBMIX_MAX 0.0f 1754 | #define DSFX_WAVESREVERB_REVERBMIX_DEFAULT 0.0f 1755 | #define DSFX_WAVESREVERB_REVERBTIME_MIN 0.001f 1756 | #define DSFX_WAVESREVERB_REVERBTIME_MAX 3000.0f 1757 | #define DSFX_WAVESREVERB_REVERBTIME_DEFAULT 1000.0f 1758 | #define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MIN 0.001f 1759 | #define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MAX 0.999f 1760 | #define DSFX_WAVESREVERB_HIGHFREQRTRATIO_DEFAULT 0.001f 1761 | 1762 | #undef INTERFACE 1763 | #define INTERFACE IDirectSoundFXWavesReverb 1764 | 1765 | DECLARE_INTERFACE_(IDirectSoundFXWavesReverb, IUnknown) 1766 | { 1767 | // IUnknown methods 1768 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1769 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1770 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1771 | 1772 | // IDirectSoundFXWavesReverb methods 1773 | STDMETHOD(SetAllParameters) (THIS_ LPCDSFXWavesReverb pcDsFxWavesReverb) PURE; 1774 | STDMETHOD(GetAllParameters) (THIS_ LPDSFXWavesReverb pDsFxWavesReverb) PURE; 1775 | }; 1776 | 1777 | #define IDirectSoundFXWavesReverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1778 | #define IDirectSoundFXWavesReverb_AddRef(p) IUnknown_AddRef(p) 1779 | #define IDirectSoundFXWavesReverb_Release(p) IUnknown_Release(p) 1780 | 1781 | #if !defined(__cplusplus) || defined(CINTERFACE) 1782 | #define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1783 | #define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1784 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1785 | #define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->SetAllParameters(a) 1786 | #define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->GetAllParameters(a) 1787 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1788 | 1789 | // 1790 | // IDirectSoundCaptureFXAec 1791 | // 1792 | 1793 | DEFINE_GUID(IID_IDirectSoundCaptureFXAec, 0xad74143d, 0x903d, 0x4ab7, 0x80, 0x66, 0x28, 0xd3, 0x63, 0x03, 0x6d, 0x65); 1794 | 1795 | typedef struct _DSCFXAec 1796 | { 1797 | BOOL fEnable; 1798 | BOOL fNoiseFill; 1799 | DWORD dwMode; 1800 | } DSCFXAec, *LPDSCFXAec; 1801 | 1802 | typedef const DSCFXAec *LPCDSCFXAec; 1803 | 1804 | // These match the AEC_MODE_* constants in the DDK's ksmedia.h file 1805 | #define DSCFX_AEC_MODE_PASS_THROUGH 0x0 1806 | #define DSCFX_AEC_MODE_HALF_DUPLEX 0x1 1807 | #define DSCFX_AEC_MODE_FULL_DUPLEX 0x2 1808 | 1809 | // These match the AEC_STATUS_* constants in ksmedia.h 1810 | #define DSCFX_AEC_STATUS_HISTORY_UNINITIALIZED 0x0 1811 | #define DSCFX_AEC_STATUS_HISTORY_CONTINUOUSLY_CONVERGED 0x1 1812 | #define DSCFX_AEC_STATUS_HISTORY_PREVIOUSLY_DIVERGED 0x2 1813 | #define DSCFX_AEC_STATUS_CURRENTLY_CONVERGED 0x8 1814 | 1815 | #undef INTERFACE 1816 | #define INTERFACE IDirectSoundCaptureFXAec 1817 | 1818 | DECLARE_INTERFACE_(IDirectSoundCaptureFXAec, IUnknown) 1819 | { 1820 | // IUnknown methods 1821 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1822 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1823 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1824 | 1825 | // IDirectSoundCaptureFXAec methods 1826 | STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXAec pDscFxAec) PURE; 1827 | STDMETHOD(GetAllParameters) (THIS_ LPDSCFXAec pDscFxAec) PURE; 1828 | STDMETHOD(GetStatus) (THIS_ PDWORD pdwStatus) PURE; 1829 | STDMETHOD(Reset) (THIS) PURE; 1830 | }; 1831 | 1832 | #define IDirectSoundCaptureFXAec_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1833 | #define IDirectSoundCaptureFXAec_AddRef(p) IUnknown_AddRef(p) 1834 | #define IDirectSoundCaptureFXAec_Release(p) IUnknown_Release(p) 1835 | 1836 | #if !defined(__cplusplus) || defined(CINTERFACE) 1837 | #define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1838 | #define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1839 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1840 | #define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->SetAllParameters(a) 1841 | #define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->GetAllParameters(a) 1842 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1843 | 1844 | 1845 | // 1846 | // IDirectSoundCaptureFXNoiseSuppress 1847 | // 1848 | 1849 | DEFINE_GUID(IID_IDirectSoundCaptureFXNoiseSuppress, 0xed311e41, 0xfbae, 0x4175, 0x96, 0x25, 0xcd, 0x8, 0x54, 0xf6, 0x93, 0xca); 1850 | 1851 | typedef struct _DSCFXNoiseSuppress 1852 | { 1853 | BOOL fEnable; 1854 | } DSCFXNoiseSuppress, *LPDSCFXNoiseSuppress; 1855 | 1856 | typedef const DSCFXNoiseSuppress *LPCDSCFXNoiseSuppress; 1857 | 1858 | #undef INTERFACE 1859 | #define INTERFACE IDirectSoundCaptureFXNoiseSuppress 1860 | 1861 | DECLARE_INTERFACE_(IDirectSoundCaptureFXNoiseSuppress, IUnknown) 1862 | { 1863 | // IUnknown methods 1864 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1865 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1866 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1867 | 1868 | // IDirectSoundCaptureFXNoiseSuppress methods 1869 | STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXNoiseSuppress pcDscFxNoiseSuppress) PURE; 1870 | STDMETHOD(GetAllParameters) (THIS_ LPDSCFXNoiseSuppress pDscFxNoiseSuppress) PURE; 1871 | STDMETHOD(Reset) (THIS) PURE; 1872 | }; 1873 | 1874 | #define IDirectSoundCaptureFXNoiseSuppress_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1875 | #define IDirectSoundCaptureFXNoiseSuppress_AddRef(p) IUnknown_AddRef(p) 1876 | #define IDirectSoundCaptureFXNoiseSuppress_Release(p) IUnknown_Release(p) 1877 | 1878 | #if !defined(__cplusplus) || defined(CINTERFACE) 1879 | #define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) 1880 | #define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) 1881 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1882 | #define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->SetAllParameters(a) 1883 | #define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->GetAllParameters(a) 1884 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1885 | 1886 | 1887 | // 1888 | // IDirectSoundFullDuplex 1889 | // 1890 | 1891 | #ifndef _IDirectSoundFullDuplex_ 1892 | #define _IDirectSoundFullDuplex_ 1893 | 1894 | #ifdef __cplusplus 1895 | // 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined 1896 | struct IDirectSoundFullDuplex; 1897 | #endif // __cplusplus 1898 | 1899 | typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; 1900 | 1901 | DEFINE_GUID(IID_IDirectSoundFullDuplex, 0xedcb4c7a, 0xdaab, 0x4216, 0xa4, 0x2e, 0x6c, 0x50, 0x59, 0x6d, 0xdc, 0x1d); 1902 | 1903 | #undef INTERFACE 1904 | #define INTERFACE IDirectSoundFullDuplex 1905 | 1906 | DECLARE_INTERFACE_(IDirectSoundFullDuplex, IUnknown) 1907 | { 1908 | // IUnknown methods 1909 | STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; 1910 | STDMETHOD_(ULONG,AddRef) (THIS) PURE; 1911 | STDMETHOD_(ULONG,Release) (THIS) PURE; 1912 | 1913 | // IDirectSoundFullDuplex methods 1914 | STDMETHOD(Initialize) (THIS_ LPCGUID pCaptureGuid, LPCGUID pRenderGuid, LPCDSCBUFFERDESC lpDscBufferDesc, LPCDSBUFFERDESC lpDsBufferDesc, HWND hWnd, DWORD dwLevel, LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8, LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8) PURE; 1915 | }; 1916 | 1917 | #define IDirectSoundFullDuplex_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) 1918 | #define IDirectSoundFullDuplex_AddRef(p) IUnknown_AddRef(p) 1919 | #define IDirectSoundFullDuplex_Release(p) IUnknown_Release(p) 1920 | 1921 | #if !defined(__cplusplus) || defined(CINTERFACE) 1922 | #define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->Initialize(p,a,b,c,d,e,f,g,h) 1923 | #else // !defined(__cplusplus) || defined(CINTERFACE) 1924 | #define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->Initialize(a,b,c,d,e,f,g,h) 1925 | #endif // !defined(__cplusplus) || defined(CINTERFACE) 1926 | 1927 | #endif // _IDirectSoundFullDuplex_ 1928 | 1929 | #endif // DIRECTSOUND_VERSION >= 0x0800 1930 | 1931 | // 1932 | // Return Codes 1933 | // 1934 | 1935 | // The function completed successfully 1936 | #define DS_OK S_OK 1937 | 1938 | // The call succeeded, but we had to substitute the 3D algorithm 1939 | #define DS_NO_VIRTUALIZATION MAKE_HRESULT(0, _FACDS, 10) 1940 | 1941 | // The call failed because resources (such as a priority level) 1942 | // were already being used by another caller 1943 | #define DSERR_ALLOCATED MAKE_DSHRESULT(10) 1944 | 1945 | // The control (vol, pan, etc.) requested by the caller is not available 1946 | #define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT(30) 1947 | 1948 | // An invalid parameter was passed to the returning function 1949 | #define DSERR_INVALIDPARAM E_INVALIDARG 1950 | 1951 | // This call is not valid for the current state of this object 1952 | #define DSERR_INVALIDCALL MAKE_DSHRESULT(50) 1953 | 1954 | // An undetermined error occurred inside the DirectSound subsystem 1955 | #define DSERR_GENERIC E_FAIL 1956 | 1957 | // The caller does not have the priority level required for the function to 1958 | // succeed 1959 | #define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70) 1960 | 1961 | // Not enough free memory is available to complete the operation 1962 | #define DSERR_OUTOFMEMORY E_OUTOFMEMORY 1963 | 1964 | // The specified WAVE format is not supported 1965 | #define DSERR_BADFORMAT MAKE_DSHRESULT(100) 1966 | 1967 | // The function called is not supported at this time 1968 | #define DSERR_UNSUPPORTED E_NOTIMPL 1969 | 1970 | // No sound driver is available for use 1971 | #define DSERR_NODRIVER MAKE_DSHRESULT(120) 1972 | // This object is already initialized 1973 | #define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT(130) 1974 | 1975 | // This object does not support aggregation 1976 | #define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION 1977 | 1978 | // The buffer memory has been lost, and must be restored 1979 | #define DSERR_BUFFERLOST MAKE_DSHRESULT(150) 1980 | 1981 | // Another app has a higher priority level, preventing this call from 1982 | // succeeding 1983 | #define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT(160) 1984 | 1985 | // This object has not been initialized 1986 | #define DSERR_UNINITIALIZED MAKE_DSHRESULT(170) 1987 | 1988 | // The requested COM interface is not available 1989 | #define DSERR_NOINTERFACE E_NOINTERFACE 1990 | 1991 | // Access is denied 1992 | #define DSERR_ACCESSDENIED E_ACCESSDENIED 1993 | 1994 | // Tried to create a DSBCAPS_CTRLFX buffer shorter than DSBSIZE_FX_MIN milliseconds 1995 | #define DSERR_BUFFERTOOSMALL MAKE_DSHRESULT(180) 1996 | 1997 | // Attempt to use DirectSound 8 functionality on an older DirectSound object 1998 | #define DSERR_DS8_REQUIRED MAKE_DSHRESULT(190) 1999 | 2000 | // A circular loop of send effects was detected 2001 | #define DSERR_SENDLOOP MAKE_DSHRESULT(200) 2002 | 2003 | // The GUID specified in an audiopath file does not match a valid MIXIN buffer 2004 | #define DSERR_BADSENDBUFFERGUID MAKE_DSHRESULT(210) 2005 | 2006 | // The object requested was not found (numerically equal to DMUS_E_NOT_FOUND) 2007 | #define DSERR_OBJECTNOTFOUND MAKE_DSHRESULT(4449) 2008 | 2009 | // The effects requested could not be found on the system, or they were found 2010 | // but in the wrong order, or in the wrong hardware/software locations. 2011 | #define DSERR_FXUNAVAILABLE MAKE_DSHRESULT(220) 2012 | 2013 | // 2014 | // Flags 2015 | // 2016 | 2017 | #define DSCAPS_PRIMARYMONO 0x00000001 2018 | #define DSCAPS_PRIMARYSTEREO 0x00000002 2019 | #define DSCAPS_PRIMARY8BIT 0x00000004 2020 | #define DSCAPS_PRIMARY16BIT 0x00000008 2021 | #define DSCAPS_CONTINUOUSRATE 0x00000010 2022 | #define DSCAPS_EMULDRIVER 0x00000020 2023 | #define DSCAPS_CERTIFIED 0x00000040 2024 | #define DSCAPS_SECONDARYMONO 0x00000100 2025 | #define DSCAPS_SECONDARYSTEREO 0x00000200 2026 | #define DSCAPS_SECONDARY8BIT 0x00000400 2027 | #define DSCAPS_SECONDARY16BIT 0x00000800 2028 | 2029 | #define DSSCL_NORMAL 0x00000001 2030 | #define DSSCL_PRIORITY 0x00000002 2031 | #define DSSCL_EXCLUSIVE 0x00000003 2032 | #define DSSCL_WRITEPRIMARY 0x00000004 2033 | 2034 | #define DSSPEAKER_DIRECTOUT 0x00000000 2035 | #define DSSPEAKER_HEADPHONE 0x00000001 2036 | #define DSSPEAKER_MONO 0x00000002 2037 | #define DSSPEAKER_QUAD 0x00000003 2038 | #define DSSPEAKER_STEREO 0x00000004 2039 | #define DSSPEAKER_SURROUND 0x00000005 2040 | #define DSSPEAKER_5POINT1 0x00000006 // obsolete 5.1 setting 2041 | #define DSSPEAKER_7POINT1 0x00000007 // obsolete 7.1 setting 2042 | #define DSSPEAKER_7POINT1_SURROUND 0x00000008 // correct 7.1 Home Theater setting 2043 | #define DSSPEAKER_7POINT1_WIDE DSSPEAKER_7POINT1 2044 | #if (DIRECTSOUND_VERSION >= 0x1000) 2045 | #define DSSPEAKER_5POINT1_SURROUND 0x00000009 // correct 5.1 setting 2046 | #define DSSPEAKER_5POINT1_BACK DSSPEAKER_5POINT1 2047 | #endif 2048 | 2049 | #define DSSPEAKER_GEOMETRY_MIN 0x00000005 // 5 degrees 2050 | #define DSSPEAKER_GEOMETRY_NARROW 0x0000000A // 10 degrees 2051 | #define DSSPEAKER_GEOMETRY_WIDE 0x00000014 // 20 degrees 2052 | #define DSSPEAKER_GEOMETRY_MAX 0x000000B4 // 180 degrees 2053 | 2054 | #define DSSPEAKER_COMBINED(c, g) ((DWORD)(((BYTE)(c)) | ((DWORD)((BYTE)(g))) << 16)) 2055 | #define DSSPEAKER_CONFIG(a) ((BYTE)(a)) 2056 | #define DSSPEAKER_GEOMETRY(a) ((BYTE)(((DWORD)(a) >> 16) & 0x00FF)) 2057 | 2058 | #define DSBCAPS_PRIMARYBUFFER 0x00000001 2059 | #define DSBCAPS_STATIC 0x00000002 2060 | #define DSBCAPS_LOCHARDWARE 0x00000004 2061 | #define DSBCAPS_LOCSOFTWARE 0x00000008 2062 | #define DSBCAPS_CTRL3D 0x00000010 2063 | #define DSBCAPS_CTRLFREQUENCY 0x00000020 2064 | #define DSBCAPS_CTRLPAN 0x00000040 2065 | #define DSBCAPS_CTRLVOLUME 0x00000080 2066 | #define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 2067 | #define DSBCAPS_CTRLFX 0x00000200 2068 | #define DSBCAPS_STICKYFOCUS 0x00004000 2069 | #define DSBCAPS_GLOBALFOCUS 0x00008000 2070 | #define DSBCAPS_GETCURRENTPOSITION2 0x00010000 2071 | #define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000 2072 | #define DSBCAPS_LOCDEFER 0x00040000 2073 | #if (DIRECTSOUND_VERSION >= 0x1000) 2074 | // Force GetCurrentPosition() to return a buffer's true play position; 2075 | // unmodified by aids to enhance backward compatibility. 2076 | #define DSBCAPS_TRUEPLAYPOSITION 0x00080000 2077 | #endif 2078 | 2079 | #define DSBPLAY_LOOPING 0x00000001 2080 | #define DSBPLAY_LOCHARDWARE 0x00000002 2081 | #define DSBPLAY_LOCSOFTWARE 0x00000004 2082 | #define DSBPLAY_TERMINATEBY_TIME 0x00000008 2083 | #define DSBPLAY_TERMINATEBY_DISTANCE 0x000000010 2084 | #define DSBPLAY_TERMINATEBY_PRIORITY 0x000000020 2085 | 2086 | #define DSBSTATUS_PLAYING 0x00000001 2087 | #define DSBSTATUS_BUFFERLOST 0x00000002 2088 | #define DSBSTATUS_LOOPING 0x00000004 2089 | #define DSBSTATUS_LOCHARDWARE 0x00000008 2090 | #define DSBSTATUS_LOCSOFTWARE 0x00000010 2091 | #define DSBSTATUS_TERMINATED 0x00000020 2092 | 2093 | #define DSBLOCK_FROMWRITECURSOR 0x00000001 2094 | #define DSBLOCK_ENTIREBUFFER 0x00000002 2095 | 2096 | #define DSBFREQUENCY_ORIGINAL 0 2097 | #define DSBFREQUENCY_MIN 100 2098 | #if DIRECTSOUND_VERSION >= 0x0900 2099 | #define DSBFREQUENCY_MAX 200000 2100 | #else 2101 | #define DSBFREQUENCY_MAX 100000 2102 | #endif 2103 | 2104 | #define DSBPAN_LEFT -10000 2105 | #define DSBPAN_CENTER 0 2106 | #define DSBPAN_RIGHT 10000 2107 | 2108 | #define DSBVOLUME_MIN -10000 2109 | #define DSBVOLUME_MAX 0 2110 | 2111 | #define DSBSIZE_MIN 4 2112 | #define DSBSIZE_MAX 0x0FFFFFFF 2113 | #define DSBSIZE_FX_MIN 150 // NOTE: Milliseconds, not bytes 2114 | 2115 | #define DSBNOTIFICATIONS_MAX 100000UL 2116 | 2117 | #define DS3DMODE_NORMAL 0x00000000 2118 | #define DS3DMODE_HEADRELATIVE 0x00000001 2119 | #define DS3DMODE_DISABLE 0x00000002 2120 | 2121 | #define DS3D_IMMEDIATE 0x00000000 2122 | #define DS3D_DEFERRED 0x00000001 2123 | 2124 | #define DS3D_MINDISTANCEFACTOR FLT_MIN 2125 | #define DS3D_MAXDISTANCEFACTOR FLT_MAX 2126 | #define DS3D_DEFAULTDISTANCEFACTOR 1.0f 2127 | 2128 | #define DS3D_MINROLLOFFFACTOR 0.0f 2129 | #define DS3D_MAXROLLOFFFACTOR 10.0f 2130 | #define DS3D_DEFAULTROLLOFFFACTOR 1.0f 2131 | 2132 | #define DS3D_MINDOPPLERFACTOR 0.0f 2133 | #define DS3D_MAXDOPPLERFACTOR 10.0f 2134 | #define DS3D_DEFAULTDOPPLERFACTOR 1.0f 2135 | 2136 | #define DS3D_DEFAULTMINDISTANCE 1.0f 2137 | #define DS3D_DEFAULTMAXDISTANCE 1000000000.0f 2138 | 2139 | #define DS3D_MINCONEANGLE 0 2140 | #define DS3D_MAXCONEANGLE 360 2141 | #define DS3D_DEFAULTCONEANGLE 360 2142 | 2143 | #define DS3D_DEFAULTCONEOUTSIDEVOLUME DSBVOLUME_MAX 2144 | 2145 | // IDirectSoundCapture attributes 2146 | 2147 | #define DSCCAPS_EMULDRIVER DSCAPS_EMULDRIVER 2148 | #define DSCCAPS_CERTIFIED DSCAPS_CERTIFIED 2149 | #define DSCCAPS_MULTIPLECAPTURE 0x00000001 2150 | 2151 | // IDirectSoundCaptureBuffer attributes 2152 | 2153 | #define DSCBCAPS_WAVEMAPPED 0x80000000 2154 | 2155 | #if DIRECTSOUND_VERSION >= 0x0800 2156 | #define DSCBCAPS_CTRLFX 0x00000200 2157 | #endif 2158 | 2159 | 2160 | #define DSCBLOCK_ENTIREBUFFER 0x00000001 2161 | 2162 | #define DSCBSTATUS_CAPTURING 0x00000001 2163 | #define DSCBSTATUS_LOOPING 0x00000002 2164 | 2165 | #define DSCBSTART_LOOPING 0x00000001 2166 | 2167 | #define DSBPN_OFFSETSTOP 0xFFFFFFFF 2168 | 2169 | #define DS_CERTIFIED 0x00000000 2170 | #define DS_UNCERTIFIED 0x00000001 2171 | 2172 | 2173 | // 2174 | // Flags for the I3DL2 effects 2175 | // 2176 | 2177 | // 2178 | // I3DL2 Material Presets 2179 | // 2180 | 2181 | enum 2182 | { 2183 | DSFX_I3DL2_MATERIAL_PRESET_SINGLEWINDOW, 2184 | DSFX_I3DL2_MATERIAL_PRESET_DOUBLEWINDOW, 2185 | DSFX_I3DL2_MATERIAL_PRESET_THINDOOR, 2186 | DSFX_I3DL2_MATERIAL_PRESET_THICKDOOR, 2187 | DSFX_I3DL2_MATERIAL_PRESET_WOODWALL, 2188 | DSFX_I3DL2_MATERIAL_PRESET_BRICKWALL, 2189 | DSFX_I3DL2_MATERIAL_PRESET_STONEWALL, 2190 | DSFX_I3DL2_MATERIAL_PRESET_CURTAIN 2191 | }; 2192 | 2193 | #define I3DL2_MATERIAL_PRESET_SINGLEWINDOW -2800,0.71f 2194 | #define I3DL2_MATERIAL_PRESET_DOUBLEWINDOW -5000,0.40f 2195 | #define I3DL2_MATERIAL_PRESET_THINDOOR -1800,0.66f 2196 | #define I3DL2_MATERIAL_PRESET_THICKDOOR -4400,0.64f 2197 | #define I3DL2_MATERIAL_PRESET_WOODWALL -4000,0.50f 2198 | #define I3DL2_MATERIAL_PRESET_BRICKWALL -5000,0.60f 2199 | #define I3DL2_MATERIAL_PRESET_STONEWALL -6000,0.68f 2200 | #define I3DL2_MATERIAL_PRESET_CURTAIN -1200,0.15f 2201 | 2202 | enum 2203 | { 2204 | DSFX_I3DL2_ENVIRONMENT_PRESET_DEFAULT, 2205 | DSFX_I3DL2_ENVIRONMENT_PRESET_GENERIC, 2206 | DSFX_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL, 2207 | DSFX_I3DL2_ENVIRONMENT_PRESET_ROOM, 2208 | DSFX_I3DL2_ENVIRONMENT_PRESET_BATHROOM, 2209 | DSFX_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM, 2210 | DSFX_I3DL2_ENVIRONMENT_PRESET_STONEROOM, 2211 | DSFX_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM, 2212 | DSFX_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL, 2213 | DSFX_I3DL2_ENVIRONMENT_PRESET_CAVE, 2214 | DSFX_I3DL2_ENVIRONMENT_PRESET_ARENA, 2215 | DSFX_I3DL2_ENVIRONMENT_PRESET_HANGAR, 2216 | DSFX_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY, 2217 | DSFX_I3DL2_ENVIRONMENT_PRESET_HALLWAY, 2218 | DSFX_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR, 2219 | DSFX_I3DL2_ENVIRONMENT_PRESET_ALLEY, 2220 | DSFX_I3DL2_ENVIRONMENT_PRESET_FOREST, 2221 | DSFX_I3DL2_ENVIRONMENT_PRESET_CITY, 2222 | DSFX_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS, 2223 | DSFX_I3DL2_ENVIRONMENT_PRESET_QUARRY, 2224 | DSFX_I3DL2_ENVIRONMENT_PRESET_PLAIN, 2225 | DSFX_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT, 2226 | DSFX_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE, 2227 | DSFX_I3DL2_ENVIRONMENT_PRESET_UNDERWATER, 2228 | DSFX_I3DL2_ENVIRONMENT_PRESET_SMALLROOM, 2229 | DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM, 2230 | DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEROOM, 2231 | DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL, 2232 | DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEHALL, 2233 | DSFX_I3DL2_ENVIRONMENT_PRESET_PLATE 2234 | }; 2235 | 2236 | // 2237 | // I3DL2 Reverberation Presets Values 2238 | // 2239 | 2240 | #define I3DL2_ENVIRONMENT_PRESET_DEFAULT -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f 2241 | #define I3DL2_ENVIRONMENT_PRESET_GENERIC -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f 2242 | #define I3DL2_ENVIRONMENT_PRESET_PADDEDCELL -1000,-6000, 0.0f, 0.17f, 0.10f, -1204, 0.001f, 207, 0.002f, 100.0f, 100.0f, 5000.0f 2243 | #define I3DL2_ENVIRONMENT_PRESET_ROOM -1000, -454, 0.0f, 0.40f, 0.83f, -1646, 0.002f, 53, 0.003f, 100.0f, 100.0f, 5000.0f 2244 | #define I3DL2_ENVIRONMENT_PRESET_BATHROOM -1000,-1200, 0.0f, 1.49f, 0.54f, -370, 0.007f, 1030, 0.011f, 100.0f, 60.0f, 5000.0f 2245 | #define I3DL2_ENVIRONMENT_PRESET_LIVINGROOM -1000,-6000, 0.0f, 0.50f, 0.10f, -1376, 0.003f, -1104, 0.004f, 100.0f, 100.0f, 5000.0f 2246 | #define I3DL2_ENVIRONMENT_PRESET_STONEROOM -1000, -300, 0.0f, 2.31f, 0.64f, -711, 0.012f, 83, 0.017f, 100.0f, 100.0f, 5000.0f 2247 | #define I3DL2_ENVIRONMENT_PRESET_AUDITORIUM -1000, -476, 0.0f, 4.32f, 0.59f, -789, 0.020f, -289, 0.030f, 100.0f, 100.0f, 5000.0f 2248 | #define I3DL2_ENVIRONMENT_PRESET_CONCERTHALL -1000, -500, 0.0f, 3.92f, 0.70f, -1230, 0.020f, -2, 0.029f, 100.0f, 100.0f, 5000.0f 2249 | #define I3DL2_ENVIRONMENT_PRESET_CAVE -1000, 0, 0.0f, 2.91f, 1.30f, -602, 0.015f, -302, 0.022f, 100.0f, 100.0f, 5000.0f 2250 | #define I3DL2_ENVIRONMENT_PRESET_ARENA -1000, -698, 0.0f, 7.24f, 0.33f, -1166, 0.020f, 16, 0.030f, 100.0f, 100.0f, 5000.0f 2251 | #define I3DL2_ENVIRONMENT_PRESET_HANGAR -1000,-1000, 0.0f,10.05f, 0.23f, -602, 0.020f, 198, 0.030f, 100.0f, 100.0f, 5000.0f 2252 | #define I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY -1000,-4000, 0.0f, 0.30f, 0.10f, -1831, 0.002f, -1630, 0.030f, 100.0f, 100.0f, 5000.0f 2253 | #define I3DL2_ENVIRONMENT_PRESET_HALLWAY -1000, -300, 0.0f, 1.49f, 0.59f, -1219, 0.007f, 441, 0.011f, 100.0f, 100.0f, 5000.0f 2254 | #define I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR -1000, -237, 0.0f, 2.70f, 0.79f, -1214, 0.013f, 395, 0.020f, 100.0f, 100.0f, 5000.0f 2255 | #define I3DL2_ENVIRONMENT_PRESET_ALLEY -1000, -270, 0.0f, 1.49f, 0.86f, -1204, 0.007f, -4, 0.011f, 100.0f, 100.0f, 5000.0f 2256 | #define I3DL2_ENVIRONMENT_PRESET_FOREST -1000,-3300, 0.0f, 1.49f, 0.54f, -2560, 0.162f, -613, 0.088f, 79.0f, 100.0f, 5000.0f 2257 | #define I3DL2_ENVIRONMENT_PRESET_CITY -1000, -800, 0.0f, 1.49f, 0.67f, -2273, 0.007f, -2217, 0.011f, 50.0f, 100.0f, 5000.0f 2258 | #define I3DL2_ENVIRONMENT_PRESET_MOUNTAINS -1000,-2500, 0.0f, 1.49f, 0.21f, -2780, 0.300f, -2014, 0.100f, 27.0f, 100.0f, 5000.0f 2259 | #define I3DL2_ENVIRONMENT_PRESET_QUARRY -1000,-1000, 0.0f, 1.49f, 0.83f,-10000, 0.061f, 500, 0.025f, 100.0f, 100.0f, 5000.0f 2260 | #define I3DL2_ENVIRONMENT_PRESET_PLAIN -1000,-2000, 0.0f, 1.49f, 0.50f, -2466, 0.179f, -2514, 0.100f, 21.0f, 100.0f, 5000.0f 2261 | #define I3DL2_ENVIRONMENT_PRESET_PARKINGLOT -1000, 0, 0.0f, 1.65f, 1.50f, -1363, 0.008f, -1153, 0.012f, 100.0f, 100.0f, 5000.0f 2262 | #define I3DL2_ENVIRONMENT_PRESET_SEWERPIPE -1000,-1000, 0.0f, 2.81f, 0.14f, 429, 0.014f, 648, 0.021f, 80.0f, 60.0f, 5000.0f 2263 | #define I3DL2_ENVIRONMENT_PRESET_UNDERWATER -1000,-4000, 0.0f, 1.49f, 0.10f, -449, 0.007f, 1700, 0.011f, 100.0f, 100.0f, 5000.0f 2264 | 2265 | // 2266 | // Examples simulating 'musical' reverb presets 2267 | // 2268 | // Name Decay time Description 2269 | // Small Room 1.1s A small size room with a length of 5m or so. 2270 | // Medium Room 1.3s A medium size room with a length of 10m or so. 2271 | // Large Room 1.5s A large size room suitable for live performances. 2272 | // Medium Hall 1.8s A medium size concert hall. 2273 | // Large Hall 1.8s A large size concert hall suitable for a full orchestra. 2274 | // Plate 1.3s A plate reverb simulation. 2275 | // 2276 | 2277 | #define I3DL2_ENVIRONMENT_PRESET_SMALLROOM -1000, -600, 0.0f, 1.10f, 0.83f, -400, 0.005f, 500, 0.010f, 100.0f, 100.0f, 5000.0f 2278 | #define I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM -1000, -600, 0.0f, 1.30f, 0.83f, -1000, 0.010f, -200, 0.020f, 100.0f, 100.0f, 5000.0f 2279 | #define I3DL2_ENVIRONMENT_PRESET_LARGEROOM -1000, -600, 0.0f, 1.50f, 0.83f, -1600, 0.020f, -1000, 0.040f, 100.0f, 100.0f, 5000.0f 2280 | #define I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL -1000, -600, 0.0f, 1.80f, 0.70f, -1300, 0.015f, -800, 0.030f, 100.0f, 100.0f, 5000.0f 2281 | #define I3DL2_ENVIRONMENT_PRESET_LARGEHALL -1000, -600, 0.0f, 1.80f, 0.70f, -2000, 0.030f, -1400, 0.060f, 100.0f, 100.0f, 5000.0f 2282 | #define I3DL2_ENVIRONMENT_PRESET_PLATE -1000, -200, 0.0f, 1.30f, 0.90f, 0, 0.002f, 0, 0.010f, 100.0f, 75.0f, 5000.0f 2283 | 2284 | // 2285 | // DirectSound3D Algorithms 2286 | // 2287 | 2288 | // Default DirectSound3D algorithm {00000000-0000-0000-0000-000000000000} 2289 | #define DS3DALG_DEFAULT GUID_NULL 2290 | 2291 | // No virtualization (Pan3D) {C241333F-1C1B-11d2-94F5-00C04FC28ACA} 2292 | DEFINE_GUID(DS3DALG_NO_VIRTUALIZATION, 0xc241333f, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); 2293 | 2294 | // High-quality HRTF algorithm {C2413340-1C1B-11d2-94F5-00C04FC28ACA} 2295 | DEFINE_GUID(DS3DALG_HRTF_FULL, 0xc2413340, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); 2296 | 2297 | // Lower-quality HRTF algorithm {C2413342-1C1B-11d2-94F5-00C04FC28ACA} 2298 | DEFINE_GUID(DS3DALG_HRTF_LIGHT, 0xc2413342, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); 2299 | 2300 | 2301 | #if DIRECTSOUND_VERSION >= 0x0800 2302 | 2303 | // 2304 | // DirectSound Internal Effect Algorithms 2305 | // 2306 | 2307 | 2308 | // Gargle {DAFD8210-5711-4B91-9FE3-F75B7AE279BF} 2309 | DEFINE_GUID(GUID_DSFX_STANDARD_GARGLE, 0xdafd8210, 0x5711, 0x4b91, 0x9f, 0xe3, 0xf7, 0x5b, 0x7a, 0xe2, 0x79, 0xbf); 2310 | 2311 | // Chorus {EFE6629C-81F7-4281-BD91-C9D604A95AF6} 2312 | DEFINE_GUID(GUID_DSFX_STANDARD_CHORUS, 0xefe6629c, 0x81f7, 0x4281, 0xbd, 0x91, 0xc9, 0xd6, 0x04, 0xa9, 0x5a, 0xf6); 2313 | 2314 | // Flanger {EFCA3D92-DFD8-4672-A603-7420894BAD98} 2315 | DEFINE_GUID(GUID_DSFX_STANDARD_FLANGER, 0xefca3d92, 0xdfd8, 0x4672, 0xa6, 0x03, 0x74, 0x20, 0x89, 0x4b, 0xad, 0x98); 2316 | 2317 | // Echo/Delay {EF3E932C-D40B-4F51-8CCF-3F98F1B29D5D} 2318 | DEFINE_GUID(GUID_DSFX_STANDARD_ECHO, 0xef3e932c, 0xd40b, 0x4f51, 0x8c, 0xcf, 0x3f, 0x98, 0xf1, 0xb2, 0x9d, 0x5d); 2319 | 2320 | // Distortion {EF114C90-CD1D-484E-96E5-09CFAF912A21} 2321 | DEFINE_GUID(GUID_DSFX_STANDARD_DISTORTION, 0xef114c90, 0xcd1d, 0x484e, 0x96, 0xe5, 0x09, 0xcf, 0xaf, 0x91, 0x2a, 0x21); 2322 | 2323 | // Compressor/Limiter {EF011F79-4000-406D-87AF-BFFB3FC39D57} 2324 | DEFINE_GUID(GUID_DSFX_STANDARD_COMPRESSOR, 0xef011f79, 0x4000, 0x406d, 0x87, 0xaf, 0xbf, 0xfb, 0x3f, 0xc3, 0x9d, 0x57); 2325 | 2326 | // Parametric Equalization {120CED89-3BF4-4173-A132-3CB406CF3231} 2327 | DEFINE_GUID(GUID_DSFX_STANDARD_PARAMEQ, 0x120ced89, 0x3bf4, 0x4173, 0xa1, 0x32, 0x3c, 0xb4, 0x06, 0xcf, 0x32, 0x31); 2328 | 2329 | // I3DL2 Environmental Reverberation: Reverb (Listener) Effect {EF985E71-D5C7-42D4-BA4D-2D073E2E96F4} 2330 | DEFINE_GUID(GUID_DSFX_STANDARD_I3DL2REVERB, 0xef985e71, 0xd5c7, 0x42d4, 0xba, 0x4d, 0x2d, 0x07, 0x3e, 0x2e, 0x96, 0xf4); 2331 | 2332 | // Waves Reverberation {87FC0268-9A55-4360-95AA-004A1D9DE26C} 2333 | DEFINE_GUID(GUID_DSFX_WAVES_REVERB, 0x87fc0268, 0x9a55, 0x4360, 0x95, 0xaa, 0x00, 0x4a, 0x1d, 0x9d, 0xe2, 0x6c); 2334 | 2335 | // 2336 | // DirectSound Capture Effect Algorithms 2337 | // 2338 | 2339 | 2340 | // Acoustic Echo Canceller {BF963D80-C559-11D0-8A2B-00A0C9255AC1} 2341 | // Matches KSNODETYPE_ACOUSTIC_ECHO_CANCEL in ksmedia.h 2342 | DEFINE_GUID(GUID_DSCFX_CLASS_AEC, 0xBF963D80L, 0xC559, 0x11D0, 0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1); 2343 | 2344 | // Microsoft AEC {CDEBB919-379A-488a-8765-F53CFD36DE40} 2345 | DEFINE_GUID(GUID_DSCFX_MS_AEC, 0xcdebb919, 0x379a, 0x488a, 0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40); 2346 | 2347 | // System AEC {1C22C56D-9879-4f5b-A389-27996DDC2810} 2348 | DEFINE_GUID(GUID_DSCFX_SYSTEM_AEC, 0x1c22c56d, 0x9879, 0x4f5b, 0xa3, 0x89, 0x27, 0x99, 0x6d, 0xdc, 0x28, 0x10); 2349 | 2350 | // Noise Supression {E07F903F-62FD-4e60-8CDD-DEA7236665B5} 2351 | // Matches KSNODETYPE_NOISE_SUPPRESS in post Windows ME DDK's ksmedia.h 2352 | DEFINE_GUID(GUID_DSCFX_CLASS_NS, 0xe07f903f, 0x62fd, 0x4e60, 0x8c, 0xdd, 0xde, 0xa7, 0x23, 0x66, 0x65, 0xb5); 2353 | 2354 | // Microsoft Noise Suppresion {11C5C73B-66E9-4ba1-A0BA-E814C6EED92D} 2355 | DEFINE_GUID(GUID_DSCFX_MS_NS, 0x11c5c73b, 0x66e9, 0x4ba1, 0xa0, 0xba, 0xe8, 0x14, 0xc6, 0xee, 0xd9, 0x2d); 2356 | 2357 | // System Noise Suppresion {5AB0882E-7274-4516-877D-4EEE99BA4FD0} 2358 | DEFINE_GUID(GUID_DSCFX_SYSTEM_NS, 0x5ab0882e, 0x7274, 0x4516, 0x87, 0x7d, 0x4e, 0xee, 0x99, 0xba, 0x4f, 0xd0); 2359 | 2360 | #endif // DIRECTSOUND_VERSION >= 0x0800 2361 | 2362 | #endif // __DSOUND_INCLUDED__ 2363 | 2364 | 2365 | 2366 | #ifdef __cplusplus 2367 | }; 2368 | #endif // __cplusplus 2369 | 2370 | -------------------------------------------------------------------------------- /include/speex/speex_echo.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) Jean-Marc Valin */ 2 | /** 3 | @file speex_echo.h 4 | @brief Echo cancellation 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | 3. The name of the author may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef SPEEX_ECHO_H 35 | #define SPEEX_ECHO_H 36 | /** @defgroup SpeexEchoState SpeexEchoState: Acoustic echo canceller 37 | * This is the acoustic echo canceller module. 38 | * @{ 39 | */ 40 | #include "speexdsp_types.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** Obtain frame size used by the AEC */ 47 | #define SPEEX_ECHO_GET_FRAME_SIZE 3 48 | 49 | /** Set sampling rate */ 50 | #define SPEEX_ECHO_SET_SAMPLING_RATE 24 51 | /** Get sampling rate */ 52 | #define SPEEX_ECHO_GET_SAMPLING_RATE 25 53 | 54 | /* Can't set window sizes */ 55 | /** Get size of impulse response (int32) */ 56 | #define SPEEX_ECHO_GET_IMPULSE_RESPONSE_SIZE 27 57 | 58 | /* Can't set window content */ 59 | /** Get impulse response (int32[]) */ 60 | #define SPEEX_ECHO_GET_IMPULSE_RESPONSE 29 61 | 62 | /** Internal echo canceller state. Should never be accessed directly. */ 63 | struct SpeexEchoState_; 64 | 65 | /** @class SpeexEchoState 66 | * This holds the state of the echo canceller. You need one per channel. 67 | */ 68 | 69 | /** Internal echo canceller state. Should never be accessed directly. */ 70 | typedef struct SpeexEchoState_ SpeexEchoState; 71 | 72 | /** Creates a new echo canceller state 73 | * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms) 74 | * @param filter_length Number of samples of echo to cancel (should generally correspond to 100-500 ms) 75 | * @return Newly-created echo canceller state 76 | */ 77 | SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length); 78 | 79 | /** Creates a new multi-channel echo canceller state 80 | * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms) 81 | * @param filter_length Number of samples of echo to cancel (should generally correspond to 100-500 ms) 82 | * @param nb_mic Number of microphone channels 83 | * @param nb_speakers Number of speaker channels 84 | * @return Newly-created echo canceller state 85 | */ 86 | SpeexEchoState *speex_echo_state_init_mc(int frame_size, int filter_length, int nb_mic, int nb_speakers); 87 | 88 | /** Destroys an echo canceller state 89 | * @param st Echo canceller state 90 | */ 91 | void speex_echo_state_destroy(SpeexEchoState *st); 92 | 93 | /** Performs echo cancellation a frame, based on the audio sent to the speaker (no delay is added 94 | * to playback in this form) 95 | * 96 | * @param st Echo canceller state 97 | * @param rec Signal from the microphone (near end + far end echo) 98 | * @param play Signal played to the speaker (received from far end) 99 | * @param out Returns near-end signal with echo removed 100 | */ 101 | void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out); 102 | 103 | /** Performs echo cancellation a frame (deprecated) */ 104 | void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out, spx_int32_t *Yout); 105 | 106 | /** Perform echo cancellation using internal playback buffer, which is delayed by two frames 107 | * to account for the delay introduced by most soundcards (but it could be off!) 108 | * @param st Echo canceller state 109 | * @param rec Signal from the microphone (near end + far end echo) 110 | * @param out Returns near-end signal with echo removed 111 | */ 112 | void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out); 113 | 114 | /** Let the echo canceller know that a frame was just queued to the soundcard 115 | * @param st Echo canceller state 116 | * @param play Signal played to the speaker (received from far end) 117 | */ 118 | void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play); 119 | 120 | /** Reset the echo canceller to its original state 121 | * @param st Echo canceller state 122 | */ 123 | void speex_echo_state_reset(SpeexEchoState *st); 124 | 125 | /** Used like the ioctl function to control the echo canceller parameters 126 | * 127 | * @param st Echo canceller state 128 | * @param request ioctl-type request (one of the SPEEX_ECHO_* macros) 129 | * @param ptr Data exchanged to-from function 130 | * @return 0 if no error, -1 if request in unknown 131 | */ 132 | int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr); 133 | 134 | 135 | 136 | struct SpeexDecorrState_; 137 | 138 | typedef struct SpeexDecorrState_ SpeexDecorrState; 139 | 140 | 141 | /** Create a state for the channel decorrelation algorithm 142 | This is useful for multi-channel echo cancellation only 143 | * @param rate Sampling rate 144 | * @param channels Number of channels (it's a bit pointless if you don't have at least 2) 145 | * @param frame_size Size of the frame to process at ones (counting samples *per* channel) 146 | */ 147 | SpeexDecorrState *speex_decorrelate_new(int rate, int channels, int frame_size); 148 | 149 | /** Remove correlation between the channels by modifying the phase and possibly 150 | adding noise in a way that is not (or little) perceptible. 151 | * @param st Decorrelator state 152 | * @param in Input audio in interleaved format 153 | * @param out Result of the decorrelation (out *may* alias in) 154 | * @param strength How much alteration of the audio to apply from 0 to 100. 155 | */ 156 | void speex_decorrelate(SpeexDecorrState *st, const spx_int16_t *in, spx_int16_t *out, int strength); 157 | 158 | /** Destroy a Decorrelation state 159 | * @param st State to destroy 160 | */ 161 | void speex_decorrelate_destroy(SpeexDecorrState *st); 162 | 163 | 164 | #ifdef __cplusplus 165 | } 166 | #endif 167 | 168 | 169 | /** @}*/ 170 | #endif 171 | -------------------------------------------------------------------------------- /include/speex/speex_jitter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file speex_jitter.h 4 | @brief Adaptive jitter buffer for Speex 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | */ 35 | 36 | #ifndef SPEEX_JITTER_H 37 | #define SPEEX_JITTER_H 38 | /** @defgroup JitterBuffer JitterBuffer: Adaptive jitter buffer 39 | * This is the jitter buffer that reorders UDP/RTP packets and adjusts the buffer size 40 | * to maintain good quality and low latency. 41 | * @{ 42 | */ 43 | 44 | #include "speexdsp_types.h" 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | /** Generic adaptive jitter buffer state */ 51 | struct JitterBuffer_; 52 | 53 | /** Generic adaptive jitter buffer state */ 54 | typedef struct JitterBuffer_ JitterBuffer; 55 | 56 | /** Definition of an incoming packet */ 57 | typedef struct _JitterBufferPacket JitterBufferPacket; 58 | 59 | /** Definition of an incoming packet */ 60 | struct _JitterBufferPacket { 61 | char *data; /**< Data bytes contained in the packet */ 62 | spx_uint32_t len; /**< Length of the packet in bytes */ 63 | spx_uint32_t timestamp; /**< Timestamp for the packet */ 64 | spx_uint32_t span; /**< Time covered by the packet (same units as timestamp) */ 65 | spx_uint16_t sequence; /**< RTP Sequence number if available (0 otherwise) */ 66 | spx_uint32_t user_data; /**< Put whatever data you like here (it's ignored by the jitter buffer) */ 67 | }; 68 | 69 | /** Packet has been retrieved */ 70 | #define JITTER_BUFFER_OK 0 71 | /** Packet is lost or is late */ 72 | #define JITTER_BUFFER_MISSING 1 73 | /** A "fake" packet is meant to be inserted here to increase buffering */ 74 | #define JITTER_BUFFER_INSERTION 2 75 | /** There was an error in the jitter buffer */ 76 | #define JITTER_BUFFER_INTERNAL_ERROR -1 77 | /** Invalid argument */ 78 | #define JITTER_BUFFER_BAD_ARGUMENT -2 79 | 80 | 81 | /** Set minimum amount of extra buffering required (margin) */ 82 | #define JITTER_BUFFER_SET_MARGIN 0 83 | /** Get minimum amount of extra buffering required (margin) */ 84 | #define JITTER_BUFFER_GET_MARGIN 1 85 | /* JITTER_BUFFER_SET_AVAILABLE_COUNT wouldn't make sense */ 86 | 87 | /** Get the amount of available packets currently buffered */ 88 | #define JITTER_BUFFER_GET_AVAILABLE_COUNT 3 89 | /** Included because of an early misspelling (will remove in next release) */ 90 | #define JITTER_BUFFER_GET_AVALIABLE_COUNT 3 91 | 92 | /** Assign a function to destroy unused packet. When setting that, the jitter 93 | buffer no longer copies packet data. */ 94 | #define JITTER_BUFFER_SET_DESTROY_CALLBACK 4 95 | /** */ 96 | #define JITTER_BUFFER_GET_DESTROY_CALLBACK 5 97 | 98 | /** Tell the jitter buffer to only adjust the delay in multiples of the step parameter provided */ 99 | #define JITTER_BUFFER_SET_DELAY_STEP 6 100 | /** */ 101 | #define JITTER_BUFFER_GET_DELAY_STEP 7 102 | 103 | /** Tell the jitter buffer to only do concealment in multiples of the size parameter provided */ 104 | #define JITTER_BUFFER_SET_CONCEALMENT_SIZE 8 105 | #define JITTER_BUFFER_GET_CONCEALMENT_SIZE 9 106 | 107 | /** Absolute max amount of loss that can be tolerated regardless of the delay. Typical loss 108 | should be half of that or less. */ 109 | #define JITTER_BUFFER_SET_MAX_LATE_RATE 10 110 | #define JITTER_BUFFER_GET_MAX_LATE_RATE 11 111 | 112 | /** Equivalent cost of one percent late packet in timestamp units */ 113 | #define JITTER_BUFFER_SET_LATE_COST 12 114 | #define JITTER_BUFFER_GET_LATE_COST 13 115 | 116 | 117 | /** Initialises jitter buffer 118 | * 119 | * @param step_size Starting value for the size of concleanment packets and delay 120 | adjustment steps. Can be changed at any time using JITTER_BUFFER_SET_DELAY_STEP 121 | and JITTER_BUFFER_GET_CONCEALMENT_SIZE. 122 | * @return Newly created jitter buffer state 123 | */ 124 | JitterBuffer *jitter_buffer_init(int step_size); 125 | 126 | /** Restores jitter buffer to its original state 127 | * 128 | * @param jitter Jitter buffer state 129 | */ 130 | void jitter_buffer_reset(JitterBuffer *jitter); 131 | 132 | /** Destroys jitter buffer 133 | * 134 | * @param jitter Jitter buffer state 135 | */ 136 | void jitter_buffer_destroy(JitterBuffer *jitter); 137 | 138 | /** Put one packet into the jitter buffer 139 | * 140 | * @param jitter Jitter buffer state 141 | * @param packet Incoming packet 142 | */ 143 | void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet); 144 | 145 | /** Get one packet from the jitter buffer 146 | * 147 | * @param jitter Jitter buffer state 148 | * @param packet Returned packet 149 | * @param desired_span Number of samples (or units) we wish to get from the buffer (no guarantee) 150 | * @param current_timestamp Timestamp for the returned packet 151 | */ 152 | int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t desired_span, spx_int32_t *start_offset); 153 | 154 | /** Used right after jitter_buffer_get() to obtain another packet that would have the same timestamp. 155 | * This is mainly useful for media where a single "frame" can be split into several packets. 156 | * 157 | * @param jitter Jitter buffer state 158 | * @param packet Returned packet 159 | */ 160 | int jitter_buffer_get_another(JitterBuffer *jitter, JitterBufferPacket *packet); 161 | 162 | /** Get pointer timestamp of jitter buffer 163 | * 164 | * @param jitter Jitter buffer state 165 | */ 166 | int jitter_buffer_get_pointer_timestamp(JitterBuffer *jitter); 167 | 168 | /** Advance by one tick 169 | * 170 | * @param jitter Jitter buffer state 171 | */ 172 | void jitter_buffer_tick(JitterBuffer *jitter); 173 | 174 | /** Telling the jitter buffer about the remaining data in the application buffer 175 | * @param jitter Jitter buffer state 176 | * @param rem Amount of data buffered by the application (timestamp units) 177 | */ 178 | void jitter_buffer_remaining_span(JitterBuffer *jitter, spx_uint32_t rem); 179 | 180 | /** Used like the ioctl function to control the jitter buffer parameters 181 | * 182 | * @param jitter Jitter buffer state 183 | * @param request ioctl-type request (one of the JITTER_BUFFER_* macros) 184 | * @param ptr Data exchanged to-from function 185 | * @return 0 if no error, -1 if request in unknown 186 | */ 187 | int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr); 188 | 189 | int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset); 190 | 191 | /* @} */ 192 | 193 | #ifdef __cplusplus 194 | } 195 | #endif 196 | 197 | #endif 198 | -------------------------------------------------------------------------------- /include/speex/speex_preprocess.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2003 Epic Games 2 | Written by Jean-Marc Valin */ 3 | /** 4 | * @file speex_preprocess.h 5 | * @brief Speex preprocessor. The preprocess can do noise suppression, 6 | * residual echo suppression (after using the echo canceller), automatic 7 | * gain control (AGC) and voice activity detection (VAD). 8 | */ 9 | /* 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are 12 | met: 13 | 14 | 1. Redistributions of source code must retain the above copyright notice, 15 | this list of conditions and the following disclaimer. 16 | 17 | 2. Redistributions in binary form must reproduce the above copyright 18 | notice, this list of conditions and the following disclaimer in the 19 | documentation and/or other materials provided with the distribution. 20 | 21 | 3. The name of the author may not be used to endorse or promote products 22 | derived from this software without specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 25 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 26 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #ifndef SPEEX_PREPROCESS_H 38 | #define SPEEX_PREPROCESS_H 39 | /** @defgroup SpeexPreprocessState SpeexPreprocessState: The Speex preprocessor 40 | * This is the Speex preprocessor. The preprocess can do noise suppression, 41 | * residual echo suppression (after using the echo canceller), automatic 42 | * gain control (AGC) and voice activity detection (VAD). 43 | * @{ 44 | */ 45 | 46 | #include "speexdsp_types.h" 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | /** State of the preprocessor (one per channel). Should never be accessed directly. */ 53 | struct SpeexPreprocessState_; 54 | 55 | /** State of the preprocessor (one per channel). Should never be accessed directly. */ 56 | typedef struct SpeexPreprocessState_ SpeexPreprocessState; 57 | 58 | 59 | /** Creates a new preprocessing state. You MUST create one state per channel processed. 60 | * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms). Must be 61 | * the same value as that used for the echo canceller for residual echo cancellation to work. 62 | * @param sampling_rate Sampling rate used for the input. 63 | * @return Newly created preprocessor state 64 | */ 65 | SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate); 66 | 67 | /** Destroys a preprocessor state 68 | * @param st Preprocessor state to destroy 69 | */ 70 | void speex_preprocess_state_destroy(SpeexPreprocessState *st); 71 | 72 | /** Preprocess a frame 73 | * @param st Preprocessor state 74 | * @param x Audio sample vector (in and out). Must be same size as specified in speex_preprocess_state_init(). 75 | * @return Bool value for voice activity (1 for speech, 0 for noise/silence), ONLY if VAD turned on. 76 | */ 77 | int speex_preprocess_run(SpeexPreprocessState *st, spx_int16_t *x); 78 | 79 | /** Preprocess a frame (deprecated, use speex_preprocess_run() instead)*/ 80 | int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo); 81 | 82 | /** Update preprocessor state, but do not compute the output 83 | * @param st Preprocessor state 84 | * @param x Audio sample vector (in only). Must be same size as specified in speex_preprocess_state_init(). 85 | */ 86 | void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x); 87 | 88 | /** Used like the ioctl function to control the preprocessor parameters 89 | * @param st Preprocessor state 90 | * @param request ioctl-type request (one of the SPEEX_PREPROCESS_* macros) 91 | * @param ptr Data exchanged to-from function 92 | * @return 0 if no error, -1 if request in unknown 93 | */ 94 | int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr); 95 | 96 | 97 | 98 | /** Set preprocessor denoiser state */ 99 | #define SPEEX_PREPROCESS_SET_DENOISE 0 100 | /** Get preprocessor denoiser state */ 101 | #define SPEEX_PREPROCESS_GET_DENOISE 1 102 | 103 | /** Set preprocessor Automatic Gain Control state */ 104 | #define SPEEX_PREPROCESS_SET_AGC 2 105 | /** Get preprocessor Automatic Gain Control state */ 106 | #define SPEEX_PREPROCESS_GET_AGC 3 107 | 108 | /** Set preprocessor Voice Activity Detection state */ 109 | #define SPEEX_PREPROCESS_SET_VAD 4 110 | /** Get preprocessor Voice Activity Detection state */ 111 | #define SPEEX_PREPROCESS_GET_VAD 5 112 | 113 | /** Set preprocessor Automatic Gain Control level (float) */ 114 | #define SPEEX_PREPROCESS_SET_AGC_LEVEL 6 115 | /** Get preprocessor Automatic Gain Control level (float) */ 116 | #define SPEEX_PREPROCESS_GET_AGC_LEVEL 7 117 | 118 | /** Set preprocessor dereverb state */ 119 | #define SPEEX_PREPROCESS_SET_DEREVERB 8 120 | /** Get preprocessor dereverb state */ 121 | #define SPEEX_PREPROCESS_GET_DEREVERB 9 122 | 123 | /** Set preprocessor dereverb level */ 124 | #define SPEEX_PREPROCESS_SET_DEREVERB_LEVEL 10 125 | /** Get preprocessor dereverb level */ 126 | #define SPEEX_PREPROCESS_GET_DEREVERB_LEVEL 11 127 | 128 | /** Set preprocessor dereverb decay */ 129 | #define SPEEX_PREPROCESS_SET_DEREVERB_DECAY 12 130 | /** Get preprocessor dereverb decay */ 131 | #define SPEEX_PREPROCESS_GET_DEREVERB_DECAY 13 132 | 133 | /** Set probability required for the VAD to go from silence to voice */ 134 | #define SPEEX_PREPROCESS_SET_PROB_START 14 135 | /** Get probability required for the VAD to go from silence to voice */ 136 | #define SPEEX_PREPROCESS_GET_PROB_START 15 137 | 138 | /** Set probability required for the VAD to stay in the voice state (integer percent) */ 139 | #define SPEEX_PREPROCESS_SET_PROB_CONTINUE 16 140 | /** Get probability required for the VAD to stay in the voice state (integer percent) */ 141 | #define SPEEX_PREPROCESS_GET_PROB_CONTINUE 17 142 | 143 | /** Set maximum attenuation of the noise in dB (negative number) */ 144 | #define SPEEX_PREPROCESS_SET_NOISE_SUPPRESS 18 145 | /** Get maximum attenuation of the noise in dB (negative number) */ 146 | #define SPEEX_PREPROCESS_GET_NOISE_SUPPRESS 19 147 | 148 | /** Set maximum attenuation of the residual echo in dB (negative number) */ 149 | #define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS 20 150 | /** Get maximum attenuation of the residual echo in dB (negative number) */ 151 | #define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS 21 152 | 153 | /** Set maximum attenuation of the residual echo in dB when near end is active (negative number) */ 154 | #define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE 22 155 | /** Get maximum attenuation of the residual echo in dB when near end is active (negative number) */ 156 | #define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE 23 157 | 158 | /** Set the corresponding echo canceller state so that residual echo suppression can be performed (NULL for no residual echo suppression) */ 159 | #define SPEEX_PREPROCESS_SET_ECHO_STATE 24 160 | /** Get the corresponding echo canceller state */ 161 | #define SPEEX_PREPROCESS_GET_ECHO_STATE 25 162 | 163 | /** Set maximal gain increase in dB/second (int32) */ 164 | #define SPEEX_PREPROCESS_SET_AGC_INCREMENT 26 165 | 166 | /** Get maximal gain increase in dB/second (int32) */ 167 | #define SPEEX_PREPROCESS_GET_AGC_INCREMENT 27 168 | 169 | /** Set maximal gain decrease in dB/second (int32) */ 170 | #define SPEEX_PREPROCESS_SET_AGC_DECREMENT 28 171 | 172 | /** Get maximal gain decrease in dB/second (int32) */ 173 | #define SPEEX_PREPROCESS_GET_AGC_DECREMENT 29 174 | 175 | /** Set maximal gain in dB (int32) */ 176 | #define SPEEX_PREPROCESS_SET_AGC_MAX_GAIN 30 177 | 178 | /** Get maximal gain in dB (int32) */ 179 | #define SPEEX_PREPROCESS_GET_AGC_MAX_GAIN 31 180 | 181 | /* Can't set loudness */ 182 | /** Get loudness */ 183 | #define SPEEX_PREPROCESS_GET_AGC_LOUDNESS 33 184 | 185 | /* Can't set gain */ 186 | /** Get current gain (int32 percent) */ 187 | #define SPEEX_PREPROCESS_GET_AGC_GAIN 35 188 | 189 | /* Can't set spectrum size */ 190 | /** Get spectrum size for power spectrum (int32) */ 191 | #define SPEEX_PREPROCESS_GET_PSD_SIZE 37 192 | 193 | /* Can't set power spectrum */ 194 | /** Get power spectrum (int32[] of squared values) */ 195 | #define SPEEX_PREPROCESS_GET_PSD 39 196 | 197 | /* Can't set noise size */ 198 | /** Get spectrum size for noise estimate (int32) */ 199 | #define SPEEX_PREPROCESS_GET_NOISE_PSD_SIZE 41 200 | 201 | /* Can't set noise estimate */ 202 | /** Get noise estimate (int32[] of squared values) */ 203 | #define SPEEX_PREPROCESS_GET_NOISE_PSD 43 204 | 205 | /* Can't set speech probability */ 206 | /** Get speech probability in last frame (int32). */ 207 | #define SPEEX_PREPROCESS_GET_PROB 45 208 | 209 | /** Set preprocessor Automatic Gain Control level (int32) */ 210 | #define SPEEX_PREPROCESS_SET_AGC_TARGET 46 211 | /** Get preprocessor Automatic Gain Control level (int32) */ 212 | #define SPEEX_PREPROCESS_GET_AGC_TARGET 47 213 | 214 | #ifdef __cplusplus 215 | } 216 | #endif 217 | 218 | /** @}*/ 219 | #endif 220 | -------------------------------------------------------------------------------- /include/speex/speex_resampler.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Jean-Marc Valin 2 | 3 | File: speex_resampler.h 4 | Resampling code 5 | 6 | The design goals of this code are: 7 | - Very fast algorithm 8 | - Low memory requirement 9 | - Good *perceptual* quality (and not best SNR) 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are 13 | met: 14 | 15 | 1. Redistributions of source code must retain the above copyright notice, 16 | this list of conditions and the following disclaimer. 17 | 18 | 2. Redistributions in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | 22 | 3. The name of the author may not be used to endorse or promote products 23 | derived from this software without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 26 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 29 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 30 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 33 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | 39 | #ifndef SPEEX_RESAMPLER_H 40 | #define SPEEX_RESAMPLER_H 41 | 42 | #ifdef OUTSIDE_SPEEX 43 | 44 | /********* WARNING: MENTAL SANITY ENDS HERE *************/ 45 | 46 | /* If the resampler is defined outside of Speex, we change the symbol names so that 47 | there won't be any clash if linking with Speex later on. */ 48 | 49 | /* #define RANDOM_PREFIX your software name here */ 50 | #ifndef RANDOM_PREFIX 51 | #error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes" 52 | #endif 53 | 54 | #define CAT_PREFIX2(a,b) a ## b 55 | #define CAT_PREFIX(a,b) CAT_PREFIX2(a, b) 56 | 57 | #define speex_resampler_init CAT_PREFIX(RANDOM_PREFIX,_resampler_init) 58 | #define speex_resampler_init_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_init_frac) 59 | #define speex_resampler_destroy CAT_PREFIX(RANDOM_PREFIX,_resampler_destroy) 60 | #define speex_resampler_process_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_float) 61 | #define speex_resampler_process_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_int) 62 | #define speex_resampler_process_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_float) 63 | #define speex_resampler_process_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_int) 64 | #define speex_resampler_set_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate) 65 | #define speex_resampler_get_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_get_rate) 66 | #define speex_resampler_set_rate_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate_frac) 67 | #define speex_resampler_get_ratio CAT_PREFIX(RANDOM_PREFIX,_resampler_get_ratio) 68 | #define speex_resampler_set_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_set_quality) 69 | #define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality) 70 | #define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride) 71 | #define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride) 72 | #define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride) 73 | #define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride) 74 | #define speex_resampler_get_input_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_latency) 75 | #define speex_resampler_get_output_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_latency) 76 | #define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros) 77 | #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem) 78 | #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror) 79 | 80 | #define spx_int16_t short 81 | #define spx_int32_t int 82 | #define spx_uint16_t unsigned short 83 | #define spx_uint32_t unsigned int 84 | 85 | #else /* OUTSIDE_SPEEX */ 86 | 87 | #include "speexdsp_types.h" 88 | 89 | #endif /* OUTSIDE_SPEEX */ 90 | 91 | #ifdef __cplusplus 92 | extern "C" { 93 | #endif 94 | 95 | #define SPEEX_RESAMPLER_QUALITY_MAX 10 96 | #define SPEEX_RESAMPLER_QUALITY_MIN 0 97 | #define SPEEX_RESAMPLER_QUALITY_DEFAULT 4 98 | #define SPEEX_RESAMPLER_QUALITY_VOIP 3 99 | #define SPEEX_RESAMPLER_QUALITY_DESKTOP 5 100 | 101 | enum { 102 | RESAMPLER_ERR_SUCCESS = 0, 103 | RESAMPLER_ERR_ALLOC_FAILED = 1, 104 | RESAMPLER_ERR_BAD_STATE = 2, 105 | RESAMPLER_ERR_INVALID_ARG = 3, 106 | RESAMPLER_ERR_PTR_OVERLAP = 4, 107 | 108 | RESAMPLER_ERR_MAX_ERROR 109 | }; 110 | 111 | struct SpeexResamplerState_; 112 | typedef struct SpeexResamplerState_ SpeexResamplerState; 113 | 114 | /** Create a new resampler with integer input and output rates. 115 | * @param nb_channels Number of channels to be processed 116 | * @param in_rate Input sampling rate (integer number of Hz). 117 | * @param out_rate Output sampling rate (integer number of Hz). 118 | * @param quality Resampling quality between 0 and 10, where 0 has poor quality 119 | * and 10 has very high quality. 120 | * @return Newly created resampler state 121 | * @retval NULL Error: not enough memory 122 | */ 123 | SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, 124 | spx_uint32_t in_rate, 125 | spx_uint32_t out_rate, 126 | int quality, 127 | int *err); 128 | 129 | /** Create a new resampler with fractional input/output rates. The sampling 130 | * rate ratio is an arbitrary rational number with both the numerator and 131 | * denominator being 32-bit integers. 132 | * @param nb_channels Number of channels to be processed 133 | * @param ratio_num Numerator of the sampling rate ratio 134 | * @param ratio_den Denominator of the sampling rate ratio 135 | * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). 136 | * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). 137 | * @param quality Resampling quality between 0 and 10, where 0 has poor quality 138 | * and 10 has very high quality. 139 | * @return Newly created resampler state 140 | * @retval NULL Error: not enough memory 141 | */ 142 | SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels, 143 | spx_uint32_t ratio_num, 144 | spx_uint32_t ratio_den, 145 | spx_uint32_t in_rate, 146 | spx_uint32_t out_rate, 147 | int quality, 148 | int *err); 149 | 150 | /** Destroy a resampler state. 151 | * @param st Resampler state 152 | */ 153 | void speex_resampler_destroy(SpeexResamplerState *st); 154 | 155 | /** Resample a float array. The input and output buffers must *not* overlap. 156 | * @param st Resampler state 157 | * @param channel_index Index of the channel to process for the multi-channel 158 | * base (0 otherwise) 159 | * @param in Input buffer 160 | * @param in_len Number of input samples in the input buffer. Returns the 161 | * number of samples processed 162 | * @param out Output buffer 163 | * @param out_len Size of the output buffer. Returns the number of samples written 164 | */ 165 | int speex_resampler_process_float(SpeexResamplerState *st, 166 | spx_uint32_t channel_index, 167 | const float *in, 168 | spx_uint32_t *in_len, 169 | float *out, 170 | spx_uint32_t *out_len); 171 | 172 | /** Resample an int array. The input and output buffers must *not* overlap. 173 | * @param st Resampler state 174 | * @param channel_index Index of the channel to process for the multi-channel 175 | * base (0 otherwise) 176 | * @param in Input buffer 177 | * @param in_len Number of input samples in the input buffer. Returns the number 178 | * of samples processed 179 | * @param out Output buffer 180 | * @param out_len Size of the output buffer. Returns the number of samples written 181 | */ 182 | int speex_resampler_process_int(SpeexResamplerState *st, 183 | spx_uint32_t channel_index, 184 | const spx_int16_t *in, 185 | spx_uint32_t *in_len, 186 | spx_int16_t *out, 187 | spx_uint32_t *out_len); 188 | 189 | /** Resample an interleaved float array. The input and output buffers must *not* overlap. 190 | * @param st Resampler state 191 | * @param in Input buffer 192 | * @param in_len Number of input samples in the input buffer. Returns the number 193 | * of samples processed. This is all per-channel. 194 | * @param out Output buffer 195 | * @param out_len Size of the output buffer. Returns the number of samples written. 196 | * This is all per-channel. 197 | */ 198 | int speex_resampler_process_interleaved_float(SpeexResamplerState *st, 199 | const float *in, 200 | spx_uint32_t *in_len, 201 | float *out, 202 | spx_uint32_t *out_len); 203 | 204 | /** Resample an interleaved int array. The input and output buffers must *not* overlap. 205 | * @param st Resampler state 206 | * @param in Input buffer 207 | * @param in_len Number of input samples in the input buffer. Returns the number 208 | * of samples processed. This is all per-channel. 209 | * @param out Output buffer 210 | * @param out_len Size of the output buffer. Returns the number of samples written. 211 | * This is all per-channel. 212 | */ 213 | int speex_resampler_process_interleaved_int(SpeexResamplerState *st, 214 | const spx_int16_t *in, 215 | spx_uint32_t *in_len, 216 | spx_int16_t *out, 217 | spx_uint32_t *out_len); 218 | 219 | /** Set (change) the input/output sampling rates (integer value). 220 | * @param st Resampler state 221 | * @param in_rate Input sampling rate (integer number of Hz). 222 | * @param out_rate Output sampling rate (integer number of Hz). 223 | */ 224 | int speex_resampler_set_rate(SpeexResamplerState *st, 225 | spx_uint32_t in_rate, 226 | spx_uint32_t out_rate); 227 | 228 | /** Get the current input/output sampling rates (integer value). 229 | * @param st Resampler state 230 | * @param in_rate Input sampling rate (integer number of Hz) copied. 231 | * @param out_rate Output sampling rate (integer number of Hz) copied. 232 | */ 233 | void speex_resampler_get_rate(SpeexResamplerState *st, 234 | spx_uint32_t *in_rate, 235 | spx_uint32_t *out_rate); 236 | 237 | /** Set (change) the input/output sampling rates and resampling ratio 238 | * (fractional values in Hz supported). 239 | * @param st Resampler state 240 | * @param ratio_num Numerator of the sampling rate ratio 241 | * @param ratio_den Denominator of the sampling rate ratio 242 | * @param in_rate Input sampling rate rounded to the nearest integer (in Hz). 243 | * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). 244 | */ 245 | int speex_resampler_set_rate_frac(SpeexResamplerState *st, 246 | spx_uint32_t ratio_num, 247 | spx_uint32_t ratio_den, 248 | spx_uint32_t in_rate, 249 | spx_uint32_t out_rate); 250 | 251 | /** Get the current resampling ratio. This will be reduced to the least 252 | * common denominator. 253 | * @param st Resampler state 254 | * @param ratio_num Numerator of the sampling rate ratio copied 255 | * @param ratio_den Denominator of the sampling rate ratio copied 256 | */ 257 | void speex_resampler_get_ratio(SpeexResamplerState *st, 258 | spx_uint32_t *ratio_num, 259 | spx_uint32_t *ratio_den); 260 | 261 | /** Set (change) the conversion quality. 262 | * @param st Resampler state 263 | * @param quality Resampling quality between 0 and 10, where 0 has poor 264 | * quality and 10 has very high quality. 265 | */ 266 | int speex_resampler_set_quality(SpeexResamplerState *st, 267 | int quality); 268 | 269 | /** Get the conversion quality. 270 | * @param st Resampler state 271 | * @param quality Resampling quality between 0 and 10, where 0 has poor 272 | * quality and 10 has very high quality. 273 | */ 274 | void speex_resampler_get_quality(SpeexResamplerState *st, 275 | int *quality); 276 | 277 | /** Set (change) the input stride. 278 | * @param st Resampler state 279 | * @param stride Input stride 280 | */ 281 | void speex_resampler_set_input_stride(SpeexResamplerState *st, 282 | spx_uint32_t stride); 283 | 284 | /** Get the input stride. 285 | * @param st Resampler state 286 | * @param stride Input stride copied 287 | */ 288 | void speex_resampler_get_input_stride(SpeexResamplerState *st, 289 | spx_uint32_t *stride); 290 | 291 | /** Set (change) the output stride. 292 | * @param st Resampler state 293 | * @param stride Output stride 294 | */ 295 | void speex_resampler_set_output_stride(SpeexResamplerState *st, 296 | spx_uint32_t stride); 297 | 298 | /** Get the output stride. 299 | * @param st Resampler state copied 300 | * @param stride Output stride 301 | */ 302 | void speex_resampler_get_output_stride(SpeexResamplerState *st, 303 | spx_uint32_t *stride); 304 | 305 | /** Get the latency introduced by the resampler measured in input samples. 306 | * @param st Resampler state 307 | */ 308 | int speex_resampler_get_input_latency(SpeexResamplerState *st); 309 | 310 | /** Get the latency introduced by the resampler measured in output samples. 311 | * @param st Resampler state 312 | */ 313 | int speex_resampler_get_output_latency(SpeexResamplerState *st); 314 | 315 | /** Make sure that the first samples to go out of the resamplers don't have 316 | * leading zeros. This is only useful before starting to use a newly created 317 | * resampler. It is recommended to use that when resampling an audio file, as 318 | * it will generate a file with the same length. For real-time processing, 319 | * it is probably easier not to use this call (so that the output duration 320 | * is the same for the first frame). 321 | * @param st Resampler state 322 | */ 323 | int speex_resampler_skip_zeros(SpeexResamplerState *st); 324 | 325 | /** Reset a resampler so a new (unrelated) stream can be processed. 326 | * @param st Resampler state 327 | */ 328 | int speex_resampler_reset_mem(SpeexResamplerState *st); 329 | 330 | /** Returns the English meaning for an error code 331 | * @param err Error code 332 | * @return English string 333 | */ 334 | const char *speex_resampler_strerror(int err); 335 | 336 | #ifdef __cplusplus 337 | } 338 | #endif 339 | 340 | #endif 341 | -------------------------------------------------------------------------------- /include/speex/speexdsp_config_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPEEX_TYPES_H__ 2 | #define __SPEEX_TYPES_H__ 3 | 4 | #if defined HAVE_STDINT_H 5 | # include 6 | #elif defined HAVE_INTTYPES_H 7 | # include 8 | #elif defined HAVE_SYS_TYPES_H 9 | # include 10 | #endif 11 | 12 | typedef int16_t spx_int16_t; 13 | typedef uint16_t spx_uint16_t; 14 | typedef int32_t spx_int32_t; 15 | typedef uint32_t spx_uint32_t; 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /include/speex/speexdsp_types.h: -------------------------------------------------------------------------------- 1 | /* speexdsp_types.h taken from libogg */ 2 | /******************************************************************** 3 | * * 4 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * by the Xiph.Org Foundation http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: #ifdef jail to whip a few platforms into the UNIX ideal. 15 | last mod: $Id: os_types.h 7524 2004-08-11 04:20:36Z conrad $ 16 | 17 | ********************************************************************/ 18 | /** 19 | @file speexdsp_types.h 20 | @brief Speex types 21 | */ 22 | #ifndef _SPEEX_TYPES_H 23 | #define _SPEEX_TYPES_H 24 | 25 | #if defined(_WIN32) 26 | 27 | # if defined(__CYGWIN__) 28 | # include <_G_config.h> 29 | typedef _G_int32_t spx_int32_t; 30 | typedef _G_uint32_t spx_uint32_t; 31 | typedef _G_int16_t spx_int16_t; 32 | typedef _G_uint16_t spx_uint16_t; 33 | # elif defined(__MINGW32__) 34 | typedef short spx_int16_t; 35 | typedef unsigned short spx_uint16_t; 36 | typedef int spx_int32_t; 37 | typedef unsigned int spx_uint32_t; 38 | # elif defined(__MWERKS__) 39 | typedef int spx_int32_t; 40 | typedef unsigned int spx_uint32_t; 41 | typedef short spx_int16_t; 42 | typedef unsigned short spx_uint16_t; 43 | # else 44 | /* MSVC/Borland */ 45 | typedef __int32 spx_int32_t; 46 | typedef unsigned __int32 spx_uint32_t; 47 | typedef __int16 spx_int16_t; 48 | typedef unsigned __int16 spx_uint16_t; 49 | # endif 50 | 51 | #elif defined(__MACOS__) 52 | 53 | # include 54 | typedef SInt16 spx_int16_t; 55 | typedef UInt16 spx_uint16_t; 56 | typedef SInt32 spx_int32_t; 57 | typedef UInt32 spx_uint32_t; 58 | 59 | #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ 60 | 61 | # include 62 | typedef int16_t spx_int16_t; 63 | typedef u_int16_t spx_uint16_t; 64 | typedef int32_t spx_int32_t; 65 | typedef u_int32_t spx_uint32_t; 66 | 67 | #elif defined(__BEOS__) 68 | 69 | /* Be */ 70 | # include 71 | typedef int16_t spx_int16_t; 72 | typedef u_int16_t spx_uint16_t; 73 | typedef int32_t spx_int32_t; 74 | typedef u_int32_t spx_uint32_t; 75 | 76 | #elif defined (__EMX__) 77 | 78 | /* OS/2 GCC */ 79 | typedef short spx_int16_t; 80 | typedef unsigned short spx_uint16_t; 81 | typedef int spx_int32_t; 82 | typedef unsigned int spx_uint32_t; 83 | 84 | #elif defined (DJGPP) 85 | 86 | /* DJGPP */ 87 | typedef short spx_int16_t; 88 | typedef int spx_int32_t; 89 | typedef unsigned int spx_uint32_t; 90 | 91 | #elif defined(R5900) 92 | 93 | /* PS2 EE */ 94 | typedef int spx_int32_t; 95 | typedef unsigned spx_uint32_t; 96 | typedef short spx_int16_t; 97 | 98 | #elif defined(__SYMBIAN32__) 99 | 100 | /* Symbian GCC */ 101 | typedef signed short spx_int16_t; 102 | typedef unsigned short spx_uint16_t; 103 | typedef signed int spx_int32_t; 104 | typedef unsigned int spx_uint32_t; 105 | 106 | #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) 107 | 108 | typedef short spx_int16_t; 109 | typedef unsigned short spx_uint16_t; 110 | typedef long spx_int32_t; 111 | typedef unsigned long spx_uint32_t; 112 | 113 | #elif defined(CONFIG_TI_C6X) 114 | 115 | typedef short spx_int16_t; 116 | typedef unsigned short spx_uint16_t; 117 | typedef int spx_int32_t; 118 | typedef unsigned int spx_uint32_t; 119 | 120 | #else 121 | 122 | #include "speexdsp_config_types.h" 123 | 124 | #endif 125 | 126 | #endif /* _SPEEX_TYPES_H */ 127 | -------------------------------------------------------------------------------- /lib/libspeexdsp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingyuejingque/rtaudio_speex/e77f7ad9e66f26e8283bd2313ea9213557b8d7f7/lib/libspeexdsp.a -------------------------------------------------------------------------------- /lib/libspeexdsp.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingyuejingque/rtaudio_speex/e77f7ad9e66f26e8283bd2313ea9213557b8d7f7/lib/libspeexdsp.dll.a -------------------------------------------------------------------------------- /lib/libspeexdsp.la: -------------------------------------------------------------------------------- 1 | # libspeexdsp.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.7 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='../bin/libspeexdsp-1.dll' 9 | 10 | # Names of this library. 11 | library_names='libspeexdsp.dll.a' 12 | 13 | # The name of the static archive. 14 | old_library='libspeexdsp.a' 15 | 16 | # Linker flags that can not go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs='' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libspeexdsp. 26 | current=6 27 | age=5 28 | revision=0 29 | 30 | # Is this an already installed library? 31 | installed=yes 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='/g/install/lib' 42 | -------------------------------------------------------------------------------- /lib/pkgconfig/speexdsp.pc: -------------------------------------------------------------------------------- 1 | # libspeexdsp pkg-config source file 2 | 3 | prefix=/g/install 4 | exec_prefix=${prefix} 5 | libdir=${exec_prefix}/lib 6 | includedir=${prefix}/include 7 | 8 | Name: speexdsp 9 | Description: Speexdsp is a speech processing library that goes along with the Speex codec 10 | Version: 1.2rc3 11 | Requires: 12 | Conflicts: 13 | Libs: -L${libdir} -lspeexdsp 14 | Libs.private: -lm 15 | Cflags: -I${includedir} 16 | -------------------------------------------------------------------------------- /remote.pcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingyuejingque/rtaudio_speex/e77f7ad9e66f26e8283bd2313ea9213557b8d7f7/remote.pcm -------------------------------------------------------------------------------- /speex_func.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "speex_func.h" 4 | 5 | int speex_func_init(int frame_size, int filter_length, int sample_rate); 6 | int speex_func_destroy(); 7 | int speex_func_echo_cancel(short* mic, short* play, short* out); 8 | 9 | static SpeexPreprocessState* g_preprocess_state = nullptr; 10 | static SpeexEchoState *g_echo_state = nullptr; 11 | static int g_frame_size = 0; 12 | static int g_filter_length = 0; 13 | 14 | int speex_func_init(int frame_size, int filter_length, int sample_rate) { 15 | g_frame_size = frame_size; 16 | g_filter_length = filter_length; 17 | 18 | g_echo_state = speex_echo_state_init( 19 | g_frame_size, 20 | g_filter_length 21 | ); 22 | g_preprocess_state = speex_preprocess_state_init( 23 | g_frame_size, 24 | sample_rate); 25 | 26 | int _db = 60; 27 | int _denose = 1; 28 | int _noiseSuppress = -25; 29 | speex_echo_ctl(g_echo_state, SPEEX_ECHO_SET_SAMPLING_RATE, &sample_rate); 30 | speex_preprocess_ctl(g_preprocess_state, SPEEX_PREPROCESS_SET_DENOISE, &_denose); 31 | speex_preprocess_ctl(g_preprocess_state, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &_noiseSuppress); //设置噪声的dB 32 | speex_preprocess_ctl(g_preprocess_state, SPEEX_PREPROCESS_SET_ECHO_STATE, g_echo_state); 33 | speex_preprocess_ctl(g_preprocess_state, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, &_db); 34 | 35 | return (g_echo_state ? 1 : 0) && (g_preprocess_state? 1: 0); 36 | } 37 | 38 | 39 | int speex_func_destroy() { 40 | if (g_preprocess_state) { 41 | speex_preprocess_state_destroy(g_preprocess_state); 42 | g_preprocess_state = nullptr; 43 | } 44 | if (g_echo_state) { 45 | speex_echo_state_destroy(g_echo_state); 46 | g_echo_state = nullptr; 47 | } 48 | return 0; 49 | } 50 | 51 | int speex_func_echo_cancel(short* mic, short* play, short* out) { 52 | if (!g_echo_state || !g_preprocess_state) { 53 | return 0; 54 | } 55 | speex_echo_cancellation(g_echo_state, 56 | (const spx_int16_t*)mic, 57 | (const spx_int16_t*)play, 58 | (spx_int16_t*)out 59 | ); 60 | speex_preprocess_run(g_preprocess_state, out); 61 | return 0; 62 | } -------------------------------------------------------------------------------- /speex_func.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPEEX_FUNC_H__ 2 | #define __SPEEX_FUNC_H__ 3 | 4 | #pragma once 5 | 6 | int speex_func_init(int frame_size, int filter_length, int sample_rate); 7 | int speex_func_destroy(); 8 | int speex_func_echo_cancel(short* mic, short* play, short* out); 9 | 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingyuejingque/rtaudio_speex/e77f7ad9e66f26e8283bd2313ea9213557b8d7f7/test.exe -------------------------------------------------------------------------------- /消除效果图1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingyuejingque/rtaudio_speex/e77f7ad9e66f26e8283bd2313ea9213557b8d7f7/消除效果图1.png -------------------------------------------------------------------------------- /消除效果图2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mingyuejingque/rtaudio_speex/e77f7ad9e66f26e8283bd2313ea9213557b8d7f7/消除效果图2.png --------------------------------------------------------------------------------