1
0

101-portaudio.patch 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093
  1. --- a/src/portaudio.h
  2. +++ /dev/null
  3. @@ -1,466 +0,0 @@
  4. -// NOTE: Copy this file to portaudio.h in order to compile with V18 portaudio
  5. -
  6. -
  7. -#ifndef PORT_AUDIO_H
  8. -#define PORT_AUDIO_H
  9. -
  10. -#ifdef __cplusplus
  11. -extern "C"
  12. -{
  13. -#endif /* __cplusplus */
  14. -
  15. -/*
  16. - * $Id: portaudio.h,v 1.5 2002/03/26 18:04:22 philburk Exp $
  17. - * PortAudio Portable Real-Time Audio Library
  18. - * PortAudio API Header File
  19. - * Latest version available at: http://www.audiomulch.com/portaudio/
  20. - *
  21. - * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
  22. - *
  23. - * Permission is hereby granted, free of charge, to any person obtaining
  24. - * a copy of this software and associated documentation files
  25. - * (the "Software"), to deal in the Software without restriction,
  26. - * including without limitation the rights to use, copy, modify, merge,
  27. - * publish, distribute, sublicense, and/or sell copies of the Software,
  28. - * and to permit persons to whom the Software is furnished to do so,
  29. - * subject to the following conditions:
  30. - *
  31. - * The above copyright notice and this permission notice shall be
  32. - * included in all copies or substantial portions of the Software.
  33. - *
  34. - * Any person wishing to distribute modifications to the Software is
  35. - * requested to send the modifications to the original developer so that
  36. - * they can be incorporated into the canonical version.
  37. - *
  38. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  39. - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  40. - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  41. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
  42. - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  43. - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  44. - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  45. - *
  46. - */
  47. -
  48. -typedef int PaError;
  49. -typedef enum {
  50. - paNoError = 0,
  51. -
  52. - paHostError = -10000,
  53. - paInvalidChannelCount,
  54. - paInvalidSampleRate,
  55. - paInvalidDeviceId,
  56. - paInvalidFlag,
  57. - paSampleFormatNotSupported,
  58. - paBadIODeviceCombination,
  59. - paInsufficientMemory,
  60. - paBufferTooBig,
  61. - paBufferTooSmall,
  62. - paNullCallback,
  63. - paBadStreamPtr,
  64. - paTimedOut,
  65. - paInternalError,
  66. - paDeviceUnavailable
  67. -} PaErrorNum;
  68. -
  69. -/*
  70. - Pa_Initialize() is the library initialisation function - call this before
  71. - using the library.
  72. -
  73. -*/
  74. -
  75. -PaError Pa_Initialize( void );
  76. -
  77. -/*
  78. - Pa_Terminate() is the library termination function - call this after
  79. - using the library.
  80. -
  81. -*/
  82. -
  83. -PaError Pa_Terminate( void );
  84. -
  85. -/*
  86. - Pa_GetHostError() returns a host specific error code.
  87. - This can be called after receiving a PortAudio error code of paHostError.
  88. -
  89. -*/
  90. -
  91. -long Pa_GetHostError( void );
  92. -
  93. -/*
  94. - Pa_GetErrorText() translates the supplied PortAudio error number
  95. - into a human readable message.
  96. -
  97. -*/
  98. -
  99. -const char *Pa_GetErrorText( PaError errnum );
  100. -
  101. -/*
  102. - Sample formats
  103. -
  104. - These are formats used to pass sound data between the callback and the
  105. - stream. Each device has a "native" format which may be used when optimum
  106. - efficiency or control over conversion is required.
  107. -
  108. - Formats marked "always available" are supported (emulated) by all
  109. - PortAudio implementations.
  110. -
  111. - The floating point representation (paFloat32) uses +1.0 and -1.0 as the
  112. - maximum and minimum respectively.
  113. -
  114. - paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
  115. -
  116. -*/
  117. -
  118. -typedef unsigned long PaSampleFormat;
  119. -#define paFloat32 ((PaSampleFormat) (1<<0)) /*always available*/
  120. -#define paInt16 ((PaSampleFormat) (1<<1)) /*always available*/
  121. -#define paInt32 ((PaSampleFormat) (1<<2)) /*always available*/
  122. -#define paInt24 ((PaSampleFormat) (1<<3))
  123. -#define paPackedInt24 ((PaSampleFormat) (1<<4))
  124. -#define paInt8 ((PaSampleFormat) (1<<5))
  125. -#define paUInt8 ((PaSampleFormat) (1<<6))
  126. -#define paCustomFormat ((PaSampleFormat) (1<<16))
  127. -
  128. -/*
  129. - Device enumeration mechanism.
  130. -
  131. - Device ids range from 0 to Pa_CountDevices()-1.
  132. -
  133. - Devices may support input, output or both.
  134. -
  135. -*/
  136. -
  137. -typedef int PaDeviceID;
  138. -#define paNoDevice -1
  139. -
  140. -int Pa_CountDevices( void );
  141. -
  142. -typedef struct
  143. -{
  144. - int structVersion;
  145. - const char *name;
  146. - int maxInputChannels;
  147. - int maxOutputChannels;
  148. - /* Number of discrete rates, or -1 if range supported. */
  149. - int numSampleRates;
  150. - /* Array of supported sample rates, or {min,max} if range supported. */
  151. - const double *sampleRates;
  152. - PaSampleFormat nativeSampleFormats;
  153. -}
  154. -PaDeviceInfo;
  155. -
  156. -/*
  157. - Pa_GetDefaultInputDeviceID(), Pa_GetDefaultOutputDeviceID() return the
  158. - default device ids for input and output respectively, or paNoDevice if
  159. - no device is available.
  160. - The result can be passed to Pa_OpenStream().
  161. -
  162. - On the PC, the user can specify a default device by
  163. - setting an environment variable. For example, to use device #1.
  164. -
  165. - set PA_RECOMMENDED_OUTPUT_DEVICE=1
  166. -
  167. - The user should first determine the available device ids by using
  168. - the supplied application "pa_devs".
  169. -
  170. -*/
  171. -
  172. -PaDeviceID Pa_GetDefaultInputDeviceID( void );
  173. -PaDeviceID Pa_GetDefaultOutputDeviceID( void );
  174. -
  175. -
  176. -
  177. -/*
  178. - Pa_GetDeviceInfo() returns a pointer to an immutable PaDeviceInfo structure
  179. - for the device specified.
  180. - If the device parameter is out of range the function returns NULL.
  181. -
  182. - PortAudio manages the memory referenced by the returned pointer, the client
  183. - must not manipulate or free the memory. The pointer is only guaranteed to be
  184. - valid between calls to Pa_Initialize() and Pa_Terminate().
  185. -
  186. -*/
  187. -
  188. -const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceID device );
  189. -
  190. -/*
  191. - PaTimestamp is used to represent a continuous sample clock with arbitrary
  192. - start time that can be used for syncronization. The type is used for the
  193. - outTime argument to the PortAudioCallback and as the result of Pa_StreamTime()
  194. -
  195. -*/
  196. -
  197. -typedef double PaTimestamp;
  198. -
  199. -/*
  200. - PortAudioCallback is implemented by PortAudio clients.
  201. -
  202. - inputBuffer and outputBuffer are arrays of interleaved samples,
  203. - the format, packing and number of channels used by the buffers are
  204. - determined by parameters to Pa_OpenStream() (see below).
  205. -
  206. - framesPerBuffer is the number of sample frames to be processed by the callback.
  207. -
  208. - outTime is the time in samples when the buffer(s) processed by
  209. - this callback will begin being played at the audio output.
  210. - See also Pa_StreamTime()
  211. -
  212. - userData is the value of a user supplied pointer passed to Pa_OpenStream()
  213. - intended for storing synthesis data etc.
  214. -
  215. - return value:
  216. - The callback can return a non-zero value to stop the stream. This may be
  217. - useful in applications such as soundfile players where a specific duration
  218. - of output is required. However, it is not necessary to utilise this mechanism
  219. - as StopStream() will also terminate the stream. A callback returning a
  220. - non-zero value must fill the entire outputBuffer.
  221. -
  222. - NOTE: None of the other stream functions may be called from within the
  223. - callback function except for Pa_GetCPULoad().
  224. -
  225. -*/
  226. -
  227. -typedef int (PortAudioCallback)(
  228. - void *inputBuffer, void *outputBuffer,
  229. - unsigned long framesPerBuffer,
  230. - PaTimestamp outTime, void *userData );
  231. -
  232. -
  233. -/*
  234. - Stream flags
  235. -
  236. - These flags may be supplied (ored together) in the streamFlags argument to
  237. - the Pa_OpenStream() function.
  238. -
  239. -*/
  240. -
  241. -#define paNoFlag (0)
  242. -#define paClipOff (1<<0) /* disable default clipping of out of range samples */
  243. -#define paDitherOff (1<<1) /* disable default dithering */
  244. -#define paPlatformSpecificFlags (0x00010000)
  245. -typedef unsigned long PaStreamFlags;
  246. -
  247. -/*
  248. - A single PortAudioStream provides multiple channels of real-time
  249. - input and output audio streaming to a client application.
  250. - Pointers to PortAudioStream objects are passed between PortAudio functions.
  251. -*/
  252. -
  253. -typedef void PortAudioStream;
  254. -#define PaStream PortAudioStream
  255. -
  256. -/*
  257. - Pa_OpenStream() opens a stream for either input, output or both.
  258. -
  259. - stream is the address of a PortAudioStream pointer which will receive
  260. - a pointer to the newly opened stream.
  261. -
  262. - inputDevice is the id of the device used for input (see PaDeviceID above.)
  263. - inputDevice may be paNoDevice to indicate that an input device is not required.
  264. -
  265. - numInputChannels is the number of channels of sound to be delivered to the
  266. - callback. It can range from 1 to the value of maxInputChannels in the
  267. - PaDeviceInfo record for the device specified by the inputDevice parameter.
  268. - If inputDevice is paNoDevice numInputChannels is ignored.
  269. -
  270. - inputSampleFormat is the sample format of inputBuffer provided to the callback
  271. - function. inputSampleFormat may be any of the formats described by the
  272. - PaSampleFormat enumeration (see above). PortAudio guarantees support for
  273. - the device's native formats (nativeSampleFormats in the device info record)
  274. - and additionally 16 and 32 bit integer and 32 bit floating point formats.
  275. - Support for other formats is implementation defined.
  276. -
  277. - inputDriverInfo is a pointer to an optional driver specific data structure
  278. - containing additional information for device setup or stream processing.
  279. - inputDriverInfo is never required for correct operation. If not used
  280. - inputDriverInfo should be NULL.
  281. -
  282. - outputDevice is the id of the device used for output (see PaDeviceID above.)
  283. - outputDevice may be paNoDevice to indicate that an output device is not required.
  284. -
  285. - numOutputChannels is the number of channels of sound to be supplied by the
  286. - callback. See the definition of numInputChannels above for more details.
  287. -
  288. - outputSampleFormat is the sample format of the outputBuffer filled by the
  289. - callback function. See the definition of inputSampleFormat above for more
  290. - details.
  291. -
  292. - outputDriverInfo is a pointer to an optional driver specific data structure
  293. - containing additional information for device setup or stream processing.
  294. - outputDriverInfo is never required for correct operation. If not used
  295. - outputDriverInfo should be NULL.
  296. -
  297. - sampleRate is the desired sampleRate. For full-duplex streams it is the
  298. - sample rate for both input and output
  299. -
  300. - framesPerBuffer is the length in sample frames of all internal sample buffers
  301. - used for communication with platform specific audio routines. Wherever
  302. - possible this corresponds to the framesPerBuffer parameter passed to the
  303. - callback function.
  304. -
  305. - numberOfBuffers is the number of buffers used for multibuffered communication
  306. - with the platform specific audio routines. If you pass zero, then an optimum
  307. - value will be chosen for you internally. This parameter is provided only
  308. - as a guide - and does not imply that an implementation must use multibuffered
  309. - i/o when reliable double buffering is available (such as SndPlayDoubleBuffer()
  310. - on the Macintosh.)
  311. -
  312. - streamFlags may contain a combination of flags ORed together.
  313. - These flags modify the behaviour of the streaming process. Some flags may only
  314. - be relevant to certain buffer formats.
  315. -
  316. - callback is a pointer to a client supplied function that is responsible
  317. - for processing and filling input and output buffers (see above for details.)
  318. -
  319. - userData is a client supplied pointer which is passed to the callback
  320. - function. It could for example, contain a pointer to instance data necessary
  321. - for processing the audio buffers.
  322. -
  323. - return value:
  324. - Upon success Pa_OpenStream() returns PaNoError and places a pointer to a
  325. - valid PortAudioStream in the stream argument. The stream is inactive (stopped).
  326. - If a call to Pa_OpenStream() fails a non-zero error code is returned (see
  327. - PaError above) and the value of stream is invalid.
  328. -
  329. -*/
  330. -
  331. -PaError Pa_OpenStream( PortAudioStream** stream,
  332. - PaDeviceID inputDevice,
  333. - int numInputChannels,
  334. - PaSampleFormat inputSampleFormat,
  335. - void *inputDriverInfo,
  336. - PaDeviceID outputDevice,
  337. - int numOutputChannels,
  338. - PaSampleFormat outputSampleFormat,
  339. - void *outputDriverInfo,
  340. - double sampleRate,
  341. - unsigned long framesPerBuffer,
  342. - unsigned long numberOfBuffers,
  343. - PaStreamFlags streamFlags,
  344. - PortAudioCallback *callback,
  345. - void *userData );
  346. -
  347. -
  348. -/*
  349. - Pa_OpenDefaultStream() is a simplified version of Pa_OpenStream() that opens
  350. - the default input and/or output devices. Most parameters have identical meaning
  351. - to their Pa_OpenStream() counterparts, with the following exceptions:
  352. -
  353. - If either numInputChannels or numOutputChannels is 0 the respective device
  354. - is not opened. This has the same effect as passing paNoDevice in the device
  355. - arguments to Pa_OpenStream().
  356. -
  357. - sampleFormat applies to both the input and output buffers.
  358. -
  359. -*/
  360. -
  361. -PaError Pa_OpenDefaultStream( PortAudioStream** stream,
  362. - int numInputChannels,
  363. - int numOutputChannels,
  364. - PaSampleFormat sampleFormat,
  365. - double sampleRate,
  366. - unsigned long framesPerBuffer,
  367. - unsigned long numberOfBuffers,
  368. - PortAudioCallback *callback,
  369. - void *userData );
  370. -
  371. -/*
  372. - Pa_CloseStream() closes an audio stream, flushing any pending buffers.
  373. -
  374. -*/
  375. -
  376. -PaError Pa_CloseStream( PortAudioStream* );
  377. -
  378. -/*
  379. - Pa_StartStream() and Pa_StopStream() begin and terminate audio processing.
  380. - Pa_StopStream() waits until all pending audio buffers have been played.
  381. - Pa_AbortStream() stops playing immediately without waiting for pending
  382. - buffers to complete.
  383. -
  384. -*/
  385. -
  386. -PaError Pa_StartStream( PortAudioStream *stream );
  387. -
  388. -PaError Pa_StopStream( PortAudioStream *stream );
  389. -
  390. -PaError Pa_AbortStream( PortAudioStream *stream );
  391. -
  392. -/*
  393. - Pa_StreamActive() returns one (1) when the stream is active (ie playing
  394. - or recording audio), zero (0) when not playing, or a negative error number
  395. - if the stream is invalid.
  396. - The stream is active between calls to Pa_StartStream() and Pa_StopStream(),
  397. - but may also become inactive if the callback returns a non-zero value.
  398. - In the latter case, the stream is considered inactive after the last
  399. - buffer has finished playing.
  400. -
  401. -*/
  402. -
  403. -PaError Pa_StreamActive( PortAudioStream *stream );
  404. -
  405. -/*
  406. - Pa_StreamTime() returns the current output time in samples for the stream.
  407. - This time may be used as a time reference (for example synchronizing audio to
  408. - MIDI).
  409. -
  410. -*/
  411. -
  412. -PaTimestamp Pa_StreamTime( PortAudioStream *stream );
  413. -
  414. -/*
  415. - Pa_GetCPULoad() returns the CPU Load for the stream.
  416. - The "CPU Load" is a fraction of total CPU time consumed by the stream's
  417. - audio processing routines including, but not limited to the client supplied
  418. - callback.
  419. - A value of 0.5 would imply that PortAudio and the sound generating
  420. - callback was consuming roughly 50% of the available CPU time.
  421. - This function may be called from the callback function or the application.
  422. -
  423. -*/
  424. -
  425. -double Pa_GetCPULoad( PortAudioStream* stream );
  426. -
  427. -/*
  428. - Pa_GetMinNumBuffers() returns the minimum number of buffers required by
  429. - the current host based on minimum latency.
  430. - On the PC, for the DirectSound implementation, latency can be optionally set
  431. - by user by setting an environment variable.
  432. - For example, to set latency to 200 msec, put:
  433. -
  434. - set PA_MIN_LATENCY_MSEC=200
  435. -
  436. - in the AUTOEXEC.BAT file and reboot.
  437. - If the environment variable is not set, then the latency will be determined
  438. - based on the OS. Windows NT has higher latency than Win95.
  439. -
  440. -*/
  441. -
  442. -int Pa_GetMinNumBuffers( int framesPerBuffer, double sampleRate );
  443. -
  444. -/*
  445. - Pa_Sleep() puts the caller to sleep for at least 'msec' milliseconds.
  446. - You may sleep longer than the requested time so don't rely on this for
  447. - accurate musical timing.
  448. -
  449. - Pa_Sleep() is provided as a convenience for authors of portable code (such as
  450. - the tests and examples in the PortAudio distribution.)
  451. -
  452. -*/
  453. -
  454. -void Pa_Sleep( long msec );
  455. -
  456. -/*
  457. - Pa_GetSampleSize() returns the size in bytes of a single sample in the
  458. - supplied PaSampleFormat, or paSampleFormatNotSupported if the format is
  459. - no supported.
  460. -
  461. -*/
  462. -
  463. -PaError Pa_GetSampleSize( PaSampleFormat format );
  464. -
  465. -
  466. -#ifdef __cplusplus
  467. -}
  468. -#endif /* __cplusplus */
  469. -#endif /* PORT_AUDIO_H */
  470. --- a/src/portaudio18.h
  471. +++ /dev/null
  472. @@ -1,466 +0,0 @@
  473. -// NOTE: Copy this file to portaudio.h in order to compile with V18 portaudio
  474. -
  475. -
  476. -#ifndef PORT_AUDIO_H
  477. -#define PORT_AUDIO_H
  478. -
  479. -#ifdef __cplusplus
  480. -extern "C"
  481. -{
  482. -#endif /* __cplusplus */
  483. -
  484. -/*
  485. - * $Id: portaudio.h,v 1.5 2002/03/26 18:04:22 philburk Exp $
  486. - * PortAudio Portable Real-Time Audio Library
  487. - * PortAudio API Header File
  488. - * Latest version available at: http://www.audiomulch.com/portaudio/
  489. - *
  490. - * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
  491. - *
  492. - * Permission is hereby granted, free of charge, to any person obtaining
  493. - * a copy of this software and associated documentation files
  494. - * (the "Software"), to deal in the Software without restriction,
  495. - * including without limitation the rights to use, copy, modify, merge,
  496. - * publish, distribute, sublicense, and/or sell copies of the Software,
  497. - * and to permit persons to whom the Software is furnished to do so,
  498. - * subject to the following conditions:
  499. - *
  500. - * The above copyright notice and this permission notice shall be
  501. - * included in all copies or substantial portions of the Software.
  502. - *
  503. - * Any person wishing to distribute modifications to the Software is
  504. - * requested to send the modifications to the original developer so that
  505. - * they can be incorporated into the canonical version.
  506. - *
  507. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  508. - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  509. - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  510. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
  511. - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  512. - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  513. - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  514. - *
  515. - */
  516. -
  517. -typedef int PaError;
  518. -typedef enum {
  519. - paNoError = 0,
  520. -
  521. - paHostError = -10000,
  522. - paInvalidChannelCount,
  523. - paInvalidSampleRate,
  524. - paInvalidDeviceId,
  525. - paInvalidFlag,
  526. - paSampleFormatNotSupported,
  527. - paBadIODeviceCombination,
  528. - paInsufficientMemory,
  529. - paBufferTooBig,
  530. - paBufferTooSmall,
  531. - paNullCallback,
  532. - paBadStreamPtr,
  533. - paTimedOut,
  534. - paInternalError,
  535. - paDeviceUnavailable
  536. -} PaErrorNum;
  537. -
  538. -/*
  539. - Pa_Initialize() is the library initialisation function - call this before
  540. - using the library.
  541. -
  542. -*/
  543. -
  544. -PaError Pa_Initialize( void );
  545. -
  546. -/*
  547. - Pa_Terminate() is the library termination function - call this after
  548. - using the library.
  549. -
  550. -*/
  551. -
  552. -PaError Pa_Terminate( void );
  553. -
  554. -/*
  555. - Pa_GetHostError() returns a host specific error code.
  556. - This can be called after receiving a PortAudio error code of paHostError.
  557. -
  558. -*/
  559. -
  560. -long Pa_GetHostError( void );
  561. -
  562. -/*
  563. - Pa_GetErrorText() translates the supplied PortAudio error number
  564. - into a human readable message.
  565. -
  566. -*/
  567. -
  568. -const char *Pa_GetErrorText( PaError errnum );
  569. -
  570. -/*
  571. - Sample formats
  572. -
  573. - These are formats used to pass sound data between the callback and the
  574. - stream. Each device has a "native" format which may be used when optimum
  575. - efficiency or control over conversion is required.
  576. -
  577. - Formats marked "always available" are supported (emulated) by all
  578. - PortAudio implementations.
  579. -
  580. - The floating point representation (paFloat32) uses +1.0 and -1.0 as the
  581. - maximum and minimum respectively.
  582. -
  583. - paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
  584. -
  585. -*/
  586. -
  587. -typedef unsigned long PaSampleFormat;
  588. -#define paFloat32 ((PaSampleFormat) (1<<0)) /*always available*/
  589. -#define paInt16 ((PaSampleFormat) (1<<1)) /*always available*/
  590. -#define paInt32 ((PaSampleFormat) (1<<2)) /*always available*/
  591. -#define paInt24 ((PaSampleFormat) (1<<3))
  592. -#define paPackedInt24 ((PaSampleFormat) (1<<4))
  593. -#define paInt8 ((PaSampleFormat) (1<<5))
  594. -#define paUInt8 ((PaSampleFormat) (1<<6))
  595. -#define paCustomFormat ((PaSampleFormat) (1<<16))
  596. -
  597. -/*
  598. - Device enumeration mechanism.
  599. -
  600. - Device ids range from 0 to Pa_CountDevices()-1.
  601. -
  602. - Devices may support input, output or both.
  603. -
  604. -*/
  605. -
  606. -typedef int PaDeviceID;
  607. -#define paNoDevice -1
  608. -
  609. -int Pa_CountDevices( void );
  610. -
  611. -typedef struct
  612. -{
  613. - int structVersion;
  614. - const char *name;
  615. - int maxInputChannels;
  616. - int maxOutputChannels;
  617. - /* Number of discrete rates, or -1 if range supported. */
  618. - int numSampleRates;
  619. - /* Array of supported sample rates, or {min,max} if range supported. */
  620. - const double *sampleRates;
  621. - PaSampleFormat nativeSampleFormats;
  622. -}
  623. -PaDeviceInfo;
  624. -
  625. -/*
  626. - Pa_GetDefaultInputDeviceID(), Pa_GetDefaultOutputDeviceID() return the
  627. - default device ids for input and output respectively, or paNoDevice if
  628. - no device is available.
  629. - The result can be passed to Pa_OpenStream().
  630. -
  631. - On the PC, the user can specify a default device by
  632. - setting an environment variable. For example, to use device #1.
  633. -
  634. - set PA_RECOMMENDED_OUTPUT_DEVICE=1
  635. -
  636. - The user should first determine the available device ids by using
  637. - the supplied application "pa_devs".
  638. -
  639. -*/
  640. -
  641. -PaDeviceID Pa_GetDefaultInputDeviceID( void );
  642. -PaDeviceID Pa_GetDefaultOutputDeviceID( void );
  643. -
  644. -
  645. -
  646. -/*
  647. - Pa_GetDeviceInfo() returns a pointer to an immutable PaDeviceInfo structure
  648. - for the device specified.
  649. - If the device parameter is out of range the function returns NULL.
  650. -
  651. - PortAudio manages the memory referenced by the returned pointer, the client
  652. - must not manipulate or free the memory. The pointer is only guaranteed to be
  653. - valid between calls to Pa_Initialize() and Pa_Terminate().
  654. -
  655. -*/
  656. -
  657. -const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceID device );
  658. -
  659. -/*
  660. - PaTimestamp is used to represent a continuous sample clock with arbitrary
  661. - start time that can be used for syncronization. The type is used for the
  662. - outTime argument to the PortAudioCallback and as the result of Pa_StreamTime()
  663. -
  664. -*/
  665. -
  666. -typedef double PaTimestamp;
  667. -
  668. -/*
  669. - PortAudioCallback is implemented by PortAudio clients.
  670. -
  671. - inputBuffer and outputBuffer are arrays of interleaved samples,
  672. - the format, packing and number of channels used by the buffers are
  673. - determined by parameters to Pa_OpenStream() (see below).
  674. -
  675. - framesPerBuffer is the number of sample frames to be processed by the callback.
  676. -
  677. - outTime is the time in samples when the buffer(s) processed by
  678. - this callback will begin being played at the audio output.
  679. - See also Pa_StreamTime()
  680. -
  681. - userData is the value of a user supplied pointer passed to Pa_OpenStream()
  682. - intended for storing synthesis data etc.
  683. -
  684. - return value:
  685. - The callback can return a non-zero value to stop the stream. This may be
  686. - useful in applications such as soundfile players where a specific duration
  687. - of output is required. However, it is not necessary to utilise this mechanism
  688. - as StopStream() will also terminate the stream. A callback returning a
  689. - non-zero value must fill the entire outputBuffer.
  690. -
  691. - NOTE: None of the other stream functions may be called from within the
  692. - callback function except for Pa_GetCPULoad().
  693. -
  694. -*/
  695. -
  696. -typedef int (PortAudioCallback)(
  697. - void *inputBuffer, void *outputBuffer,
  698. - unsigned long framesPerBuffer,
  699. - PaTimestamp outTime, void *userData );
  700. -
  701. -
  702. -/*
  703. - Stream flags
  704. -
  705. - These flags may be supplied (ored together) in the streamFlags argument to
  706. - the Pa_OpenStream() function.
  707. -
  708. -*/
  709. -
  710. -#define paNoFlag (0)
  711. -#define paClipOff (1<<0) /* disable default clipping of out of range samples */
  712. -#define paDitherOff (1<<1) /* disable default dithering */
  713. -#define paPlatformSpecificFlags (0x00010000)
  714. -typedef unsigned long PaStreamFlags;
  715. -
  716. -/*
  717. - A single PortAudioStream provides multiple channels of real-time
  718. - input and output audio streaming to a client application.
  719. - Pointers to PortAudioStream objects are passed between PortAudio functions.
  720. -*/
  721. -
  722. -typedef void PortAudioStream;
  723. -#define PaStream PortAudioStream
  724. -
  725. -/*
  726. - Pa_OpenStream() opens a stream for either input, output or both.
  727. -
  728. - stream is the address of a PortAudioStream pointer which will receive
  729. - a pointer to the newly opened stream.
  730. -
  731. - inputDevice is the id of the device used for input (see PaDeviceID above.)
  732. - inputDevice may be paNoDevice to indicate that an input device is not required.
  733. -
  734. - numInputChannels is the number of channels of sound to be delivered to the
  735. - callback. It can range from 1 to the value of maxInputChannels in the
  736. - PaDeviceInfo record for the device specified by the inputDevice parameter.
  737. - If inputDevice is paNoDevice numInputChannels is ignored.
  738. -
  739. - inputSampleFormat is the sample format of inputBuffer provided to the callback
  740. - function. inputSampleFormat may be any of the formats described by the
  741. - PaSampleFormat enumeration (see above). PortAudio guarantees support for
  742. - the device's native formats (nativeSampleFormats in the device info record)
  743. - and additionally 16 and 32 bit integer and 32 bit floating point formats.
  744. - Support for other formats is implementation defined.
  745. -
  746. - inputDriverInfo is a pointer to an optional driver specific data structure
  747. - containing additional information for device setup or stream processing.
  748. - inputDriverInfo is never required for correct operation. If not used
  749. - inputDriverInfo should be NULL.
  750. -
  751. - outputDevice is the id of the device used for output (see PaDeviceID above.)
  752. - outputDevice may be paNoDevice to indicate that an output device is not required.
  753. -
  754. - numOutputChannels is the number of channels of sound to be supplied by the
  755. - callback. See the definition of numInputChannels above for more details.
  756. -
  757. - outputSampleFormat is the sample format of the outputBuffer filled by the
  758. - callback function. See the definition of inputSampleFormat above for more
  759. - details.
  760. -
  761. - outputDriverInfo is a pointer to an optional driver specific data structure
  762. - containing additional information for device setup or stream processing.
  763. - outputDriverInfo is never required for correct operation. If not used
  764. - outputDriverInfo should be NULL.
  765. -
  766. - sampleRate is the desired sampleRate. For full-duplex streams it is the
  767. - sample rate for both input and output
  768. -
  769. - framesPerBuffer is the length in sample frames of all internal sample buffers
  770. - used for communication with platform specific audio routines. Wherever
  771. - possible this corresponds to the framesPerBuffer parameter passed to the
  772. - callback function.
  773. -
  774. - numberOfBuffers is the number of buffers used for multibuffered communication
  775. - with the platform specific audio routines. If you pass zero, then an optimum
  776. - value will be chosen for you internally. This parameter is provided only
  777. - as a guide - and does not imply that an implementation must use multibuffered
  778. - i/o when reliable double buffering is available (such as SndPlayDoubleBuffer()
  779. - on the Macintosh.)
  780. -
  781. - streamFlags may contain a combination of flags ORed together.
  782. - These flags modify the behaviour of the streaming process. Some flags may only
  783. - be relevant to certain buffer formats.
  784. -
  785. - callback is a pointer to a client supplied function that is responsible
  786. - for processing and filling input and output buffers (see above for details.)
  787. -
  788. - userData is a client supplied pointer which is passed to the callback
  789. - function. It could for example, contain a pointer to instance data necessary
  790. - for processing the audio buffers.
  791. -
  792. - return value:
  793. - Upon success Pa_OpenStream() returns PaNoError and places a pointer to a
  794. - valid PortAudioStream in the stream argument. The stream is inactive (stopped).
  795. - If a call to Pa_OpenStream() fails a non-zero error code is returned (see
  796. - PaError above) and the value of stream is invalid.
  797. -
  798. -*/
  799. -
  800. -PaError Pa_OpenStream( PortAudioStream** stream,
  801. - PaDeviceID inputDevice,
  802. - int numInputChannels,
  803. - PaSampleFormat inputSampleFormat,
  804. - void *inputDriverInfo,
  805. - PaDeviceID outputDevice,
  806. - int numOutputChannels,
  807. - PaSampleFormat outputSampleFormat,
  808. - void *outputDriverInfo,
  809. - double sampleRate,
  810. - unsigned long framesPerBuffer,
  811. - unsigned long numberOfBuffers,
  812. - PaStreamFlags streamFlags,
  813. - PortAudioCallback *callback,
  814. - void *userData );
  815. -
  816. -
  817. -/*
  818. - Pa_OpenDefaultStream() is a simplified version of Pa_OpenStream() that opens
  819. - the default input and/or output devices. Most parameters have identical meaning
  820. - to their Pa_OpenStream() counterparts, with the following exceptions:
  821. -
  822. - If either numInputChannels or numOutputChannels is 0 the respective device
  823. - is not opened. This has the same effect as passing paNoDevice in the device
  824. - arguments to Pa_OpenStream().
  825. -
  826. - sampleFormat applies to both the input and output buffers.
  827. -
  828. -*/
  829. -
  830. -PaError Pa_OpenDefaultStream( PortAudioStream** stream,
  831. - int numInputChannels,
  832. - int numOutputChannels,
  833. - PaSampleFormat sampleFormat,
  834. - double sampleRate,
  835. - unsigned long framesPerBuffer,
  836. - unsigned long numberOfBuffers,
  837. - PortAudioCallback *callback,
  838. - void *userData );
  839. -
  840. -/*
  841. - Pa_CloseStream() closes an audio stream, flushing any pending buffers.
  842. -
  843. -*/
  844. -
  845. -PaError Pa_CloseStream( PortAudioStream* );
  846. -
  847. -/*
  848. - Pa_StartStream() and Pa_StopStream() begin and terminate audio processing.
  849. - Pa_StopStream() waits until all pending audio buffers have been played.
  850. - Pa_AbortStream() stops playing immediately without waiting for pending
  851. - buffers to complete.
  852. -
  853. -*/
  854. -
  855. -PaError Pa_StartStream( PortAudioStream *stream );
  856. -
  857. -PaError Pa_StopStream( PortAudioStream *stream );
  858. -
  859. -PaError Pa_AbortStream( PortAudioStream *stream );
  860. -
  861. -/*
  862. - Pa_StreamActive() returns one (1) when the stream is active (ie playing
  863. - or recording audio), zero (0) when not playing, or a negative error number
  864. - if the stream is invalid.
  865. - The stream is active between calls to Pa_StartStream() and Pa_StopStream(),
  866. - but may also become inactive if the callback returns a non-zero value.
  867. - In the latter case, the stream is considered inactive after the last
  868. - buffer has finished playing.
  869. -
  870. -*/
  871. -
  872. -PaError Pa_StreamActive( PortAudioStream *stream );
  873. -
  874. -/*
  875. - Pa_StreamTime() returns the current output time in samples for the stream.
  876. - This time may be used as a time reference (for example synchronizing audio to
  877. - MIDI).
  878. -
  879. -*/
  880. -
  881. -PaTimestamp Pa_StreamTime( PortAudioStream *stream );
  882. -
  883. -/*
  884. - Pa_GetCPULoad() returns the CPU Load for the stream.
  885. - The "CPU Load" is a fraction of total CPU time consumed by the stream's
  886. - audio processing routines including, but not limited to the client supplied
  887. - callback.
  888. - A value of 0.5 would imply that PortAudio and the sound generating
  889. - callback was consuming roughly 50% of the available CPU time.
  890. - This function may be called from the callback function or the application.
  891. -
  892. -*/
  893. -
  894. -double Pa_GetCPULoad( PortAudioStream* stream );
  895. -
  896. -/*
  897. - Pa_GetMinNumBuffers() returns the minimum number of buffers required by
  898. - the current host based on minimum latency.
  899. - On the PC, for the DirectSound implementation, latency can be optionally set
  900. - by user by setting an environment variable.
  901. - For example, to set latency to 200 msec, put:
  902. -
  903. - set PA_MIN_LATENCY_MSEC=200
  904. -
  905. - in the AUTOEXEC.BAT file and reboot.
  906. - If the environment variable is not set, then the latency will be determined
  907. - based on the OS. Windows NT has higher latency than Win95.
  908. -
  909. -*/
  910. -
  911. -int Pa_GetMinNumBuffers( int framesPerBuffer, double sampleRate );
  912. -
  913. -/*
  914. - Pa_Sleep() puts the caller to sleep for at least 'msec' milliseconds.
  915. - You may sleep longer than the requested time so don't rely on this for
  916. - accurate musical timing.
  917. -
  918. - Pa_Sleep() is provided as a convenience for authors of portable code (such as
  919. - the tests and examples in the PortAudio distribution.)
  920. -
  921. -*/
  922. -
  923. -void Pa_Sleep( long msec );
  924. -
  925. -/*
  926. - Pa_GetSampleSize() returns the size in bytes of a single sample in the
  927. - supplied PaSampleFormat, or paSampleFormatNotSupported if the format is
  928. - no supported.
  929. -
  930. -*/
  931. -
  932. -PaError Pa_GetSampleSize( PaSampleFormat format );
  933. -
  934. -
  935. -#ifdef __cplusplus
  936. -}
  937. -#endif /* __cplusplus */
  938. -#endif /* PORT_AUDIO_H */
  939. --- a/src/portaudio19.h
  940. +++ /dev/null
  941. @@ -1,1127 +0,0 @@
  942. -// NOTE: Copy this file to portaudio.h in order to compile with V19 portaudio
  943. -
  944. -#ifndef PORTAUDIO_H
  945. -#define PORTAUDIO_H
  946. -/*
  947. - * $Id: portaudio.h 1061 2006-06-19 22:46:41Z lschwardt $
  948. - * PortAudio Portable Real-Time Audio Library
  949. - * PortAudio API Header File
  950. - * Latest version available at: http://www.portaudio.com/
  951. - *
  952. - * Copyright (c) 1999-2002 Ross Bencina and Phil Burk
  953. - *
  954. - * Permission is hereby granted, free of charge, to any person obtaining
  955. - * a copy of this software and associated documentation files
  956. - * (the "Software"), to deal in the Software without restriction,
  957. - * including without limitation the rights to use, copy, modify, merge,
  958. - * publish, distribute, sublicense, and/or sell copies of the Software,
  959. - * and to permit persons to whom the Software is furnished to do so,
  960. - * subject to the following conditions:
  961. - *
  962. - * The above copyright notice and this permission notice shall be
  963. - * included in all copies or substantial portions of the Software.
  964. - *
  965. - * Any person wishing to distribute modifications to the Software is
  966. - * requested to send the modifications to the original developer so that
  967. - * they can be incorporated into the canonical version.
  968. - *
  969. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  970. - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  971. - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  972. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
  973. - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  974. - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  975. - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  976. - */
  977. -
  978. -/** @file
  979. - @brief The PortAudio API.
  980. -*/
  981. -
  982. -
  983. -#ifdef __cplusplus
  984. -extern "C"
  985. -{
  986. -#endif /* __cplusplus */
  987. -
  988. -
  989. -/** Retrieve the release number of the currently running PortAudio build,
  990. - eg 1900.
  991. -*/
  992. -int Pa_GetVersion( void );
  993. -
  994. -
  995. -/** Retrieve a textual description of the current PortAudio build,
  996. - eg "PortAudio V19-devel 13 October 2002".
  997. -*/
  998. -const char* Pa_GetVersionText( void );
  999. -
  1000. -
  1001. -/** Error codes returned by PortAudio functions.
  1002. - Note that with the exception of paNoError, all PaErrorCodes are negative.
  1003. -*/
  1004. -
  1005. -typedef int PaError;
  1006. -typedef enum PaErrorCode
  1007. -{
  1008. - paNoError = 0,
  1009. -
  1010. - paNotInitialized = -10000,
  1011. - paUnanticipatedHostError,
  1012. - paInvalidChannelCount,
  1013. - paInvalidSampleRate,
  1014. - paInvalidDevice,
  1015. - paInvalidFlag,
  1016. - paSampleFormatNotSupported,
  1017. - paBadIODeviceCombination,
  1018. - paInsufficientMemory,
  1019. - paBufferTooBig,
  1020. - paBufferTooSmall,
  1021. - paNullCallback,
  1022. - paBadStreamPtr,
  1023. - paTimedOut,
  1024. - paInternalError,
  1025. - paDeviceUnavailable,
  1026. - paIncompatibleHostApiSpecificStreamInfo,
  1027. - paStreamIsStopped,
  1028. - paStreamIsNotStopped,
  1029. - paInputOverflowed,
  1030. - paOutputUnderflowed,
  1031. - paHostApiNotFound,
  1032. - paInvalidHostApi,
  1033. - paCanNotReadFromACallbackStream, /**< @todo review error code name */
  1034. - paCanNotWriteToACallbackStream, /**< @todo review error code name */
  1035. - paCanNotReadFromAnOutputOnlyStream, /**< @todo review error code name */
  1036. - paCanNotWriteToAnInputOnlyStream, /**< @todo review error code name */
  1037. - paIncompatibleStreamHostApi,
  1038. - paBadBufferPtr
  1039. -} PaErrorCode;
  1040. -
  1041. -
  1042. -/** Translate the supplied PortAudio error code into a human readable
  1043. - message.
  1044. -*/
  1045. -const char *Pa_GetErrorText( PaError errorCode );
  1046. -
  1047. -
  1048. -/** Library initialization function - call this before using PortAudio.
  1049. - This function initialises internal data structures and prepares underlying
  1050. - host APIs for use. This function MUST be called before using any other
  1051. - PortAudio API functions.
  1052. -
  1053. - If Pa_Initialize() is called multiple times, each successful
  1054. - call must be matched with a corresponding call to Pa_Terminate().
  1055. - Pairs of calls to Pa_Initialize()/Pa_Terminate() may overlap, and are not
  1056. - required to be fully nested.
  1057. -
  1058. - Note that if Pa_Initialize() returns an error code, Pa_Terminate() should
  1059. - NOT be called.
  1060. -
  1061. - @return paNoError if successful, otherwise an error code indicating the cause
  1062. - of failure.
  1063. -
  1064. - @see Pa_Terminate
  1065. -*/
  1066. -PaError Pa_Initialize( void );
  1067. -
  1068. -
  1069. -/** Library termination function - call this when finished using PortAudio.
  1070. - This function deallocates all resources allocated by PortAudio since it was
  1071. - initializied by a call to Pa_Initialize(). In cases where Pa_Initialise() has
  1072. - been called multiple times, each call must be matched with a corresponding call
  1073. - to Pa_Terminate(). The final matching call to Pa_Terminate() will automatically
  1074. - close any PortAudio streams that are still open.
  1075. -
  1076. - Pa_Terminate() MUST be called before exiting a program which uses PortAudio.
  1077. - Failure to do so may result in serious resource leaks, such as audio devices
  1078. - not being available until the next reboot.
  1079. -
  1080. - @return paNoError if successful, otherwise an error code indicating the cause
  1081. - of failure.
  1082. -
  1083. - @see Pa_Initialize
  1084. -*/
  1085. -PaError Pa_Terminate( void );
  1086. -
  1087. -
  1088. -
  1089. -/** The type used to refer to audio devices. Values of this type usually
  1090. - range from 0 to (Pa_DeviceCount-1), and may also take on the PaNoDevice
  1091. - and paUseHostApiSpecificDeviceSpecification values.
  1092. -
  1093. - @see Pa_DeviceCount, paNoDevice, paUseHostApiSpecificDeviceSpecification
  1094. -*/
  1095. -typedef int PaDeviceIndex;
  1096. -
  1097. -
  1098. -/** A special PaDeviceIndex value indicating that no device is available,
  1099. - or should be used.
  1100. -
  1101. - @see PaDeviceIndex
  1102. -*/
  1103. -#define paNoDevice ((PaDeviceIndex)-1)
  1104. -
  1105. -
  1106. -/** A special PaDeviceIndex value indicating that the device(s) to be used
  1107. - are specified in the host api specific stream info structure.
  1108. -
  1109. - @see PaDeviceIndex
  1110. -*/
  1111. -#define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
  1112. -
  1113. -
  1114. -/* Host API enumeration mechanism */
  1115. -
  1116. -/** The type used to enumerate to host APIs at runtime. Values of this type
  1117. - range from 0 to (Pa_GetHostApiCount()-1).
  1118. -
  1119. - @see Pa_GetHostApiCount
  1120. -*/
  1121. -typedef int PaHostApiIndex;
  1122. -
  1123. -
  1124. -/** Retrieve the number of available host APIs. Even if a host API is
  1125. - available it may have no devices available.
  1126. -
  1127. - @return A non-negative value indicating the number of available host APIs
  1128. - or, a PaErrorCode (which are always negative) if PortAudio is not initialized
  1129. - or an error is encountered.
  1130. -
  1131. - @see PaHostApiIndex
  1132. -*/
  1133. -PaHostApiIndex Pa_GetHostApiCount( void );
  1134. -
  1135. -
  1136. -/** Retrieve the index of the default host API. The default host API will be
  1137. - the lowest common denominator host API on the current platform and is
  1138. - unlikely to provide the best performance.
  1139. -
  1140. - @return A non-negative value ranging from 0 to (Pa_GetHostApiCount()-1)
  1141. - indicating the default host API index or, a PaErrorCode (which are always
  1142. - negative) if PortAudio is not initialized or an error is encountered.
  1143. -*/
  1144. -PaHostApiIndex Pa_GetDefaultHostApi( void );
  1145. -
  1146. -
  1147. -/** Unchanging unique identifiers for each supported host API. This type
  1148. - is used in the PaHostApiInfo structure. The values are guaranteed to be
  1149. - unique and to never change, thus allowing code to be written that
  1150. - conditionally uses host API specific extensions.
  1151. -
  1152. - New type ids will be allocated when support for a host API reaches
  1153. - "public alpha" status, prior to that developers should use the
  1154. - paInDevelopment type id.
  1155. -
  1156. - @see PaHostApiInfo
  1157. -*/
  1158. -typedef enum PaHostApiTypeId
  1159. -{
  1160. - paInDevelopment=0, /* use while developing support for a new host API */
  1161. - paDirectSound=1,
  1162. - paMME=2,
  1163. - paASIO=3,
  1164. - paSoundManager=4,
  1165. - paCoreAudio=5,
  1166. - paOSS=7,
  1167. - paALSA=8,
  1168. - paAL=9,
  1169. - paBeOS=10,
  1170. - paWDMKS=11,
  1171. - paJACK=12,
  1172. - paWASAPI=13,
  1173. - paAudioScienceHPI=14
  1174. -} PaHostApiTypeId;
  1175. -
  1176. -
  1177. -/** A structure containing information about a particular host API. */
  1178. -
  1179. -typedef struct PaHostApiInfo
  1180. -{
  1181. - /** this is struct version 1 */
  1182. - int structVersion;
  1183. - /** The well known unique identifier of this host API @see PaHostApiTypeId */
  1184. - PaHostApiTypeId type;
  1185. - /** A textual description of the host API for display on user interfaces. */
  1186. - const char *name;
  1187. -
  1188. - /** The number of devices belonging to this host API. This field may be
  1189. - used in conjunction with Pa_HostApiDeviceIndexToDeviceIndex() to enumerate
  1190. - all devices for this host API.
  1191. - @see Pa_HostApiDeviceIndexToDeviceIndex
  1192. - */
  1193. - int deviceCount;
  1194. -
  1195. - /** The default input device for this host API. The value will be a
  1196. - device index ranging from 0 to (Pa_GetDeviceCount()-1), or paNoDevice
  1197. - if no default input device is available.
  1198. - */
  1199. - PaDeviceIndex defaultInputDevice;
  1200. -
  1201. - /** The default output device for this host API. The value will be a
  1202. - device index ranging from 0 to (Pa_GetDeviceCount()-1), or paNoDevice
  1203. - if no default output device is available.
  1204. - */
  1205. - PaDeviceIndex defaultOutputDevice;
  1206. -
  1207. -} PaHostApiInfo;
  1208. -
  1209. -
  1210. -/** Retrieve a pointer to a structure containing information about a specific
  1211. - host Api.
  1212. -
  1213. - @param hostApi A valid host API index ranging from 0 to (Pa_GetHostApiCount()-1)
  1214. -
  1215. - @return A pointer to an immutable PaHostApiInfo structure describing
  1216. - a specific host API. If the hostApi parameter is out of range or an error
  1217. - is encountered, the function returns NULL.
  1218. -
  1219. - The returned structure is owned by the PortAudio implementation and must not
  1220. - be manipulated or freed. The pointer is only guaranteed to be valid between
  1221. - calls to Pa_Initialize() and Pa_Terminate().
  1222. -*/
  1223. -const PaHostApiInfo * Pa_GetHostApiInfo( PaHostApiIndex hostApi );
  1224. -
  1225. -
  1226. -/** Convert a static host API unique identifier, into a runtime
  1227. - host API index.
  1228. -
  1229. - @param type A unique host API identifier belonging to the PaHostApiTypeId
  1230. - enumeration.
  1231. -
  1232. - @return A valid PaHostApiIndex ranging from 0 to (Pa_GetHostApiCount()-1) or,
  1233. - a PaErrorCode (which are always negative) if PortAudio is not initialized
  1234. - or an error is encountered.
  1235. -
  1236. - The paHostApiNotFound error code indicates that the host API specified by the
  1237. - type parameter is not available.
  1238. -
  1239. - @see PaHostApiTypeId
  1240. -*/
  1241. -PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type );
  1242. -
  1243. -
  1244. -/** Convert a host-API-specific device index to standard PortAudio device index.
  1245. - This function may be used in conjunction with the deviceCount field of
  1246. - PaHostApiInfo to enumerate all devices for the specified host API.
  1247. -
  1248. - @param hostApi A valid host API index ranging from 0 to (Pa_GetHostApiCount()-1)
  1249. -
  1250. - @param hostApiDeviceIndex A valid per-host device index in the range
  1251. - 0 to (Pa_GetHostApiInfo(hostApi)->deviceCount-1)
  1252. -
  1253. - @return A non-negative PaDeviceIndex ranging from 0 to (Pa_GetDeviceCount()-1)
  1254. - or, a PaErrorCode (which are always negative) if PortAudio is not initialized
  1255. - or an error is encountered.
  1256. -
  1257. - A paInvalidHostApi error code indicates that the host API index specified by
  1258. - the hostApi parameter is out of range.
  1259. -
  1260. - A paInvalidDevice error code indicates that the hostApiDeviceIndex parameter
  1261. - is out of range.
  1262. -
  1263. - @see PaHostApiInfo
  1264. -*/
  1265. -PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex( PaHostApiIndex hostApi,
  1266. - int hostApiDeviceIndex );
  1267. -
  1268. -
  1269. -
  1270. -/** Structure used to return information about a host error condition.
  1271. -*/
  1272. -typedef struct PaHostErrorInfo{
  1273. - PaHostApiTypeId hostApiType; /**< the host API which returned the error code */
  1274. - long errorCode; /**< the error code returned */
  1275. - const char *errorText; /**< a textual description of the error if available, otherwise a zero-length string */
  1276. -}PaHostErrorInfo;
  1277. -
  1278. -
  1279. -/** Return information about the last host error encountered. The error
  1280. - information returned by Pa_GetLastHostErrorInfo() will never be modified
  1281. - asyncronously by errors occurring in other PortAudio owned threads
  1282. - (such as the thread that manages the stream callback.)
  1283. -
  1284. - This function is provided as a last resort, primarily to enhance debugging
  1285. - by providing clients with access to all available error information.
  1286. -
  1287. - @return A pointer to an immutable structure constaining information about
  1288. - the host error. The values in this structure will only be valid if a
  1289. - PortAudio function has previously returned the paUnanticipatedHostError
  1290. - error code.
  1291. -*/
  1292. -const PaHostErrorInfo* Pa_GetLastHostErrorInfo( void );
  1293. -
  1294. -
  1295. -
  1296. -/* Device enumeration and capabilities */
  1297. -
  1298. -/** Retrieve the number of available devices. The number of available devices
  1299. - may be zero.
  1300. -
  1301. - @return A non-negative value indicating the number of available devices or,
  1302. - a PaErrorCode (which are always negative) if PortAudio is not initialized
  1303. - or an error is encountered.
  1304. -*/
  1305. -PaDeviceIndex Pa_GetDeviceCount( void );
  1306. -
  1307. -
  1308. -/** Retrieve the index of the default input device. The result can be
  1309. - used in the inputDevice parameter to Pa_OpenStream().
  1310. -
  1311. - @return The default input device index for the default host API, or paNoDevice
  1312. - if no default input device is available or an error was encountered.
  1313. -*/
  1314. -PaDeviceIndex Pa_GetDefaultInputDevice( void );
  1315. -
  1316. -
  1317. -/** Retrieve the index of the default output device. The result can be
  1318. - used in the outputDevice parameter to Pa_OpenStream().
  1319. -
  1320. - @return The default output device index for the defualt host API, or paNoDevice
  1321. - if no default output device is available or an error was encountered.
  1322. -
  1323. - @note
  1324. - On the PC, the user can specify a default device by
  1325. - setting an environment variable. For example, to use device #1.
  1326. -<pre>
  1327. - set PA_RECOMMENDED_OUTPUT_DEVICE=1
  1328. -</pre>
  1329. - The user should first determine the available device ids by using
  1330. - the supplied application "pa_devs".
  1331. -*/
  1332. -PaDeviceIndex Pa_GetDefaultOutputDevice( void );
  1333. -
  1334. -
  1335. -/** The type used to represent monotonic time in seconds that can be used
  1336. - for syncronisation. The type is used for the outTime argument to the
  1337. - PaStreamCallback and as the result of Pa_GetStreamTime().
  1338. -
  1339. - @see PaStreamCallback, Pa_GetStreamTime
  1340. -*/
  1341. -typedef double PaTime;
  1342. -
  1343. -
  1344. -/** A type used to specify one or more sample formats. Each value indicates
  1345. - a possible format for sound data passed to and from the stream callback,
  1346. - Pa_ReadStream and Pa_WriteStream.
  1347. -
  1348. - The standard formats paFloat32, paInt16, paInt32, paInt24, paInt8
  1349. - and aUInt8 are usually implemented by all implementations.
  1350. -
  1351. - The floating point representation (paFloat32) uses +1.0 and -1.0 as the
  1352. - maximum and minimum respectively.
  1353. -
  1354. - paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
  1355. -
  1356. - The paNonInterleaved flag indicates that a multichannel buffer is passed
  1357. - as a set of non-interleaved pointers.
  1358. -
  1359. - @see Pa_OpenStream, Pa_OpenDefaultStream, PaDeviceInfo
  1360. - @see paFloat32, paInt16, paInt32, paInt24, paInt8
  1361. - @see paUInt8, paCustomFormat, paNonInterleaved
  1362. -*/
  1363. -typedef unsigned long PaSampleFormat;
  1364. -
  1365. -
  1366. -#define paFloat32 ((PaSampleFormat) 0x00000001) /**< @see PaSampleFormat */
  1367. -#define paInt32 ((PaSampleFormat) 0x00000002) /**< @see PaSampleFormat */
  1368. -#define paInt24 ((PaSampleFormat) 0x00000004) /**< Packed 24 bit format. @see PaSampleFormat */
  1369. -#define paInt16 ((PaSampleFormat) 0x00000008) /**< @see PaSampleFormat */
  1370. -#define paInt8 ((PaSampleFormat) 0x00000010) /**< @see PaSampleFormat */
  1371. -#define paUInt8 ((PaSampleFormat) 0x00000020) /**< @see PaSampleFormat */
  1372. -#define paCustomFormat ((PaSampleFormat) 0x00010000)/**< @see PaSampleFormat */
  1373. -
  1374. -#define paNonInterleaved ((PaSampleFormat) 0x80000000)
  1375. -
  1376. -/** A structure providing information and capabilities of PortAudio devices.
  1377. - Devices may support input, output or both input and output.
  1378. -*/
  1379. -typedef struct PaDeviceInfo
  1380. -{
  1381. - int structVersion; /* this is struct version 2 */
  1382. - const char *name;
  1383. - PaHostApiIndex hostApi; /* note this is a host API index, not a type id*/
  1384. -
  1385. - int maxInputChannels;
  1386. - int maxOutputChannels;
  1387. -
  1388. - /* Default latency values for interactive performance. */
  1389. - PaTime defaultLowInputLatency;
  1390. - PaTime defaultLowOutputLatency;
  1391. - /* Default latency values for robust non-interactive applications (eg. playing sound files). */
  1392. - PaTime defaultHighInputLatency;
  1393. - PaTime defaultHighOutputLatency;
  1394. -
  1395. - double defaultSampleRate;
  1396. -} PaDeviceInfo;
  1397. -
  1398. -
  1399. -/** Retrieve a pointer to a PaDeviceInfo structure containing information
  1400. - about the specified device.
  1401. - @return A pointer to an immutable PaDeviceInfo structure. If the device
  1402. - parameter is out of range the function returns NULL.
  1403. -
  1404. - @param device A valid device index in the range 0 to (Pa_GetDeviceCount()-1)
  1405. -
  1406. - @note PortAudio manages the memory referenced by the returned pointer,
  1407. - the client must not manipulate or free the memory. The pointer is only
  1408. - guaranteed to be valid between calls to Pa_Initialize() and Pa_Terminate().
  1409. -
  1410. - @see PaDeviceInfo, PaDeviceIndex
  1411. -*/
  1412. -const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceIndex device );
  1413. -
  1414. -
  1415. -/** Parameters for one direction (input or output) of a stream.
  1416. -*/
  1417. -typedef struct PaStreamParameters
  1418. -{
  1419. - /** A valid device index in the range 0 to (Pa_GetDeviceCount()-1)
  1420. - specifying the device to be used or the special constant
  1421. - paUseHostApiSpecificDeviceSpecification which indicates that the actual
  1422. - device(s) to use are specified in hostApiSpecificStreamInfo.
  1423. - This field must not be set to paNoDevice.
  1424. - */
  1425. - PaDeviceIndex device;
  1426. -
  1427. - /** The number of channels of sound to be delivered to the
  1428. - stream callback or accessed by Pa_ReadStream() or Pa_WriteStream().
  1429. - It can range from 1 to the value of maxInputChannels in the
  1430. - PaDeviceInfo record for the device specified by the device parameter.
  1431. - */
  1432. - int channelCount;
  1433. -
  1434. - /** The sample format of the buffer provided to the stream callback,
  1435. - a_ReadStream() or Pa_WriteStream(). It may be any of the formats described
  1436. - by the PaSampleFormat enumeration.
  1437. - */
  1438. - PaSampleFormat sampleFormat;
  1439. -
  1440. - /** The desired latency in seconds. Where practical, implementations should
  1441. - configure their latency based on these parameters, otherwise they may
  1442. - choose the closest viable latency instead. Unless the suggested latency
  1443. - is greater than the absolute upper limit for the device implementations
  1444. - should round the suggestedLatency up to the next practial value - ie to
  1445. - provide an equal or higher latency than suggestedLatency wherever possibe.
  1446. - Actual latency values for an open stream may be retrieved using the
  1447. - inputLatency and outputLatency fields of the PaStreamInfo structure
  1448. - returned by Pa_GetStreamInfo().
  1449. - @see default*Latency in PaDeviceInfo, *Latency in PaStreamInfo
  1450. - */
  1451. - PaTime suggestedLatency;
  1452. -
  1453. - /** An optional pointer to a host api specific data structure
  1454. - containing additional information for device setup and/or stream processing.
  1455. - hostApiSpecificStreamInfo is never required for correct operation,
  1456. - if not used it should be set to NULL.
  1457. - */
  1458. - void *hostApiSpecificStreamInfo;
  1459. -
  1460. -} PaStreamParameters;
  1461. -
  1462. -
  1463. -/** Return code for Pa_IsFormatSupported indicating success. */
  1464. -#define paFormatIsSupported (0)
  1465. -
  1466. -/** Determine whether it would be possible to open a stream with the specified
  1467. - parameters.
  1468. -
  1469. - @param inputParameters A structure that describes the input parameters used to
  1470. - open a stream. The suggestedLatency field is ignored. See PaStreamParameters
  1471. - for a description of these parameters. inputParameters must be NULL for
  1472. - output-only streams.
  1473. -
  1474. - @param outputParameters A structure that describes the output parameters used
  1475. - to open a stream. The suggestedLatency field is ignored. See PaStreamParameters
  1476. - for a description of these parameters. outputParameters must be NULL for
  1477. - input-only streams.
  1478. -
  1479. - @param sampleRate The required sampleRate. For full-duplex streams it is the
  1480. - sample rate for both input and output
  1481. -
  1482. - @return Returns 0 if the format is supported, and an error code indicating why
  1483. - the format is not supported otherwise. The constant paFormatIsSupported is
  1484. - provided to compare with the return value for success.
  1485. -
  1486. - @see paFormatIsSupported, PaStreamParameters
  1487. -*/
  1488. -PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
  1489. - const PaStreamParameters *outputParameters,
  1490. - double sampleRate );
  1491. -
  1492. -
  1493. -
  1494. -/* Streaming types and functions */
  1495. -
  1496. -
  1497. -/**
  1498. - A single PaStream can provide multiple channels of real-time
  1499. - streaming audio input and output to a client application. A stream
  1500. - provides access to audio hardware represented by one or more
  1501. - PaDevices. Depending on the underlying Host API, it may be possible
  1502. - to open multiple streams using the same device, however this behavior
  1503. - is implementation defined. Portable applications should assume that
  1504. - a PaDevice may be simultaneously used by at most one PaStream.
  1505. -
  1506. - Pointers to PaStream objects are passed between PortAudio functions that
  1507. - operate on streams.
  1508. -
  1509. - @see Pa_OpenStream, Pa_OpenDefaultStream, Pa_OpenDefaultStream, Pa_CloseStream,
  1510. - Pa_StartStream, Pa_StopStream, Pa_AbortStream, Pa_IsStreamActive,
  1511. - Pa_GetStreamTime, Pa_GetStreamCpuLoad
  1512. -
  1513. -*/
  1514. -typedef void PaStream;
  1515. -
  1516. -
  1517. -/** Can be passed as the framesPerBuffer parameter to Pa_OpenStream()
  1518. - or Pa_OpenDefaultStream() to indicate that the stream callback will
  1519. - accept buffers of any size.
  1520. -*/
  1521. -#define paFramesPerBufferUnspecified (0)
  1522. -
  1523. -
  1524. -/** Flags used to control the behavior of a stream. They are passed as
  1525. - parameters to Pa_OpenStream or Pa_OpenDefaultStream. Multiple flags may be
  1526. - ORed together.
  1527. -
  1528. - @see Pa_OpenStream, Pa_OpenDefaultStream
  1529. - @see paNoFlag, paClipOff, paDitherOff, paNeverDropInput,
  1530. - paPrimeOutputBuffersUsingStreamCallback, paPlatformSpecificFlags
  1531. -*/
  1532. -typedef unsigned long PaStreamFlags;
  1533. -
  1534. -/** @see PaStreamFlags */
  1535. -#define paNoFlag ((PaStreamFlags) 0)
  1536. -
  1537. -/** Disable default clipping of out of range samples.
  1538. - @see PaStreamFlags
  1539. -*/
  1540. -#define paClipOff ((PaStreamFlags) 0x00000001)
  1541. -
  1542. -/** Disable default dithering.
  1543. - @see PaStreamFlags
  1544. -*/
  1545. -#define paDitherOff ((PaStreamFlags) 0x00000002)
  1546. -
  1547. -/** Flag requests that where possible a full duplex stream will not discard
  1548. - overflowed input samples without calling the stream callback. This flag is
  1549. - only valid for full duplex callback streams and only when used in combination
  1550. - with the paFramesPerBufferUnspecified (0) framesPerBuffer parameter. Using
  1551. - this flag incorrectly results in a paInvalidFlag error being returned from
  1552. - Pa_OpenStream and Pa_OpenDefaultStream.
  1553. -
  1554. - @see PaStreamFlags, paFramesPerBufferUnspecified
  1555. -*/
  1556. -#define paNeverDropInput ((PaStreamFlags) 0x00000004)
  1557. -
  1558. -/** Call the stream callback to fill initial output buffers, rather than the
  1559. - default behavior of priming the buffers with zeros (silence). This flag has
  1560. - no effect for input-only and blocking read/write streams.
  1561. -
  1562. - @see PaStreamFlags
  1563. -*/
  1564. -#define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
  1565. -
  1566. -/** A mask specifying the platform specific bits.
  1567. - @see PaStreamFlags
  1568. -*/
  1569. -#define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
  1570. -
  1571. -/**
  1572. - Timing information for the buffers passed to the stream callback.
  1573. -*/
  1574. -typedef struct PaStreamCallbackTimeInfo{
  1575. - PaTime inputBufferAdcTime;
  1576. - PaTime currentTime;
  1577. - PaTime outputBufferDacTime;
  1578. -} PaStreamCallbackTimeInfo;
  1579. -
  1580. -
  1581. -/**
  1582. - Flag bit constants for the statusFlags to PaStreamCallback.
  1583. -
  1584. - @see paInputUnderflow, paInputOverflow, paOutputUnderflow, paOutputOverflow,
  1585. - paPrimingOutput
  1586. -*/
  1587. -typedef unsigned long PaStreamCallbackFlags;
  1588. -
  1589. -/** In a stream opened with paFramesPerBufferUnspecified, indicates that
  1590. - input data is all silence (zeros) because no real data is available. In a
  1591. - stream opened without paFramesPerBufferUnspecified, it indicates that one or
  1592. - more zero samples have been inserted into the input buffer to compensate
  1593. - for an input underflow.
  1594. - @see PaStreamCallbackFlags
  1595. -*/
  1596. -#define paInputUnderflow ((PaStreamCallbackFlags) 0x00000001)
  1597. -
  1598. -/** In a stream opened with paFramesPerBufferUnspecified, indicates that data
  1599. - prior to the first sample of the input buffer was discarded due to an
  1600. - overflow, possibly because the stream callback is using too much CPU time.
  1601. - Otherwise indicates that data prior to one or more samples in the
  1602. - input buffer was discarded.
  1603. - @see PaStreamCallbackFlags
  1604. -*/
  1605. -#define paInputOverflow ((PaStreamCallbackFlags) 0x00000002)
  1606. -
  1607. -/** Indicates that output data (or a gap) was inserted, possibly because the
  1608. - stream callback is using too much CPU time.
  1609. - @see PaStreamCallbackFlags
  1610. -*/
  1611. -#define paOutputUnderflow ((PaStreamCallbackFlags) 0x00000004)
  1612. -
  1613. -/** Indicates that output data will be discarded because no room is available.
  1614. - @see PaStreamCallbackFlags
  1615. -*/
  1616. -#define paOutputOverflow ((PaStreamCallbackFlags) 0x00000008)
  1617. -
  1618. -/** Some of all of the output data will be used to prime the stream, input
  1619. - data may be zero.
  1620. - @see PaStreamCallbackFlags
  1621. -*/
  1622. -#define paPrimingOutput ((PaStreamCallbackFlags) 0x00000010)
  1623. -
  1624. -/**
  1625. - Allowable return values for the PaStreamCallback.
  1626. - @see PaStreamCallback
  1627. -*/
  1628. -typedef enum PaStreamCallbackResult
  1629. -{
  1630. - paContinue=0,
  1631. - paComplete=1,
  1632. - paAbort=2
  1633. -} PaStreamCallbackResult;
  1634. -
  1635. -
  1636. -/**
  1637. - Functions of type PaStreamCallback are implemented by PortAudio clients.
  1638. - They consume, process or generate audio in response to requests from an
  1639. - active PortAudio stream.
  1640. -
  1641. - @param input and @param output are arrays of interleaved samples,
  1642. - the format, packing and number of channels used by the buffers are
  1643. - determined by parameters to Pa_OpenStream().
  1644. -
  1645. - @param frameCount The number of sample frames to be processed by
  1646. - the stream callback.
  1647. -
  1648. - @param timeInfo The time in seconds when the first sample of the input
  1649. - buffer was received at the audio input, the time in seconds when the first
  1650. - sample of the output buffer will begin being played at the audio output, and
  1651. - the time in seconds when the stream callback was called.
  1652. - See also Pa_GetStreamTime()
  1653. -
  1654. - @param statusFlags Flags indicating whether input and/or output buffers
  1655. - have been inserted or will be dropped to overcome underflow or overflow
  1656. - conditions.
  1657. -
  1658. - @param userData The value of a user supplied pointer passed to
  1659. - Pa_OpenStream() intended for storing synthesis data etc.
  1660. -
  1661. - @return
  1662. - The stream callback should return one of the values in the
  1663. - PaStreamCallbackResult enumeration. To ensure that the callback continues
  1664. - to be called, it should return paContinue (0). Either paComplete or paAbort
  1665. - can be returned to finish stream processing, after either of these values is
  1666. - returned the callback will not be called again. If paAbort is returned the
  1667. - stream will finish as soon as possible. If paComplete is returned, the stream
  1668. - will continue until all buffers generated by the callback have been played.
  1669. - This may be useful in applications such as soundfile players where a specific
  1670. - duration of output is required. However, it is not necessary to utilise this
  1671. - mechanism as Pa_StopStream(), Pa_AbortStream() or Pa_CloseStream() can also
  1672. - be used to stop the stream. The callback must always fill the entire output
  1673. - buffer irrespective of its return value.
  1674. -
  1675. - @see Pa_OpenStream, Pa_OpenDefaultStream
  1676. -
  1677. - @note With the exception of Pa_GetStreamCpuLoad() it is not permissable to call
  1678. - PortAudio API functions from within the stream callback.
  1679. -*/
  1680. -typedef int PaStreamCallback(
  1681. - const void *input, void *output,
  1682. - unsigned long frameCount,
  1683. - const PaStreamCallbackTimeInfo* timeInfo,
  1684. - PaStreamCallbackFlags statusFlags,
  1685. - void *userData );
  1686. -
  1687. -
  1688. -/** Opens a stream for either input, output or both.
  1689. -
  1690. - @param stream The address of a PaStream pointer which will receive
  1691. - a pointer to the newly opened stream.
  1692. -
  1693. - @param inputParameters A structure that describes the input parameters used by
  1694. - the opened stream. See PaStreamParameters for a description of these parameters.
  1695. - inputParameters must be NULL for output-only streams.
  1696. -
  1697. - @param outputParameters A structure that describes the output parameters used by
  1698. - the opened stream. See PaStreamParameters for a description of these parameters.
  1699. - outputParameters must be NULL for input-only streams.
  1700. -
  1701. - @param sampleRate The desired sampleRate. For full-duplex streams it is the
  1702. - sample rate for both input and output
  1703. -
  1704. - @param framesPerBuffer The number of frames passed to the stream callback
  1705. - function, or the preferred block granularity for a blocking read/write stream.
  1706. - The special value paFramesPerBufferUnspecified (0) may be used to request that
  1707. - the stream callback will recieve an optimal (and possibly varying) number of
  1708. - frames based on host requirements and the requested latency settings.
  1709. - Note: With some host APIs, the use of non-zero framesPerBuffer for a callback
  1710. - stream may introduce an additional layer of buffering which could introduce
  1711. - additional latency. PortAudio guarantees that the additional latency
  1712. - will be kept to the theoretical minimum however, it is strongly recommended
  1713. - that a non-zero framesPerBuffer value only be used when your algorithm
  1714. - requires a fixed number of frames per stream callback.
  1715. -
  1716. - @param streamFlags Flags which modify the behaviour of the streaming process.
  1717. - This parameter may contain a combination of flags ORed together. Some flags may
  1718. - only be relevant to certain buffer formats.
  1719. -
  1720. - @param streamCallback A pointer to a client supplied function that is responsible
  1721. - for processing and filling input and output buffers. If this parameter is NULL
  1722. - the stream will be opened in 'blocking read/write' mode. In blocking mode,
  1723. - the client can receive sample data using Pa_ReadStream and write sample data
  1724. - using Pa_WriteStream, the number of samples that may be read or written
  1725. - without blocking is returned by Pa_GetStreamReadAvailable and
  1726. - Pa_GetStreamWriteAvailable respectively.
  1727. -
  1728. - @param userData A client supplied pointer which is passed to the stream callback
  1729. - function. It could for example, contain a pointer to instance data necessary
  1730. - for processing the audio buffers. This parameter is ignored if streamCallback
  1731. - is NULL.
  1732. -
  1733. - @return
  1734. - Upon success Pa_OpenStream() returns paNoError and places a pointer to a
  1735. - valid PaStream in the stream argument. The stream is inactive (stopped).
  1736. - If a call to Pa_OpenStream() fails, a non-zero error code is returned (see
  1737. - PaError for possible error codes) and the value of stream is invalid.
  1738. -
  1739. - @see PaStreamParameters, PaStreamCallback, Pa_ReadStream, Pa_WriteStream,
  1740. - Pa_GetStreamReadAvailable, Pa_GetStreamWriteAvailable
  1741. -*/
  1742. -PaError Pa_OpenStream( PaStream** stream,
  1743. - const PaStreamParameters *inputParameters,
  1744. - const PaStreamParameters *outputParameters,
  1745. - double sampleRate,
  1746. - unsigned long framesPerBuffer,
  1747. - PaStreamFlags streamFlags,
  1748. - PaStreamCallback *streamCallback,
  1749. - void *userData );
  1750. -
  1751. -
  1752. -/** A simplified version of Pa_OpenStream() that opens the default input
  1753. - and/or output devices.
  1754. -
  1755. - @param stream The address of a PaStream pointer which will receive
  1756. - a pointer to the newly opened stream.
  1757. -
  1758. - @param numInputChannels The number of channels of sound that will be supplied
  1759. - to the stream callback or returned by Pa_ReadStream. It can range from 1 to
  1760. - the value of maxInputChannels in the PaDeviceInfo record for the default input
  1761. - device. If 0 the stream is opened as an output-only stream.
  1762. -
  1763. - @param numOutputChannels The number of channels of sound to be delivered to the
  1764. - stream callback or passed to Pa_WriteStream. It can range from 1 to the value
  1765. - of maxOutputChannels in the PaDeviceInfo record for the default output dvice.
  1766. - If 0 the stream is opened as an output-only stream.
  1767. -
  1768. - @param sampleFormat The sample format of both the input and output buffers
  1769. - provided to the callback or passed to and from Pa_ReadStream and Pa_WriteStream.
  1770. - sampleFormat may be any of the formats described by the PaSampleFormat
  1771. - enumeration.
  1772. -
  1773. - @param sampleRate Same as Pa_OpenStream parameter of the same name.
  1774. - @param framesPerBuffer Same as Pa_OpenStream parameter of the same name.
  1775. - @param streamCallback Same as Pa_OpenStream parameter of the same name.
  1776. - @param userData Same as Pa_OpenStream parameter of the same name.
  1777. -
  1778. - @return As for Pa_OpenStream
  1779. -
  1780. - @see Pa_OpenStream, PaStreamCallback
  1781. -*/
  1782. -PaError Pa_OpenDefaultStream( PaStream** stream,
  1783. - int numInputChannels,
  1784. - int numOutputChannels,
  1785. - PaSampleFormat sampleFormat,
  1786. - double sampleRate,
  1787. - unsigned long framesPerBuffer,
  1788. - PaStreamCallback *streamCallback,
  1789. - void *userData );
  1790. -
  1791. -
  1792. -/** Closes an audio stream. If the audio stream is active it
  1793. - discards any pending buffers as if Pa_AbortStream() had been called.
  1794. -*/
  1795. -PaError Pa_CloseStream( PaStream *stream );
  1796. -
  1797. -
  1798. -/** Functions of type PaStreamFinishedCallback are implemented by PortAudio
  1799. - clients. They can be registered with a stream using the Pa_SetStreamFinishedCallback
  1800. - function. Once registered they are called when the stream becomes inactive
  1801. - (ie once a call to Pa_StopStream() will not block).
  1802. - A stream will become inactive after the stream callback returns non-zero,
  1803. - or when Pa_StopStream or Pa_AbortStream is called. For a stream providing audio
  1804. - output, if the stream callback returns paComplete, or Pa_StopStream is called,
  1805. - the stream finished callback will not be called until all generated sample data
  1806. - has been played.
  1807. -
  1808. - @param userData The userData parameter supplied to Pa_OpenStream()
  1809. -
  1810. - @see Pa_SetStreamFinishedCallback
  1811. -*/
  1812. -typedef void PaStreamFinishedCallback( void *userData );
  1813. -
  1814. -
  1815. -/** Register a stream finished callback function which will be called when the
  1816. - stream becomes inactive. See the description of PaStreamFinishedCallback for
  1817. - further details about when the callback will be called.
  1818. -
  1819. - @param stream a pointer to a PaStream that is in the stopped state - if the
  1820. - stream is not stopped, the stream's finished callback will remain unchanged
  1821. - and an error code will be returned.
  1822. -
  1823. - @param streamFinishedCallback a pointer to a function with the same signature
  1824. - as PaStreamFinishedCallback, that will be called when the stream becomes
  1825. - inactive. Passing NULL for this parameter will un-register a previously
  1826. - registered stream finished callback function.
  1827. -
  1828. - @return on success returns paNoError, otherwise an error code indicating the cause
  1829. - of the error.
  1830. -
  1831. - @see PaStreamFinishedCallback
  1832. -*/
  1833. -PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
  1834. -
  1835. -
  1836. -/** Commences audio processing.
  1837. -*/
  1838. -PaError Pa_StartStream( PaStream *stream );
  1839. -
  1840. -
  1841. -/** Terminates audio processing. It waits until all pending
  1842. - audio buffers have been played before it returns.
  1843. -*/
  1844. -PaError Pa_StopStream( PaStream *stream );
  1845. -
  1846. -
  1847. -/** Terminates audio processing immediately without waiting for pending
  1848. - buffers to complete.
  1849. -*/
  1850. -PaError Pa_AbortStream( PaStream *stream );
  1851. -
  1852. -
  1853. -/** Determine whether the stream is stopped.
  1854. - A stream is considered to be stopped prior to a successful call to
  1855. - Pa_StartStream and after a successful call to Pa_StopStream or Pa_AbortStream.
  1856. - If a stream callback returns a value other than paContinue the stream is NOT
  1857. - considered to be stopped.
  1858. -
  1859. - @return Returns one (1) when the stream is stopped, zero (0) when
  1860. - the stream is running or, a PaErrorCode (which are always negative) if
  1861. - PortAudio is not initialized or an error is encountered.
  1862. -
  1863. - @see Pa_StopStream, Pa_AbortStream, Pa_IsStreamActive
  1864. -*/
  1865. -PaError Pa_IsStreamStopped( PaStream *stream );
  1866. -
  1867. -
  1868. -/** Determine whether the stream is active.
  1869. - A stream is active after a successful call to Pa_StartStream(), until it
  1870. - becomes inactive either as a result of a call to Pa_StopStream() or
  1871. - Pa_AbortStream(), or as a result of a return value other than paContinue from
  1872. - the stream callback. In the latter case, the stream is considered inactive
  1873. - after the last buffer has finished playing.
  1874. -
  1875. - @return Returns one (1) when the stream is active (ie playing or recording
  1876. - audio), zero (0) when not playing or, a PaErrorCode (which are always negative)
  1877. - if PortAudio is not initialized or an error is encountered.
  1878. -
  1879. - @see Pa_StopStream, Pa_AbortStream, Pa_IsStreamStopped
  1880. -*/
  1881. -PaError Pa_IsStreamActive( PaStream *stream );
  1882. -
  1883. -
  1884. -
  1885. -/** A structure containing unchanging information about an open stream.
  1886. - @see Pa_GetStreamInfo
  1887. -*/
  1888. -
  1889. -typedef struct PaStreamInfo
  1890. -{
  1891. - /** this is struct version 1 */
  1892. - int structVersion;
  1893. -
  1894. - /** The input latency of the stream in seconds. This value provides the most
  1895. - accurate estimate of input latency available to the implementation. It may
  1896. - differ significantly from the suggestedLatency value passed to Pa_OpenStream().
  1897. - The value of this field will be zero (0.) for output-only streams.
  1898. - @see PaTime
  1899. - */
  1900. - PaTime inputLatency;
  1901. -
  1902. - /** The output latency of the stream in seconds. This value provides the most
  1903. - accurate estimate of output latency available to the implementation. It may
  1904. - differ significantly from the suggestedLatency value passed to Pa_OpenStream().
  1905. - The value of this field will be zero (0.) for input-only streams.
  1906. - @see PaTime
  1907. - */
  1908. - PaTime outputLatency;
  1909. -
  1910. - /** The sample rate of the stream in Hertz (samples per second). In cases
  1911. - where the hardware sample rate is inaccurate and PortAudio is aware of it,
  1912. - the value of this field may be different from the sampleRate parameter
  1913. - passed to Pa_OpenStream(). If information about the actual hardware sample
  1914. - rate is not available, this field will have the same value as the sampleRate
  1915. - parameter passed to Pa_OpenStream().
  1916. - */
  1917. - double sampleRate;
  1918. -
  1919. -} PaStreamInfo;
  1920. -
  1921. -
  1922. -/** Retrieve a pointer to a PaStreamInfo structure containing information
  1923. - about the specified stream.
  1924. - @return A pointer to an immutable PaStreamInfo structure. If the stream
  1925. - parameter invalid, or an error is encountered, the function returns NULL.
  1926. -
  1927. - @param stream A pointer to an open stream previously created with Pa_OpenStream.
  1928. -
  1929. - @note PortAudio manages the memory referenced by the returned pointer,
  1930. - the client must not manipulate or free the memory. The pointer is only
  1931. - guaranteed to be valid until the specified stream is closed.
  1932. -
  1933. - @see PaStreamInfo
  1934. -*/
  1935. -const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
  1936. -
  1937. -
  1938. -/** Determine the current time for the stream according to the same clock used
  1939. - to generate buffer timestamps. This time may be used for syncronising other
  1940. - events to the audio stream, for example synchronizing audio to MIDI.
  1941. -
  1942. - @return The stream's current time in seconds, or 0 if an error occurred.
  1943. -
  1944. - @see PaTime, PaStreamCallback
  1945. -*/
  1946. -PaTime Pa_GetStreamTime( PaStream *stream );
  1947. -
  1948. -
  1949. -/** Retrieve CPU usage information for the specified stream.
  1950. - The "CPU Load" is a fraction of total CPU time consumed by a callback stream's
  1951. - audio processing routines including, but not limited to the client supplied
  1952. - stream callback. This function does not work with blocking read/write streams.
  1953. -
  1954. - This function may be called from the stream callback function or the
  1955. - application.
  1956. -
  1957. - @return
  1958. - A floating point value, typically between 0.0 and 1.0, where 1.0 indicates
  1959. - that the stream callback is consuming the maximum number of CPU cycles possible
  1960. - to maintain real-time operation. A value of 0.5 would imply that PortAudio and
  1961. - the stream callback was consuming roughly 50% of the available CPU time. The
  1962. - return value may exceed 1.0. A value of 0.0 will always be returned for a
  1963. - blocking read/write stream, or if an error occurrs.
  1964. -*/
  1965. -double Pa_GetStreamCpuLoad( PaStream* stream );
  1966. -
  1967. -
  1968. -/** Read samples from an input stream. The function doesn't return until
  1969. - the entire buffer has been filled - this may involve waiting for the operating
  1970. - system to supply the data.
  1971. -
  1972. - @param stream A pointer to an open stream previously created with Pa_OpenStream.
  1973. -
  1974. - @param buffer A pointer to a buffer of sample frames. The buffer contains
  1975. - samples in the format specified by the inputParameters->sampleFormat field
  1976. - used to open the stream, and the number of channels specified by
  1977. - inputParameters->numChannels. If non-interleaved samples were requested,
  1978. - buffer is a pointer to the first element of an array of non-interleaved
  1979. - buffer pointers, one for each channel.
  1980. -
  1981. - @param frames The number of frames to be read into buffer. This parameter
  1982. - is not constrained to a specific range, however high performance applications
  1983. - will want to match this parameter to the framesPerBuffer parameter used
  1984. - when opening the stream.
  1985. -
  1986. - @return On success PaNoError will be returned, or PaInputOverflowed if input
  1987. - data was discarded by PortAudio after the previous call and before this call.
  1988. -*/
  1989. -PaError Pa_ReadStream( PaStream* stream,
  1990. - void *buffer,
  1991. - unsigned long frames );
  1992. -
  1993. -
  1994. -/** Write samples to an output stream. This function doesn't return until the
  1995. - entire buffer has been consumed - this may involve waiting for the operating
  1996. - system to consume the data.
  1997. -
  1998. - @param stream A pointer to an open stream previously created with Pa_OpenStream.
  1999. -
  2000. - @param buffer A pointer to a buffer of sample frames. The buffer contains
  2001. - samples in the format specified by the outputParameters->sampleFormat field
  2002. - used to open the stream, and the number of channels specified by
  2003. - outputParameters->numChannels. If non-interleaved samples were requested,
  2004. - buffer is a pointer to the first element of an array of non-interleaved
  2005. - buffer pointers, one for each channel.
  2006. -
  2007. - @param frames The number of frames to be written from buffer. This parameter
  2008. - is not constrained to a specific range, however high performance applications
  2009. - will want to match this parameter to the framesPerBuffer parameter used
  2010. - when opening the stream.
  2011. -
  2012. - @return On success PaNoError will be returned, or paOutputUnderflowed if
  2013. - additional output data was inserted after the previous call and before this
  2014. - call.
  2015. -*/
  2016. -PaError Pa_WriteStream( PaStream* stream,
  2017. - const void *buffer,
  2018. - unsigned long frames );
  2019. -
  2020. -
  2021. -/** Retrieve the number of frames that can be read from the stream without
  2022. - waiting.
  2023. -
  2024. - @return Returns a non-negative value representing the maximum number of frames
  2025. - that can be read from the stream without blocking or busy waiting or, a
  2026. - PaErrorCode (which are always negative) if PortAudio is not initialized or an
  2027. - error is encountered.
  2028. -*/
  2029. -signed long Pa_GetStreamReadAvailable( PaStream* stream );
  2030. -
  2031. -
  2032. -/** Retrieve the number of frames that can be written to the stream without
  2033. - waiting.
  2034. -
  2035. - @return Returns a non-negative value representing the maximum number of frames
  2036. - that can be written to the stream without blocking or busy waiting or, a
  2037. - PaErrorCode (which are always negative) if PortAudio is not initialized or an
  2038. - error is encountered.
  2039. -*/
  2040. -signed long Pa_GetStreamWriteAvailable( PaStream* stream );
  2041. -
  2042. -
  2043. -/* Miscellaneous utilities */
  2044. -
  2045. -
  2046. -/** Retrieve the size of a given sample format in bytes.
  2047. -
  2048. - @return The size in bytes of a single sample in the specified format,
  2049. - or paSampleFormatNotSupported if the format is not supported.
  2050. -*/
  2051. -PaError Pa_GetSampleSize( PaSampleFormat format );
  2052. -
  2053. -
  2054. -/** Put the caller to sleep for at least 'msec' milliseconds. This function is
  2055. - provided only as a convenience for authors of portable code (such as the tests
  2056. - and examples in the PortAudio distribution.)
  2057. -
  2058. - The function may sleep longer than requested so don't rely on this for accurate
  2059. - musical timing.
  2060. -*/
  2061. -void Pa_Sleep( long msec );
  2062. -
  2063. -
  2064. -
  2065. -#ifdef __cplusplus
  2066. -}
  2067. -#endif /* __cplusplus */
  2068. -#endif /* PORTAUDIO_H */
  2069. --- a/src/wave.cpp
  2070. +++ b/src/wave.cpp
  2071. @@ -31,7 +31,10 @@
  2072. #include <sys/time.h>
  2073. #include <time.h>
  2074. -#include "portaudio.h"
  2075. +#ifdef USE_PORTAUDIO
  2076. +#include <portaudio.h>
  2077. +#endif
  2078. +
  2079. #ifdef PLATFORM_WINDOWS
  2080. #include <windows.h>
  2081. #else
  2082. --- a/src/wavegen.cpp
  2083. +++ b/src/wavegen.cpp
  2084. @@ -40,7 +40,7 @@
  2085. #endif
  2086. #ifdef USE_PORTAUDIO
  2087. -#include "portaudio.h"
  2088. +#include <portaudio.h>
  2089. #undef USE_PORTAUDIO
  2090. // determine portaudio version by looking for a #define which is not in V18
  2091. #ifdef paNeverDropInput