public final class Pa
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Pa.HostApiTypeId
Enumerates the unchanging unique identifiers of each of the supported
host APIs.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MILLIS_PER_BUFFER
The number of milliseconds to be read from or written to a native
PortAudio stream in a single transfer of data.
|
static double |
DEFAULT_SAMPLE_RATE
The default value for the sample rate of the input and the output
PortAudio streams with which they are to be opened if no other specific
sample rate is specified to the PortAudio DataSource or
PortAudioRenderer that they represent.
|
static long |
FRAMES_PER_BUFFER_UNSPECIFIED
Can be passed as the framesPerBuffer parameter to
Pa_OpenStream() or Pa_OpenDefaultStream() to indicate
that the stream callback will accept buffers of any size.
|
static double |
LATENCY_HIGH
Used when creating new stream parameters for suggested latency to use
high input/output value.
|
static double |
LATENCY_LOW
Used when creating new stream parameters for suggested latency to use low
input/default value.
|
static double |
LATENCY_UNSPECIFIED
Used when creating new stream parameters for suggested latency to use
default value.
|
static int |
MMSYSERR_NODRIVER
The constant defined by Windows Multimedia and utilized by PortAudio's
wmme host API to signal that no device driver is present.
|
static int |
paNoDevice
The constant defined by the native PortAudio library to signal that no
device is specified.
|
static int |
paNoError
The PaErrorCode value defined by the native PortAudio library to
signal that no error is detected/reported.
|
static int |
paTimedOut
The PaErrorCode value defined by the native PortAudio library to
signal that a timeout has occurred.
|
static int |
paUnanticipatedHostError
The PaErrorCode value defined by the native PortAudio library to
signal that an unanticipated error has been detected by a host API.
|
static long |
SAMPLE_FORMAT_FLOAT32
A type used to specify one or more sample formats.
|
static long |
SAMPLE_FORMAT_INT16
A type used to specify one or more sample formats.
|
static long |
SAMPLE_FORMAT_INT24
A type used to specify one or more sample formats.
|
static long |
SAMPLE_FORMAT_INT32
A type used to specify one or more sample formats.
|
static long |
SAMPLE_FORMAT_INT8
A type used to specify one or more sample formats.
|
static long |
SAMPLE_FORMAT_UINT8
A type used to specify one or more sample formats.
|
static long |
STREAM_FLAGS_CLIP_OFF
Disables default clipping of out of range samples.
|
static long |
STREAM_FLAGS_DITHER_OFF
Disables default dithering.
|
static long |
STREAM_FLAGS_NEVER_DROP_INPUT
Flag requests that where possible a full duplex stream will not discard
overflowed input samples without calling the stream callback.
|
static long |
STREAM_FLAGS_NO_FLAG
Flags used to control the behavior of a stream.
|
static long |
STREAM_FLAGS_PLATFORM_SPECIFIC_FLAGS
A mask specifying the platform specific bits.
|
static long |
STREAM_FLAGS_PRIME_OUTPUT_BUFFERS_USING_STREAM_CALLBACK
Call the stream callback to fill initial output buffers, rather than the
default behavior of priming the buffers with zeros (silence).
|
Modifier and Type | Method and Description |
---|---|
static void |
AbortStream(long stream)
Terminates audio processing immediately without waiting for pending
buffers to complete.
|
static void |
CloseStream(long stream)
Closes an audio stream.
|
static double |
DeviceInfo_getDefaultHighInputLatency(long deviceInfo)
Returns defaultHighInputLatency for the device.
|
static double |
DeviceInfo_getDefaultHighOutputLatency(long deviceInfo)
Returns defaultHighOutputLatency for the device.
|
static double |
DeviceInfo_getDefaultLowInputLatency(long deviceInfo)
Returns defaultLowInputLatency for the device.
|
static double |
DeviceInfo_getDefaultLowOutputLatency(long deviceInfo)
Returns defaultLowOutputLatency for the device.
|
static double |
DeviceInfo_getDefaultSampleRate(long deviceInfo)
The default sample rate for the device.
|
static java.lang.String |
DeviceInfo_getDeviceUID(long deviceInfo)
Device UID for the device (persistent across boots).
|
static byte[] |
DeviceInfo_getDeviceUIDBytes(long deviceInfo)
Device UID for the device (persistent across boots).
|
static int |
DeviceInfo_getHostApi(long deviceInfo)
The host api of the device.
|
static int |
DeviceInfo_getMaxInputChannels(long deviceInfo)
Maximum input channels for the device.
|
static int |
DeviceInfo_getMaxOutputChannels(long deviceInfo)
Maximum output channels for the device.
|
static java.lang.String |
DeviceInfo_getName(long deviceInfo)
Gets the human-readable name of the PaDeviceInfo specified by a
pointer to it.
|
static java.lang.String |
DeviceInfo_getTransportType(long deviceInfo)
Transport type for the device: BuiltIn, USB, BLuetooth, etc.
|
static byte[] |
DeviceInfo_getTransportTypeBytes(long deviceInfo)
Transport type for the device: BuiltIn, USB, BLuetooth, etc.
|
static void |
devicesChangedCallback()
Implements a callback which gets called by the native PortAudio
counterpart to notify the Java counterpart that the list of PortAudio
devices has changed.
|
static int |
GetDefaultInputDevice()
Retrieve the index of the default input device.
|
static int |
GetDefaultOutputDevice()
Retrieve the index of the default output device.
|
static int |
GetDeviceCount()
Retrieve the number of available devices.
|
static int |
getDeviceIndex(java.lang.String deviceID,
int minInputChannels,
int minOutputChannels)
Returns the PortAudio index of the device identified by a specific
deviceID or
paNoDevice if no such device exists. |
static long |
GetDeviceInfo(int deviceIndex)
Retrieve a pointer to a PaDeviceInfo structure containing information
about the specified device.
|
static long |
GetHostApiInfo(int hostApiIndex)
Retrieve a pointer to a structure containing information about a specific
host Api.
|
static long |
getPaSampleFormat(int sampleSizeInBits)
Gets the native PaSampleFormat with a specific size in bits.
|
static int |
GetSampleSize(long format)
Retrieve the size of a given sample format in bytes.
|
static long |
GetStreamReadAvailable(long stream)
Retrieve the number of frames that can be read from the stream without
waiting.
|
static long |
GetStreamWriteAvailable(long stream)
Retrieve the number of frames that can be written to the stream
without waiting.
|
static double |
getSuggestedLatency()
Gets the suggested latency to be used when opening PortAudio streams.
|
static int |
HostApiInfo_getDefaultInputDevice(long hostApiInfo)
The default input device for this host API.
|
static int |
HostApiInfo_getDefaultOutputDevice(long hostApiInfo)
The default output device for this host API.
|
static int |
HostApiInfo_getDeviceCount(long hostApiInfo)
The number of devices belonging to this host API.
|
static int |
HostApiInfo_getType(long hostApiInfo)
The well known unique identifier of this host API.
|
static boolean |
IsFormatSupported(long inputParameters,
long outputParameters,
double sampleRate)
Determine whether it would be possible to open a stream
with the specified parameters.
|
static long |
OpenStream(long inputParameters,
long outputParameters,
double sampleRate,
long framesPerBuffer,
long streamFlags,
PortAudioStreamCallback streamCallback)
Opens a stream for either input, output or both.
|
static void |
ReadStream(long stream,
byte[] buffer,
long frames)
Read samples from an input stream.
|
static void |
setDenoise(long stream,
boolean denoise)
Sets the indicator which determines whether a specific (input) PortAudio
stream is to have denoise performed on the audio data it provides.
|
static void |
setDevicesChangedCallback(java.lang.Runnable devicesChangedCallback) |
static void |
setEchoFilterLengthInMillis(long stream,
long echoFilterLengthInMillis)
Sets the number of milliseconds of echo to be canceled in the audio data
provided by a specific (input) PortAudio stream.
|
static void |
StartStream(long stream)
Commences audio processing.
|
static void |
StopStream(long stream)
Terminates audio processing.
|
static void |
StreamParameters_free(long streamParameters)
Free StreamParameters resources specified by a pointer to it.
|
static long |
StreamParameters_new(int deviceIndex,
int channelCount,
long sampleFormat,
double suggestedLatency)
Creates parameters used for opening streams.
|
static void |
UpdateAvailableDeviceList() |
static void |
WriteStream(long stream,
byte[] buffer,
int offset,
long frames,
int numberOfWrites)
Writes samples to an output stream.
|
static void |
WriteStream(long stream,
byte[] buffer,
long frames)
Write samples to an output stream.
|
public static final int DEFAULT_MILLIS_PER_BUFFER
public static final double DEFAULT_SAMPLE_RATE
public static final long FRAMES_PER_BUFFER_UNSPECIFIED
public static final double LATENCY_HIGH
public static final double LATENCY_LOW
public static final double LATENCY_UNSPECIFIED
public static final int MMSYSERR_NODRIVER
public static final int paNoDevice
public static final int paNoError
public static final int paTimedOut
public static final int paUnanticipatedHostError
public static final long SAMPLE_FORMAT_FLOAT32
public static final long SAMPLE_FORMAT_INT16
public static final long SAMPLE_FORMAT_INT24
public static final long SAMPLE_FORMAT_INT32
public static final long SAMPLE_FORMAT_INT8
public static final long SAMPLE_FORMAT_UINT8
public static final long STREAM_FLAGS_CLIP_OFF
public static final long STREAM_FLAGS_DITHER_OFF
public static final long STREAM_FLAGS_NEVER_DROP_INPUT
public static final long STREAM_FLAGS_NO_FLAG
public static final long STREAM_FLAGS_PLATFORM_SPECIFIC_FLAGS
public static final long STREAM_FLAGS_PRIME_OUTPUT_BUFFERS_USING_STREAM_CALLBACK
public static void AbortStream(long stream) throws PortAudioException
stream
- the steam pointer.PortAudioException
public static void CloseStream(long stream) throws PortAudioException
stream
- the steam pointer.PortAudioException
public static double DeviceInfo_getDefaultHighInputLatency(long deviceInfo)
deviceInfo
- device info pointer.public static double DeviceInfo_getDefaultHighOutputLatency(long deviceInfo)
deviceInfo
- device info pointer.public static double DeviceInfo_getDefaultLowInputLatency(long deviceInfo)
deviceInfo
- device info pointer.public static double DeviceInfo_getDefaultLowOutputLatency(long deviceInfo)
deviceInfo
- device info pointer.public static double DeviceInfo_getDefaultSampleRate(long deviceInfo)
deviceInfo
- device info pointer.public static java.lang.String DeviceInfo_getDeviceUID(long deviceInfo)
deviceInfo
- device info pointer.public static byte[] DeviceInfo_getDeviceUIDBytes(long deviceInfo)
deviceInfo
- device info pointer.public static int DeviceInfo_getHostApi(long deviceInfo)
deviceInfo
- device info pointer.public static int DeviceInfo_getMaxInputChannels(long deviceInfo)
deviceInfo
- device info pointer.public static int DeviceInfo_getMaxOutputChannels(long deviceInfo)
deviceInfo
- device info pointer.public static java.lang.String DeviceInfo_getName(long deviceInfo)
deviceInfo
- the pointer to the PaDeviceInfo to get the
human-readable name ofpublic static java.lang.String DeviceInfo_getTransportType(long deviceInfo)
deviceInfo
- device info pointer.public static byte[] DeviceInfo_getTransportTypeBytes(long deviceInfo)
deviceInfo
- device info pointer.public static void devicesChangedCallback()
public static int GetDefaultInputDevice()
public static int GetDefaultOutputDevice()
public static int GetDeviceCount() throws PortAudioException
PortAudioException
public static int getDeviceIndex(java.lang.String deviceID, int minInputChannels, int minOutputChannels)
paNoDevice
if no such device exists. The
deviceID is either a deviceUID or a (PortAudio device)
name depending, for example, on operating system/API availability. Since
at least names may not be unique, the PortAudio device to return the
index of may be identified more specifically by the minimal numbers of
channels to be required from the device for input and output.deviceID
- a String identifying the PortAudio device to
retrieve the index of. It is either a deviceUID or a (PortAudio
device) name.minInputChannels
- minOutputChannels
- public static long GetDeviceInfo(int deviceIndex)
deviceIndex
- the device indexpublic static long GetHostApiInfo(int hostApiIndex)
hostApiIndex
- host api index.public static long getPaSampleFormat(int sampleSizeInBits)
sampleSizeInBits
- the size in bits of the native
PaSampleFormat to getpublic static int GetSampleSize(long format)
format
- the format.public static long GetStreamReadAvailable(long stream)
stream
- pointer to the stream.public static long GetStreamWriteAvailable(long stream)
stream
- pointer to the stream.public static double getSuggestedLatency()
public static int HostApiInfo_getDefaultInputDevice(long hostApiInfo)
hostApiInfo
- pointer to host API info structure.public static int HostApiInfo_getDefaultOutputDevice(long hostApiInfo)
hostApiInfo
- pointer to host API info structure.public static int HostApiInfo_getDeviceCount(long hostApiInfo)
hostApiInfo
- pointer to host API info structure.public static int HostApiInfo_getType(long hostApiInfo)
hostApiInfo
- pointer to host API info structure.public static boolean IsFormatSupported(long inputParameters, long outputParameters, double sampleRate)
inputParameters
- A structure that describes the input parameters
used to open a stream.outputParameters
- A structure that describes the output parameters
used to open a stream.sampleRate
- The required sampleRate.public static long OpenStream(long inputParameters, long outputParameters, double sampleRate, long framesPerBuffer, long streamFlags, PortAudioStreamCallback streamCallback) throws PortAudioException
inputParameters
- the input parameters or 0 if absent.outputParameters
- the output parameters or 0 if absent.sampleRate
- The desired sampleRate.framesPerBuffer
- The number of frames passed to the stream callback
function, or the preferred block granularity for a blocking read/write
streamstreamFlags
- Flags which modify the behavior of the streaming
process.streamCallback
- A pointer to a client supplied function that is
responsible for processing and filling input and output buffers. If
null, the stream will be opened in 'blocking read/write' mode.PortAudioException
public static void ReadStream(long stream, byte[] buffer, long frames) throws PortAudioException
stream
- pointer to the stream.buffer
- a buffer of sample frames.frames
- The number of frames to be read into buffer.PortAudioException
public static void setDenoise(long stream, boolean denoise)
stream
- the (input) PortAudio stream for which denoise is to be
enabled or disableddenoise
- true if denoise is to be performed on the audio
data provided by stream; otherwise, falsepublic static void setDevicesChangedCallback(java.lang.Runnable devicesChangedCallback)
public static void setEchoFilterLengthInMillis(long stream, long echoFilterLengthInMillis)
stream
- the (input) PortAudio stream for which the number of
milliseconds of echo to be canceled is to be setechoFilterLengthInMillis
- the number of milliseconds of echo to be
canceled in the audio data provided by streampublic static void StartStream(long stream) throws PortAudioException
stream
- pointer to the streamPortAudioException
public static void StopStream(long stream) throws PortAudioException
stream
- pointer to the streamPortAudioException
public static void StreamParameters_free(long streamParameters)
streamParameters
- the pointer to the PaStreamParameters
to freepublic static long StreamParameters_new(int deviceIndex, int channelCount, long sampleFormat, double suggestedLatency)
deviceIndex
- the device.channelCount
- the channels to be used.sampleFormat
- the sample format.suggestedLatency
- the suggested latency in milliseconds:
LATENCY_UNSPECIFIED -
use default(default high input/output latency)
LATENCY_HIGH - use default high input/output latency
LATENCY_LOW - use default low input/output latency
... - any other value in milliseconds (e.g. 0.1 is acceptable)public static void UpdateAvailableDeviceList()
public static void WriteStream(long stream, byte[] buffer, int offset, long frames, int numberOfWrites) throws PortAudioException
Provides better efficiency than achieved through multiple consecutive
calls to WriteStream(long, byte[], long)
with one and the
same buffer because the JNI access to the bytes of the buffer which is
likely to copy the whole buffer is only performed once.
stream
- the pointer to the PortAudio stream to write the samples tobuffer
- the buffer containing the samples to be writtenoffset
- the byte offset in buffer at which the samples to
be written startframes
- the number of frames from buffer starting at
offset are to be written with a single writenumberOfWrites
- the number of writes each writing frames
number of frames to be performedPortAudioException
- if anything goes wrong while writingpublic static void WriteStream(long stream, byte[] buffer, long frames) throws PortAudioException
stream
- pointer to the streambuffer
- A buffer of sample frames.frames
- The number of frames to be written from buffer.PortAudioException
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.