Skip to content

Commit 04aa710

Browse files
committed
Switch to API mode
1 parent b7962d7 commit 04aa710

File tree

14 files changed

+3316
-135
lines changed

14 files changed

+3316
-135
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
_sounddevice.py
1+
_sounddevice.*
22
*.pyc
33
__pycache__/
44
build/
55
dist/
66
.eggs/
77
sounddevice.egg-info/
8+
.DS_Store

include/pa_asio.h

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#ifndef PA_ASIO_H
2+
#define PA_ASIO_H
3+
/*
4+
* $Id$
5+
* PortAudio Portable Real-Time Audio Library
6+
* ASIO specific extensions
7+
*
8+
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining
11+
* a copy of this software and associated documentation files
12+
* (the "Software"), to deal in the Software without restriction,
13+
* including without limitation the rights to use, copy, modify, merge,
14+
* publish, distribute, sublicense, and/or sell copies of the Software,
15+
* and to permit persons to whom the Software is furnished to do so,
16+
* subject to the following conditions:
17+
*
18+
* The above copyright notice and this permission notice shall be
19+
* included in all copies or substantial portions of the Software.
20+
*
21+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
25+
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26+
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28+
*/
29+
30+
/*
31+
* The text above constitutes the entire PortAudio license; however,
32+
* the PortAudio community also makes the following non-binding requests:
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. It is also
37+
* requested that these non-binding requests be included along with the
38+
* license above.
39+
*/
40+
41+
42+
/** @file
43+
@ingroup public_header
44+
@brief ASIO-specific PortAudio API extension header file.
45+
*/
46+
47+
#include "portaudio.h"
48+
49+
#ifdef __cplusplus
50+
extern "C"
51+
{
52+
#endif /* __cplusplus */
53+
54+
55+
/** Retrieve legal native buffer sizes for the specified device, in sample frames.
56+
57+
@param device The global index of the device about which the query is being made.
58+
@param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
59+
@param maxBufferSizeFrames A pointer to the location which will receive the maximum buffer size value.
60+
@param preferredBufferSizeFrames A pointer to the location which will receive the preferred buffer size value.
61+
@param granularity A pointer to the location which will receive the "granularity". This value determines
62+
the step size used to compute the legal values between minBufferSizeFrames and maxBufferSizeFrames.
63+
If granularity is -1 then available buffer size values are powers of two.
64+
65+
@see ASIOGetBufferSize in the ASIO SDK.
66+
67+
@note: this function used to be called PaAsio_GetAvailableLatencyValues. There is a
68+
#define that maps PaAsio_GetAvailableLatencyValues to this function for backwards compatibility.
69+
*/
70+
PaError PaAsio_GetAvailableBufferSizes( PaDeviceIndex device,
71+
long *minBufferSizeFrames, long *maxBufferSizeFrames, long *preferredBufferSizeFrames, long *granularity );
72+
73+
74+
/** Backwards compatibility alias for PaAsio_GetAvailableBufferSizes
75+
76+
@see PaAsio_GetAvailableBufferSizes
77+
*/
78+
#define PaAsio_GetAvailableLatencyValues PaAsio_GetAvailableBufferSizes
79+
80+
81+
/** Display the ASIO control panel for the specified device.
82+
83+
@param device The global index of the device whose control panel is to be displayed.
84+
@param systemSpecific On Windows, the calling application's main window handle,
85+
on Macintosh this value should be zero.
86+
*/
87+
PaError PaAsio_ShowControlPanel( PaDeviceIndex device, void* systemSpecific );
88+
89+
90+
91+
92+
/** Retrieve a pointer to a string containing the name of the specified
93+
input channel. The string is valid until Pa_Terminate is called.
94+
95+
The string will be no longer than 32 characters including the null terminator.
96+
*/
97+
PaError PaAsio_GetInputChannelName( PaDeviceIndex device, int channelIndex,
98+
const char** channelName );
99+
100+
101+
/** Retrieve a pointer to a string containing the name of the specified
102+
input channel. The string is valid until Pa_Terminate is called.
103+
104+
The string will be no longer than 32 characters including the null terminator.
105+
*/
106+
PaError PaAsio_GetOutputChannelName( PaDeviceIndex device, int channelIndex,
107+
const char** channelName );
108+
109+
110+
/** Set the sample rate of an open paASIO stream.
111+
112+
@param stream The stream to operate on.
113+
@param sampleRate The new sample rate.
114+
115+
Note that this function may fail if the stream is already running and the
116+
ASIO driver does not support switching the sample rate of a running stream.
117+
118+
Returns paIncompatibleStreamHostApi if stream is not a paASIO stream.
119+
*/
120+
PaError PaAsio_SetStreamSampleRate( PaStream* stream, double sampleRate );
121+
122+
123+
#define paAsioUseChannelSelectors (0x01)
124+
125+
typedef struct PaAsioStreamInfo{
126+
unsigned long size; /**< sizeof(PaAsioStreamInfo) */
127+
PaHostApiTypeId hostApiType; /**< paASIO */
128+
unsigned long version; /**< 1 */
129+
130+
unsigned long flags;
131+
132+
/* Support for opening only specific channels of an ASIO device.
133+
If the paAsioUseChannelSelectors flag is set, channelSelectors is a
134+
pointer to an array of integers specifying the device channels to use.
135+
When used, the length of the channelSelectors array must match the
136+
corresponding channelCount parameter to Pa_OpenStream() otherwise a
137+
crash may result.
138+
The values in the selectors array must specify channels within the
139+
range of supported channels for the device or paInvalidChannelCount will
140+
result.
141+
*/
142+
int *channelSelectors;
143+
}PaAsioStreamInfo;
144+
145+
146+
#ifdef __cplusplus
147+
}
148+
#endif /* __cplusplus */
149+
150+
#endif /* PA_ASIO_H */

include/pa_jack.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#ifndef PA_JACK_H
2+
#define PA_JACK_H
3+
4+
/*
5+
* $Id:
6+
* PortAudio Portable Real-Time Audio Library
7+
* JACK-specific extensions
8+
*
9+
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
10+
*
11+
* Permission is hereby granted, free of charge, to any person obtaining
12+
* a copy of this software and associated documentation files
13+
* (the "Software"), to deal in the Software without restriction,
14+
* including without limitation the rights to use, copy, modify, merge,
15+
* publish, distribute, sublicense, and/or sell copies of the Software,
16+
* and to permit persons to whom the Software is furnished to do so,
17+
* subject to the following conditions:
18+
*
19+
* The above copyright notice and this permission notice shall be
20+
* included in all copies or substantial portions of the Software.
21+
*
22+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26+
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27+
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29+
*/
30+
31+
/*
32+
* The text above constitutes the entire PortAudio license; however,
33+
* the PortAudio community also makes the following non-binding requests:
34+
*
35+
* Any person wishing to distribute modifications to the Software is
36+
* requested to send the modifications to the original developer so that
37+
* they can be incorporated into the canonical version. It is also
38+
* requested that these non-binding requests be included along with the
39+
* license above.
40+
*/
41+
42+
/** @file
43+
* @ingroup public_header
44+
* @brief JACK-specific PortAudio API extension header file.
45+
*/
46+
47+
#include "portaudio.h"
48+
49+
#ifdef __cplusplus
50+
extern "C" {
51+
#endif
52+
53+
/** Set the JACK client name.
54+
*
55+
* During Pa_Initialize, When PA JACK connects as a client of the JACK server, it requests a certain
56+
* name, which is for instance prepended to port names. By default this name is "PortAudio". The
57+
* JACK server may append a suffix to the client name, in order to avoid clashes among clients that
58+
* try to connect with the same name (e.g., different PA JACK clients).
59+
*
60+
* This function must be called before Pa_Initialize, otherwise it won't have any effect. Note that
61+
* the string is not copied, but instead referenced directly, so it must not be freed for as long as
62+
* PA might need it.
63+
* @sa PaJack_GetClientName
64+
*/
65+
PaError PaJack_SetClientName( const char* name );
66+
67+
/** Get the JACK client name used by PA JACK.
68+
*
69+
* The caller is responsible for freeing the returned pointer.
70+
*/
71+
PaError PaJack_GetClientName(const char** clientName);
72+
73+
#ifdef __cplusplus
74+
}
75+
#endif
76+
77+
#endif

