Skip to content

Commit

Permalink
inc: New PortAudio binding
Browse files Browse the repository at this point in the history
  • Loading branch information
dkl committed Sep 10, 2015
1 parent 3d41246 commit 05ffa9d
Show file tree
Hide file tree
Showing 2 changed files with 202 additions and 53 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Expand Up @@ -63,6 +63,7 @@ Version 1.04.0
- New binding for libvorbis 1.3.5, with 64bit support
- New binding for Newton 3.13, with 64bit support
- New binding for ODE 0.13.1, with 64bit support
- New binding for PortAudio (pa_stable_v19_20140130), with 64bit support

[fixed]
- False-positive "ambigious sizeof" warnings if the identifier could refer only to a type or procedure (in that case it should already be fairly clear that the type will be chosen, not the procedure, because sizeof() can't be applied to procedures at all), or if an expression such as "array(0)" is given to sizeof() (i.e. something that starts with an identifier but is followed by further tokens that clarify that it's not refering to a type)
Expand Down
254 changes: 201 additions & 53 deletions inc/portaudio.bi
@@ -1,24 +1,65 @@
'' FreeBASIC binding for pa_stable_v19_20140130
''
'' based on the C header files:
'' $Id: portaudio.h 1859 2012-09-01 00:10:13Z philburk $
'' PortAudio Portable Real-Time Audio Library
'' PortAudio API Header File
'' Latest version available at: http://www.portaudio.com/
''
'' portaudio -- header translated with help of SWIG FB wrapper
'' Copyright (c) 1999-2002 Ross Bencina and Phil Burk
''
'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
'' be included in other distributions without authorization.
'' Permission is hereby granted, free of charge, to any person obtaining
'' a copy of this software and associated documentation files
'' (the "Software"), to deal in the Software without restriction,
'' including without limitation the rights to use, copy, modify, merge,
'' publish, distribute, sublicense, and/or sell copies of the Software,
'' and to permit persons to whom the Software is furnished to do so,
'' subject to the following conditions:
''
'' The above copyright notice and this permission notice shall be
'' included in all copies or substantial portions of the Software.
''
#ifndef __portaudio_bi__
#define __portaudio_bi__
'' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
'' EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
'' MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
'' IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
'' ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
'' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
'' WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
''
'' The text above constitutes the entire PortAudio license; however,
'' the PortAudio community also makes the following non-binding requests:
''
'' Any person wishing to distribute modifications to the Software is
'' requested to send the modifications to the original developer so that
'' they can be incorporated into the canonical version. It is also
'' requested that these non-binding requests be included along with the
'' license above.
''
'' translated to FreeBASIC by:
'' Copyright © 2015 FreeBASIC development team

#pragma once

#inclib "portaudio"

type PaError as integer
#include once "crt/long.bi"

extern "C"

#define PORTAUDIO_H
declare function Pa_GetVersion() as long
declare function Pa_GetVersionText() as const zstring ptr
type PaError as long

enum PaErrorNum
type PaErrorCode as long
enum
paNoError = 0
paHostError = -10000
paNotInitialized = -10000
paUnanticipatedHostError
paInvalidChannelCount
paInvalidSampleRate
paInvalidDeviceId
paInvalidDevice
paInvalidFlag
paSampleFormatNotSupported
paBadIODeviceCombination
Expand All @@ -30,57 +71,164 @@ enum PaErrorNum
paTimedOut
paInternalError
paDeviceUnavailable
paIncompatibleHostApiSpecificStreamInfo
paStreamIsStopped
paStreamIsNotStopped
paInputOverflowed
paOutputUnderflowed
paHostApiNotFound
paInvalidHostApi
paCanNotReadFromACallbackStream
paCanNotWriteToACallbackStream
paCanNotReadFromAnOutputOnlyStream
paCanNotWriteToAnInputOnlyStream
paIncompatibleStreamHostApi
paBadBufferPtr
end enum

