Package com.portaudio
Class PortAudio
- java.lang.Object
-
- com.portaudio.PortAudio
-
public class PortAudio extends java.lang.Object
Java methods that call PortAudio via JNI. This is a portable audio I/O library that can be used as an alternative to JavaSound. Please see the PortAudio documentation for a full explanation. http://portaudio.com/docs/ http://portaudio.com/docs/v19-doxydocs/portaudio_8h.html This Java binding does not support audio callbacks because an audio callback should never block. Calling into a Java virtual machine might block for garbage collection or synchronization. So only the blocking read/write mode is supported.- Author:
- Phil Burk
- See Also:
BlockingStream
,DeviceInfo
,HostApiInfo
,StreamInfo
,StreamParameters
-
-
Field Summary
Fields Modifier and Type Field Description static int
FLAG_CLIP_OFF
static int
FLAG_DITHER_OFF
static int
FORMAT_FLOAT_32
Sample Formatsstatic int
FORMAT_INT_16
static int
FORMAT_INT_24
static int
FORMAT_INT_32
static int
FORMAT_INT_8
static int
FORMAT_UINT_8
static int
HOST_API_TYPE_AL
static int
HOST_API_TYPE_ALSA
static int
HOST_API_TYPE_ASIO
static int
HOST_API_TYPE_AUDIOSCIENCE
static int
HOST_API_TYPE_BEOS
static int
HOST_API_TYPE_COREAUDIO
static int
HOST_API_TYPE_COUNT
static int
HOST_API_TYPE_DEV
These HOST_API_TYPES will not change in the future.static int
HOST_API_TYPE_DIRECTSOUND
static int
HOST_API_TYPE_JACK
static int
HOST_API_TYPE_MME
static int
HOST_API_TYPE_OSS
static int
HOST_API_TYPE_SOUNDMANAGER
Apple Sound Manager.static int
HOST_API_TYPE_WASAPI
static int
HOST_API_TYPE_WDMKS
-
Constructor Summary
Constructors Constructor Description PortAudio()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
getDefaultHostApi()
static int
getDefaultInputDevice()
static int
getDefaultOutputDevice()
static int
getDeviceCount()
static DeviceInfo
getDeviceInfo(int index)
static int
getHostApiCount()
static HostApiInfo
getHostApiInfo(int index)
static int
getVersion()
static java.lang.String
getVersionText()
static int
hostApiDeviceIndexToDeviceIndex(int hostApiIndex, int apiDeviceIndex)
static int
hostApiTypeIdToHostApiIndex(int hostApiType)
static void
initialize()
Library initialization function - call this before using PortAudio.static int
isFormatSupported(StreamParameters inputStreamParameters, StreamParameters outputStreamParameters, int sampleRate)
static BlockingStream
openStream(StreamParameters inputStreamParameters, StreamParameters outputStreamParameters, int sampleRate, int framesPerBuffer, int flags)
static void
terminate()
Library termination function - call this when finished using PortAudio.
-
-
-
Field Detail
-
FLAG_CLIP_OFF
public static final int FLAG_CLIP_OFF
- See Also:
- Constant Field Values
-
FLAG_DITHER_OFF
public static final int FLAG_DITHER_OFF
- See Also:
- Constant Field Values
-
FORMAT_FLOAT_32
public static final int FORMAT_FLOAT_32
Sample Formats- See Also:
- Constant Field Values
-
FORMAT_INT_32
public static final int FORMAT_INT_32
- See Also:
- Constant Field Values
-
FORMAT_INT_24
public static final int FORMAT_INT_24
- See Also:
- Constant Field Values
-
FORMAT_INT_16
public static final int FORMAT_INT_16
- See Also:
- Constant Field Values
-
FORMAT_INT_8
public static final int FORMAT_INT_8
- See Also:
- Constant Field Values
-
FORMAT_UINT_8
public static final int FORMAT_UINT_8
- See Also:
- Constant Field Values
-
HOST_API_TYPE_DEV
public static final int HOST_API_TYPE_DEV
These HOST_API_TYPES will not change in the future.- See Also:
- Constant Field Values
-
HOST_API_TYPE_DIRECTSOUND
public static final int HOST_API_TYPE_DIRECTSOUND
- See Also:
- Constant Field Values
-
HOST_API_TYPE_MME
public static final int HOST_API_TYPE_MME
- See Also:
- Constant Field Values
-
HOST_API_TYPE_ASIO
public static final int HOST_API_TYPE_ASIO
- See Also:
- Constant Field Values
-
HOST_API_TYPE_SOUNDMANAGER
public static final int HOST_API_TYPE_SOUNDMANAGER
Apple Sound Manager. Obsolete.- See Also:
- Constant Field Values
-
HOST_API_TYPE_COREAUDIO
public static final int HOST_API_TYPE_COREAUDIO
- See Also:
- Constant Field Values
-
HOST_API_TYPE_OSS
public static final int HOST_API_TYPE_OSS
- See Also:
- Constant Field Values
-
HOST_API_TYPE_ALSA
public static final int HOST_API_TYPE_ALSA
- See Also:
- Constant Field Values
-
HOST_API_TYPE_AL
public static final int HOST_API_TYPE_AL
- See Also:
- Constant Field Values
-
HOST_API_TYPE_BEOS
public static final int HOST_API_TYPE_BEOS
- See Also:
- Constant Field Values
-
HOST_API_TYPE_WDMKS
public static final int HOST_API_TYPE_WDMKS
- See Also:
- Constant Field Values
-
HOST_API_TYPE_JACK
public static final int HOST_API_TYPE_JACK
- See Also:
- Constant Field Values
-
HOST_API_TYPE_WASAPI
public static final int HOST_API_TYPE_WASAPI
- See Also:
- Constant Field Values
-
HOST_API_TYPE_AUDIOSCIENCE
public static final int HOST_API_TYPE_AUDIOSCIENCE
- See Also:
- Constant Field Values
-
HOST_API_TYPE_COUNT
public static final int HOST_API_TYPE_COUNT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getVersion
public static int getVersion()
- Returns:
- the release number of the currently running PortAudio build, eg 1900.
-
getVersionText
public static java.lang.String getVersionText()
- Returns:
- a textual description of the current PortAudio build, eg "PortAudio V19-devel 13 October 2002".
-
initialize
public static void initialize()
Library initialization function - call this before using PortAudio. This function initializes internal data structures and prepares underlying host APIs for use. With the exception of getVersion(), getVersionText(), and getErrorText(), this function MUST be called before using any other PortAudio API functions.
-
terminate
public static void terminate()
Library termination function - call this when finished using PortAudio. This function deallocates all resources allocated by PortAudio since it was initialized by a call to initialize(). In cases where Pa_Initialise() has been called multiple times, each call must be matched with a corresponding call to terminate(). The final matching call to terminate() will automatically close any PortAudio streams that are still open.
-
getDeviceCount
public static int getDeviceCount()
- Returns:
- the number of available devices. The number of available devices may be zero.
-
getDeviceInfo
public static DeviceInfo getDeviceInfo(int index)
- Parameters:
index
- A valid device index in the range 0 to (getDeviceCount()-1)- Returns:
- An DeviceInfo structure.
- Throws:
java.lang.RuntimeException
- if the device parameter is out of range.
-
getHostApiCount
public static int getHostApiCount()
- Returns:
- the number of available host APIs.
-
getHostApiInfo
public static HostApiInfo getHostApiInfo(int index)
- Parameters:
index
-- Returns:
- information about the Host API
-
hostApiTypeIdToHostApiIndex
public static int hostApiTypeIdToHostApiIndex(int hostApiType)
- Parameters:
hostApiType
- A unique host API identifier, for example HOST_API_TYPE_COREAUDIO.- Returns:
- a runtime host API index
-
hostApiDeviceIndexToDeviceIndex
public static int hostApiDeviceIndexToDeviceIndex(int hostApiIndex, int apiDeviceIndex)
- Parameters:
hostApiIndex
- A valid host API index ranging from 0 to (getHostApiCount()-1)apiDeviceIndex
- A valid per-host device index in the range 0 to (getHostApiInfo(hostApi).deviceCount-1)- Returns:
- standard PortAudio device index
-
getDefaultInputDevice
public static int getDefaultInputDevice()
-
getDefaultOutputDevice
public static int getDefaultOutputDevice()
-
getDefaultHostApi
public static int getDefaultHostApi()
-
isFormatSupported
public static int isFormatSupported(StreamParameters inputStreamParameters, StreamParameters outputStreamParameters, int sampleRate)
- Parameters:
inputStreamParameters
- input description, may be nulloutputStreamParameters
- output description, may be nullsampleRate
- typically 44100 or 48000, or maybe 22050, 16000, 8000, 96000- Returns:
- 0 if supported or a negative error
-
openStream
public static BlockingStream openStream(StreamParameters inputStreamParameters, StreamParameters outputStreamParameters, int sampleRate, int framesPerBuffer, int flags)
- Parameters:
inputStreamParameters
- input description, may be nulloutputStreamParameters
- output description, may be nullsampleRate
- typically 44100 or 48000, or maybe 22050, 16000, 8000, 96000framesPerBuffer
-flags
-- Returns:
-
-