include/pa_linux_alsa.h

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#ifndef PA_LINUX_ALSA_H
2+
#define PA_LINUX_ALSA_H
3+
4+
/*
5+
* $Id$
6+
* PortAudio Portable Real-Time Audio Library
7+
* ALSA-specific extensions
8+
*
9+
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
10+
*
11+
* Permission is hereby granted, free of charge, to any person obtaining
12+
* a copy of this software and associated documentation files
13+
* (the "Software"), to deal in the Software without restriction,
14+
* including without limitation the rights to use, copy, modify, merge,
15+
* publish, distribute, sublicense, and/or sell copies of the Software,
16+
* and to permit persons to whom the Software is furnished to do so,
17+
* subject to the following conditions:
18+
*
19+
* The above copyright notice and this permission notice shall be
20+
* included in all copies or substantial portions of the Software.
21+
*
22+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26+
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27+
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29+
*/
30+
31+
/*
32+
* The text above constitutes the entire PortAudio license; however,
33+
* the PortAudio community also makes the following non-binding requests:
34+
*
35+
* Any person wishing to distribute modifications to the Software is
36+
* requested to send the modifications to the original developer so that
37+
* they can be incorporated into the canonical version. It is also
38+
* requested that these non-binding requests be included along with the
39+
* license above.
40+
*/
41+
42+
/** @file
43+
* @ingroup public_header
44+
* @brief ALSA-specific PortAudio API extension header file.
45+
*/
46+
47+
#include "portaudio.h"
48+
49+
#ifdef __cplusplus
50+
extern "C" {
51+
#endif
52+
53+
typedef struct PaAlsaStreamInfo
54+
{
55+
unsigned long size;
56+
PaHostApiTypeId hostApiType;
57+
unsigned long version;
58+
59+
const char *deviceString;
60+
}
61+
PaAlsaStreamInfo;
62+
63+
/** Initialize host API specific structure, call this before setting relevant attributes. */
64+
void PaAlsa_InitializeStreamInfo( PaAlsaStreamInfo *info );
65+
66+
/** Instruct whether to enable real-time priority when starting the audio thread.
67+
*
68+
* If this is turned on by the stream is started, the audio callback thread will be created
69+
* with the FIFO scheduling policy, which is suitable for realtime operation.
70+
**/
71+
void PaAlsa_EnableRealtimeScheduling( PaStream *s, int enable );
72+
73+
#if 0
74+
void PaAlsa_EnableWatchdog( PaStream *s, int enable );
75+
#endif
76+
77+
/** Get the ALSA-lib card index of this stream's input device. */
78+
PaError PaAlsa_GetStreamInputCard( PaStream *s, int *card );
79+
80+
/** Get the ALSA-lib card index of this stream's output device. */
81+
PaError PaAlsa_GetStreamOutputCard( PaStream *s, int *card );
82+
83+
/** Set the number of periods (buffer fragments) to configure devices with.
84+
*
85+
* By default the number of periods is 4, this is the lowest number of periods that works well on
86+
* the author's soundcard.
87+
* @param numPeriods The number of periods.
88+
*/
89+
PaError PaAlsa_SetNumPeriods( int numPeriods );
90+
91+
/** Set the maximum number of times to retry opening busy device (sleeping for a
92+
* short interval inbetween).
93+
*/
94+
PaError PaAlsa_SetRetriesBusy( int retries );
95+
96+
/** Set the path and name of ALSA library file if PortAudio is configured to load it dynamically (see
97+
* PA_ALSA_DYNAMIC). This setting will overwrite the default name set by PA_ALSA_PATHNAME define.
98+
* @param pathName Full path with filename. Only filename can be used, but dlopen() will lookup default
99+
* searchable directories (/usr/lib;/usr/local/lib) then.
100+
*/
101+
void PaAlsa_SetLibraryPathName( const char *pathName );
102+
103+
#ifdef __cplusplus
104+
}
105+
#endif
106+
107+
#endif

0 commit comments

Comments
 (0)