declare function Pa_GetErrorText(byval errorCode as PaError) as const zstring ptr
declare function Pa_Initialize() as PaError
declare function Pa_Terminate() as PaError
type PaDeviceIndex as long
const paNoDevice = cast(PaDeviceIndex, -1)
const paUseHostApiSpecificDeviceSpecification = cast(PaDeviceIndex, -2)
type PaHostApiIndex as long
declare function Pa_GetHostApiCount() as PaHostApiIndex
declare function Pa_GetDefaultHostApi() as PaHostApiIndex

declare function Pa_Initialize cdecl alias "Pa_Initialize" () as PaError
declare function Pa_Terminate cdecl alias "Pa_Terminate" () as PaError
declare function Pa_GetHostError cdecl alias "Pa_GetHostError" () as integer
declare function Pa_GetErrorText cdecl alias "Pa_GetErrorText" (byval errnum as PaError) as zstring ptr
type PaHostApiTypeId as long
enum
paInDevelopment = 0
paDirectSound = 1
paMME = 2
paASIO = 3
paSoundManager = 4
paCoreAudio = 5
paOSS = 7
paALSA = 8
paAL = 9
paBeOS = 10
paWDMKS = 11
paJACK = 12
paWASAPI = 13
paAudioScienceHPI = 14
end enum

type PaHostApiInfo
structVersion as long
as PaHostApiTypeId type
name as const zstring ptr
deviceCount as long
defaultInputDevice as PaDeviceIndex
defaultOutputDevice as PaDeviceIndex
end type

type PaSampleFormat as uinteger
type PaDeviceID as integer
declare function Pa_GetHostApiInfo(byval hostApi as PaHostApiIndex) as const PaHostApiInfo ptr
declare function Pa_HostApiTypeIdToHostApiIndex(byval type as PaHostApiTypeId) as PaHostApiIndex
declare function Pa_HostApiDeviceIndexToDeviceIndex(byval hostApi as PaHostApiIndex, byval hostApiDeviceIndex as long) as PaDeviceIndex

#define paNoDevice -1
type PaHostErrorInfo
hostApiType as PaHostApiTypeId
errorCode as clong
errorText as const zstring ptr
end type

declare function Pa_GetLastHostErrorInfo() as const PaHostErrorInfo ptr
declare function Pa_GetDeviceCount() as PaDeviceIndex
declare function Pa_GetDefaultInputDevice() as PaDeviceIndex
declare function Pa_GetDefaultOutputDevice() as PaDeviceIndex
type PaTime as double
type PaSampleFormat as culong

declare function Pa_CountDevices cdecl alias "Pa_CountDevices" () as integer
const paFloat32 = cast(PaSampleFormat, &h00000001)
const paInt32 = cast(PaSampleFormat, &h00000002)
const paInt24 = cast(PaSampleFormat, &h00000004)
const paInt16 = cast(PaSampleFormat, &h00000008)
const paInt8 = cast(PaSampleFormat, &h00000010)
const paUInt8 = cast(PaSampleFormat, &h00000020)
const paCustomFormat = cast(PaSampleFormat, &h00010000)
const paNonInterleaved = cast(PaSampleFormat, &h80000000)

type PaDeviceInfo
structVersion as integer
name as zstring ptr
maxInputChannels as integer
maxOutputChannels as integer
numSampleRates as integer
sampleRates as double ptr
nativeSampleFormats as PaSampleFormat
structVersion as long
name as const zstring ptr
hostApi as PaHostApiIndex
maxInputChannels as long
maxOutputChannels as long
defaultLowInputLatency as PaTime
defaultLowOutputLatency as PaTime
defaultHighInputLatency as PaTime
defaultHighOutputLatency as PaTime
defaultSampleRate as double
end type

declare function Pa_GetDeviceInfo(byval device as PaDeviceIndex) as const PaDeviceInfo ptr

type PaStreamParameters
device as PaDeviceIndex
channelCount as long
sampleFormat as PaSampleFormat
suggestedLatency as PaTime
hostApiSpecificStreamInfo as any ptr
end type

const paFormatIsSupported = 0
declare function Pa_IsFormatSupported(byval inputParameters as const PaStreamParameters ptr, byval outputParameters as const PaStreamParameters ptr, byval sampleRate as double) as PaError
type PaStream as any
const paFramesPerBufferUnspecified = 0
type PaStreamFlags as culong
const paNoFlag = cast(PaStreamFlags, 0)
const paClipOff = cast(PaStreamFlags, &h00000001)
const paDitherOff = cast(PaStreamFlags, &h00000002)
const paNeverDropInput = cast(PaStreamFlags, &h00000004)
const paPrimeOutputBuffersUsingStreamCallback = cast(PaStreamFlags, &h00000008)
const paPlatformSpecificFlags = cast(PaStreamFlags, &hFFFF0000)

type PaStreamCallbackTimeInfo
inputBufferAdcTime as PaTime
currentTime as PaTime
outputBufferDacTime as PaTime
end type

type PaStreamCallbackFlags as culong
const paInputUnderflow = cast(PaStreamCallbackFlags, &h00000001)
const paInputOverflow = cast(PaStreamCallbackFlags, &h00000002)
const paOutputUnderflow = cast(PaStreamCallbackFlags, &h00000004)
const paOutputOverflow = cast(PaStreamCallbackFlags, &h00000008)
const paPrimingOutput = cast(PaStreamCallbackFlags, &h00000010)

type PaStreamCallbackResult as long
enum
paContinue = 0
paComplete = 1
paAbort = 2
end enum

declare function Pa_OpenStream(byval stream as PaStream ptr ptr, byval inputParameters as const PaStreamParameters ptr, byval outputParameters as const PaStreamParameters ptr, byval sampleRate as double, byval framesPerBuffer as culong, byval streamFlags as PaStreamFlags, byval streamCallback as function(byval input as const any ptr, byval output as any ptr, byval frameCount as culong, byval timeInfo as const PaStreamCallbackTimeInfo ptr, byval statusFlags as PaStreamCallbackFlags, byval userData as any ptr) as long, byval userData as any ptr) as PaError
declare function Pa_OpenDefaultStream(byval stream as PaStream ptr ptr, byval numInputChannels as long, byval numOutputChannels as long, byval sampleFormat as PaSampleFormat, byval sampleRate as double, byval framesPerBuffer as culong, byval streamCallback as function(byval input as const any ptr, byval output as any ptr, byval frameCount as culong, byval timeInfo as const PaStreamCallbackTimeInfo ptr, byval statusFlags as PaStreamCallbackFlags, byval userData as any ptr) as long, byval userData as any ptr) as PaError
declare function Pa_CloseStream(byval stream as PaStream ptr) as PaError
declare function Pa_SetStreamFinishedCallback(byval stream as PaStream ptr, byval streamFinishedCallback as sub(byval userData as any ptr)) as PaError
declare function Pa_StartStream(byval stream as PaStream ptr) as PaError
declare function Pa_StopStream(byval stream as PaStream ptr) as PaError
declare function Pa_AbortStream(byval stream as PaStream ptr) as PaError
declare function Pa_IsStreamStopped(byval stream as PaStream ptr) as PaError
declare function Pa_IsStreamActive(byval stream as PaStream ptr) as PaError

type PaStreamInfo
structVersion as long
inputLatency as PaTime
outputLatency as PaTime
sampleRate as double
end type

declare function Pa_GetDefaultInputDeviceID cdecl alias "Pa_GetDefaultInputDeviceID" () as PaDeviceID
declare function Pa_GetDefaultOutputDeviceID cdecl alias "Pa_GetDefaultOutputDeviceID" () as PaDeviceID
declare function Pa_GetDeviceInfo cdecl alias "Pa_GetDeviceInfo" (byval device as PaDeviceID) as PaDeviceInfo ptr

type PaTimestamp as double
type PortAudioCallback as function( byval inputbuffer as any ptr, outputBuffer as any ptr, framesPerBuffer as uinteger, outTime as double, userData as any ptr )

#define paNoFlag (0)
#define paClipOff (1 shl 0)
#define paDitherOff (1 shl 1)
#define paPlatformSpecificFlags (&h00010000)

type PaStreamFlags as uinteger
type PortAudioStream as any

declare function Pa_OpenStream cdecl alias "Pa_OpenStream" (byval stream as PortAudioStream ptr ptr, byval inputDevice as PaDeviceID, byval numInputChannels as integer, byval inputSampleFormat as PaSampleFormat, byval inputDriverInfo as any ptr, byval outputDevice as PaDeviceID, byval numOutputChannels as integer, byval outputSampleFormat as PaSampleFormat, byval outputDriverInfo as any ptr, byval sampleRate as double, byval framesPerBuffer as uinteger, byval numberOfBuffers as uinteger, byval streamFlags as PaStreamFlags, byval callback as PortAudioCallback ptr, byval userData as any ptr) as PaError
declare function Pa_OpenDefaultStream cdecl alias "Pa_OpenDefaultStream" (byval stream as PortAudioStream ptr ptr, byval numInputChannels as integer, byval numOutputChannels as integer, byval sampleFormat as PaSampleFormat, byval sampleRate as double, byval framesPerBuffer as uinteger, byval numberOfBuffers as uinteger, byval callback as PortAudioCallback ptr, byval userData as any ptr) as PaError
declare function Pa_CloseStream cdecl alias "Pa_CloseStream" (byval as PortAudioStream ptr) as PaError
declare function Pa_StartStream cdecl alias "Pa_StartStream" (byval stream as PortAudioStream ptr) as PaError
declare function Pa_StopStream cdecl alias "Pa_StopStream" (byval stream as PortAudioStream ptr) as PaError
declare function Pa_AbortStream cdecl alias "Pa_AbortStream" (byval stream as PortAudioStream ptr) as PaError
declare function Pa_StreamActive cdecl alias "Pa_StreamActive" (byval stream as PortAudioStream ptr) as PaError
declare function Pa_StreamTime cdecl alias "Pa_StreamTime" (byval stream as PortAudioStream ptr) as PaTimestamp
declare function Pa_GetCPULoad cdecl alias "Pa_GetCPULoad" (byval stream as PortAudioStream ptr) as double
declare function Pa_GetMinNumBuffers cdecl alias "Pa_GetMinNumBuffers" (byval framesPerBuffer as integer, byval sampleRate as double) as integer
declare sub Pa_Sleep cdecl alias "Pa_Sleep" (byval msec as integer)
declare function Pa_GetSampleSize cdecl alias "Pa_GetSampleSize" (byval format as PaSampleFormat) as PaError

#endif
declare function Pa_GetStreamInfo(byval stream as PaStream ptr) as const PaStreamInfo ptr
declare function Pa_GetStreamTime(byval stream as PaStream ptr) as PaTime
declare function Pa_GetStreamCpuLoad(byval stream as PaStream ptr) as double
declare function Pa_ReadStream(byval stream as PaStream ptr, byval buffer as any ptr, byval frames as culong) as PaError
declare function Pa_WriteStream(byval stream as PaStream ptr, byval buffer as const any ptr, byval frames as culong) as PaError
declare function Pa_GetStreamReadAvailable(byval stream as PaStream ptr) as clong
declare function Pa_GetStreamWriteAvailable(byval stream as PaStream ptr) as clong
declare function Pa_GetSampleSize(byval format as PaSampleFormat) as PaError
declare sub Pa_Sleep(byval msec as clong)

end extern

0 comments on commit 05ffa9d

Please sign in to comment.