PortAudio  2.0
PortAudio.java
Go to the documentation of this file.
1 /*
2  * Portable Audio I/O Library
3  * Java Binding for PortAudio
4  *
5  * Based on the Open Source API proposed by Ross Bencina
6  * Copyright (c) 2008 Ross Bencina
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files
10  * (the "Software"), to deal in the Software without restriction,
11  * including without limitation the rights to use, copy, modify, merge,
12  * publish, distribute, sublicense, and/or sell copies of the Software,
13  * and to permit persons to whom the Software is furnished to do so,
14  * subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
23  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
24  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  */
27 
28 /*
29  * The text above constitutes the entire PortAudio license; however,
30  * the PortAudio community also makes the following non-binding requests:
31  *
32  * Any person wishing to distribute modifications to the Software is
33  * requested to send the modifications to the original developer so that
34  * they can be incorporated into the canonical version. It is also
35  * requested that these non-binding requests be included along with the
36  * license above.
37  */
38 
44 package com.portaudio;
45 
69 public class PortAudio
70 {
71  public final static int FLAG_CLIP_OFF = (1 << 0);
72  public final static int FLAG_DITHER_OFF = (1 << 1);
73 
75  public final static int FORMAT_FLOAT_32 = (1 << 0);
76  public final static int FORMAT_INT_32 = (1 << 1); // not supported
77  public final static int FORMAT_INT_24 = (1 << 2); // not supported
78  public final static int FORMAT_INT_16 = (1 << 3);
79  public final static int FORMAT_INT_8 = (1 << 4); // not supported
80  public final static int FORMAT_UINT_8 = (1 << 5); // not supported
81 
83  public final static int HOST_API_TYPE_DEV = 0;
84  public final static int HOST_API_TYPE_DIRECTSOUND = 1;
85  public final static int HOST_API_TYPE_MME = 2;
86  public final static int HOST_API_TYPE_ASIO = 3;
88  public final static int HOST_API_TYPE_SOUNDMANAGER = 4;
89  public final static int HOST_API_TYPE_COREAUDIO = 5;
90  public final static int HOST_API_TYPE_OSS = 7;
91  public final static int HOST_API_TYPE_ALSA = 8;
92  public final static int HOST_API_TYPE_AL = 9;
93  public final static int HOST_API_TYPE_BEOS = 10;
94  public final static int HOST_API_TYPE_WDMKS = 11;
95  public final static int HOST_API_TYPE_JACK = 12;
96  public final static int HOST_API_TYPE_WASAPI = 13;
97  public final static int HOST_API_TYPE_AUDIOSCIENCE = 14;
98  public final static int HOST_API_TYPE_COUNT = 15;
99 
100  static
101  {
102  String os = System.getProperty( "os.name" ).toLowerCase();
103  // On Windows we have separate libraries for 32 and 64-bit JVMs.
104  if( os.indexOf( "win" ) >= 0 )
105  {
106  if( System.getProperty( "os.arch" ).contains( "64" ) )
107  {
108  System.loadLibrary( "jportaudio_x64" );
109  }
110  else
111  {
112  System.loadLibrary( "jportaudio_x86" );
113  }
114  }
115  else
116  {
117  System.loadLibrary( "jportaudio" );
118  }
119  System.out.println( "---- JPortAudio version " + getVersion() + ", "
120  + getVersionText() );
121  }
122 
127  public native static int getVersion();
128 
133  public native static String getVersionText();
134 
142  public native static void initialize();
143 
152  public native static void terminate();
153 
158  public native static int getDeviceCount();
159 
160  private native static void getDeviceInfo( int index, DeviceInfo deviceInfo );
161 
169  public static DeviceInfo getDeviceInfo( int index )
170  {
171  DeviceInfo deviceInfo = new DeviceInfo();
172  getDeviceInfo( index, deviceInfo );
173  return deviceInfo;
174  }
175 
179  public native static int getHostApiCount();
180 
181  private native static void getHostApiInfo( int index,
182  HostApiInfo hostApiInfo );
183 
188  public static HostApiInfo getHostApiInfo( int index )
189  {
190  HostApiInfo hostApiInfo = new HostApiInfo();
191  getHostApiInfo( index, hostApiInfo );
192  return hostApiInfo;
193  }
194 
201  public native static int hostApiTypeIdToHostApiIndex( int hostApiType );
202 
211  public native static int hostApiDeviceIndexToDeviceIndex( int hostApiIndex,
212  int apiDeviceIndex );
213 
214  public native static int getDefaultInputDevice();
215 
216  public native static int getDefaultOutputDevice();
217 
218  public native static int getDefaultHostApi();
219 
229  public native static int isFormatSupported(
230  StreamParameters inputStreamParameters,
231  StreamParameters outputStreamParameters, int sampleRate );
232 
233  private native static void openStream( BlockingStream blockingStream,
234  StreamParameters inputStreamParameters,
235  StreamParameters outputStreamParameters, int sampleRate,
236  int framesPerBuffer, int flags );
237 
250  public static BlockingStream openStream(
251  StreamParameters inputStreamParameters,
252  StreamParameters outputStreamParameters, int sampleRate,
253  int framesPerBuffer, int flags )
254  {
255  BlockingStream blockingStream = new BlockingStream();
256  openStream( blockingStream, inputStreamParameters,
257  outputStreamParameters, sampleRate, framesPerBuffer, flags );
258  return blockingStream;
259  }
260 
261 }
static native int hostApiTypeIdToHostApiIndex(int hostApiType)
static native void initialize()
static native int isFormatSupported(StreamParameters inputStreamParameters, StreamParameters outputStreamParameters, int sampleRate)
static native int getDeviceCount()
static final int HOST_API_TYPE_SOUNDMANAGER
Definition: PortAudio.java:88
static native String getVersionText()
static HostApiInfo getHostApiInfo(int index)
Definition: PortAudio.java:188
static native int hostApiDeviceIndexToDeviceIndex(int hostApiIndex, int apiDeviceIndex)
static native void terminate()
static final int FORMAT_FLOAT_32
Definition: PortAudio.java:75
static BlockingStream openStream(StreamParameters inputStreamParameters, StreamParameters outputStreamParameters, int sampleRate, int framesPerBuffer, int flags)
Definition: PortAudio.java:250
static native int getVersion()
static native int getHostApiCount()
static final int HOST_API_TYPE_DEV
Definition: PortAudio.java:83
static DeviceInfo getDeviceInfo(int index)
Definition: PortAudio.java:169

Generated for PortAudio by  doxygen1.8.12