PortAudio.java
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00044 package com.portaudio;
00045
00069 public class PortAudio
00070 {
00071 public final static int FLAG_CLIP_OFF = (1 << 0);
00072 public final static int FLAG_DITHER_OFF = (1 << 1);
00073
00075 public final static int FORMAT_FLOAT_32 = (1 << 0);
00076 public final static int FORMAT_INT_32 = (1 << 1);
00077 public final static int FORMAT_INT_24 = (1 << 2);
00078 public final static int FORMAT_INT_16 = (1 << 3);
00079 public final static int FORMAT_INT_8 = (1 << 4);
00080 public final static int FORMAT_UINT_8 = (1 << 5);
00081
00083 public final static int HOST_API_TYPE_DEV = 0;
00084 public final static int HOST_API_TYPE_DIRECTSOUND = 1;
00085 public final static int HOST_API_TYPE_MME = 2;
00086 public final static int HOST_API_TYPE_ASIO = 3;
00088 public final static int HOST_API_TYPE_SOUNDMANAGER = 4;
00089 public final static int HOST_API_TYPE_COREAUDIO = 5;
00090 public final static int HOST_API_TYPE_OSS = 7;
00091 public final static int HOST_API_TYPE_ALSA = 8;
00092 public final static int HOST_API_TYPE_AL = 9;
00093 public final static int HOST_API_TYPE_BEOS = 10;
00094 public final static int HOST_API_TYPE_WDMKS = 11;
00095 public final static int HOST_API_TYPE_JACK = 12;
00096 public final static int HOST_API_TYPE_WASAPI = 13;
00097 public final static int HOST_API_TYPE_AUDIOSCIENCE = 14;
00098 public final static int HOST_API_TYPE_COUNT = 15;
00099
00100 static
00101 {
00102 String os = System.getProperty( "os.name" ).toLowerCase();
00103
00104 if( os.indexOf( "win" ) >= 0 )
00105 {
00106 if( System.getProperty( "os.arch" ).contains( "64" ) )
00107 {
00108 System.loadLibrary( "jportaudio_x64" );
00109 }
00110 else
00111 {
00112 System.loadLibrary( "jportaudio_x86" );
00113 }
00114 }
00115 else
00116 {
00117 System.loadLibrary( "jportaudio" );
00118 }
00119 System.out.println( "---- JPortAudio version " + getVersion() + ", "
00120 + getVersionText() );
00121 }
00122
00127 public native static int getVersion();
00128
00133 public native static String getVersionText();
00134
00142 public native static void initialize();
00143
00152 public native static void terminate();
00153
00158 public native static int getDeviceCount();
00159
00160 private native static void getDeviceInfo( int index, DeviceInfo deviceInfo );
00161
00169 public static DeviceInfo getDeviceInfo( int index )
00170 {
00171 DeviceInfo deviceInfo = new DeviceInfo();
00172 getDeviceInfo( index, deviceInfo );
00173 return deviceInfo;
00174 }
00175
00179 public native static int getHostApiCount();
00180
00181 private native static void getHostApiInfo( int index,
00182 HostApiInfo hostApiInfo );
00183
00188 public static HostApiInfo getHostApiInfo( int index )
00189 {
00190 HostApiInfo hostApiInfo = new HostApiInfo();
00191 getHostApiInfo( index, hostApiInfo );
00192 return hostApiInfo;
00193 }
00194
00201 public native static int hostApiTypeIdToHostApiIndex( int hostApiType );
00202
00211 public native static int hostApiDeviceIndexToDeviceIndex( int hostApiIndex,
00212 int apiDeviceIndex );
00213
00214 public native static int getDefaultInputDevice();
00215
00216 public native static int getDefaultOutputDevice();
00217
00218 public native static int getDefaultHostApi();
00219
00229 public native static int isFormatSupported(
00230 StreamParameters inputStreamParameters,
00231 StreamParameters outputStreamParameters, int sampleRate );
00232
00233 private native static void openStream( BlockingStream blockingStream,
00234 StreamParameters inputStreamParameters,
00235 StreamParameters outputStreamParameters, int sampleRate,
00236 int framesPerBuffer, int flags );
00237
00250 public static BlockingStream openStream(
00251 StreamParameters inputStreamParameters,
00252 StreamParameters outputStreamParameters, int sampleRate,
00253 int framesPerBuffer, int flags )
00254 {
00255 BlockingStream blockingStream = new BlockingStream();
00256 openStream( blockingStream, inputStreamParameters,
00257 outputStreamParameters, sampleRate, framesPerBuffer, flags );
00258 return blockingStream;
00259 }
00260
00261 }