Package com.portaudio

Class 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
    • Constructor Detail

      • PortAudio

        public PortAudio()
    • 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 null
        outputStreamParameters - output description, may be null
        sampleRate - 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 null
        outputStreamParameters - output description, may be null
        sampleRate - typically 44100 or 48000, or maybe 22050, 16000, 8000, 96000
        framesPerBuffer -
        flags -
        Returns: