summaryrefslogtreecommitdiff
path: root/3rdparty/portaudio/bindings/java/jportaudio
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/portaudio/bindings/java/jportaudio')
-rw-r--r--3rdparty/portaudio/bindings/java/jportaudio/.classpath8
-rw-r--r--3rdparty/portaudio/bindings/java/jportaudio/.project17
-rw-r--r--3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/PlaySine.java89
-rw-r--r--3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java523
-rw-r--r--3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/BlockingStream.java208
-rw-r--r--3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java65
-rw-r--r--3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java61
-rw-r--r--3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/PortAudio.java261
-rw-r--r--3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamInfo.java60
-rw-r--r--3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamParameters.java57
10 files changed, 1349 insertions, 0 deletions
diff --git a/3rdparty/portaudio/bindings/java/jportaudio/.classpath b/3rdparty/portaudio/bindings/java/jportaudio/.classpath
new file mode 100644
index 0000000..6bbd70c
--- /dev/null
+++ b/3rdparty/portaudio/bindings/java/jportaudio/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="jtests"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/3rdparty/portaudio/bindings/java/jportaudio/.project b/3rdparty/portaudio/bindings/java/jportaudio/.project
new file mode 100644
index 0000000..8d2a750
--- /dev/null
+++ b/3rdparty/portaudio/bindings/java/jportaudio/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>JPortAudio</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/PlaySine.java b/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/PlaySine.java
new file mode 100644
index 0000000..ec2cb97
--- /dev/null
+++ b/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/PlaySine.java
@@ -0,0 +1,89 @@
+
+/** @file
+ @ingroup bindings_java
+
+ @brief Example that shows how to play sine waves using JPortAudio.
+*/
+package com.portaudio;
+
+import com.portaudio.TestBasic.SineOscillator;
+
+public class PlaySine
+{
+ /**
+ * Write a sine wave to the stream.
+ * @param stream
+ * @param framesPerBuffer
+ * @param numFrames
+ * @param sampleRate
+ */
+ private void writeSineData( BlockingStream stream, int framesPerBuffer,
+ int numFrames, int sampleRate )
+ {
+ float[] buffer = new float[framesPerBuffer * 2];
+ SineOscillator osc1 = new SineOscillator( 200.0, sampleRate );
+ SineOscillator osc2 = new SineOscillator( 300.0, sampleRate );
+ int framesLeft = numFrames;
+ while( framesLeft > 0 )
+ {
+ int index = 0;
+ int framesToWrite = (framesLeft > framesPerBuffer) ? framesPerBuffer
+ : framesLeft;
+ for( int j = 0; j < framesToWrite; j++ )
+ {
+ buffer[index++] = (float) osc1.next();
+ buffer[index++] = (float) osc2.next();
+ }
+ stream.write( buffer, framesToWrite );
+ framesLeft -= framesToWrite;
+ }
+ }
+
+ /**
+ * Create a stream on the default device then play sine waves.
+ */
+ public void play()
+ {
+ PortAudio.initialize();
+
+ // Get the default device and setup the stream parameters.
+ int deviceId = PortAudio.getDefaultOutputDevice();
+ DeviceInfo deviceInfo = PortAudio.getDeviceInfo( deviceId );
+ double sampleRate = deviceInfo.defaultSampleRate;
+ System.out.println( " deviceId = " + deviceId );
+ System.out.println( " sampleRate = " + sampleRate );
+ System.out.println( " device name = " + deviceInfo.name );
+
+ StreamParameters streamParameters = new StreamParameters();
+ streamParameters.channelCount = 2;
+ streamParameters.device = deviceId;
+ streamParameters.suggestedLatency = deviceInfo.defaultLowOutputLatency;
+ System.out.println( " suggestedLatency = "
+ + streamParameters.suggestedLatency );
+
+ int framesPerBuffer = 256;
+ int flags = 0;
+
+ // Open a stream for output.
+ BlockingStream stream = PortAudio.openStream( null, streamParameters,
+ (int) sampleRate, framesPerBuffer, flags );
+
+ int numFrames = (int) (sampleRate * 4); // enough for 4 seconds
+
+ stream.start();
+
+ writeSineData( stream, framesPerBuffer, numFrames, (int) sampleRate );
+
+ stream.stop();
+ stream.close();
+
+ PortAudio.terminate();
+ System.out.println( "JPortAudio test complete." );
+ }
+
+ public static void main( String[] args )
+ {
+ PlaySine player = new PlaySine();
+ player.play();
+ }
+}
diff --git a/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java b/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java
new file mode 100644
index 0000000..43b8fa7
--- /dev/null
+++ b/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java
@@ -0,0 +1,523 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+package com.portaudio;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the Java bindings for PortAudio.
+ *
+ * @author Phil Burk
+ *
+ */
+public class TestBasic extends TestCase
+{
+
+ public void testDeviceCount()
+ {
+ PortAudio.initialize();
+ assertTrue( "version invalid", (PortAudio.getVersion() > 0) );
+ System.out.println( "getVersion = " + PortAudio.getVersion() );
+ System.out.println( "getVersionText = " + PortAudio.getVersionText() );
+ System.out.println( "getDeviceCount = " + PortAudio.getDeviceCount() );
+ assertTrue( "getDeviceCount", (PortAudio.getDeviceCount() > 0) );
+ PortAudio.terminate();
+ }
+
+ public void testListDevices()
+ {
+ PortAudio.initialize();
+ int count = PortAudio.getDeviceCount();
+ assertTrue( "getDeviceCount", (count > 0) );
+ for( int i = 0; i < count; i++ )
+ {
+ DeviceInfo info = PortAudio.getDeviceInfo( i );
+ System.out.println( "------------------ #" + i );
+ System.out.println( " name = " + info.name );
+ System.out.println( " hostApi = " + info.hostApi );
+ System.out.println( " maxOutputChannels = "
+ + info.maxOutputChannels );
+ System.out.println( " maxInputChannels = "
+ + info.maxInputChannels );
+ System.out.println( " defaultSampleRate = "
+ + info.defaultSampleRate );
+ System.out.printf( " defaultLowInputLatency = %3d msec\n",
+ ((int) (info.defaultLowInputLatency * 1000)) );
+ System.out.printf( " defaultHighInputLatency = %3d msec\n",
+ ((int) (info.defaultHighInputLatency * 1000)) );
+ System.out.printf( " defaultLowOutputLatency = %3d msec\n",
+ ((int) (info.defaultLowOutputLatency * 1000)) );
+ System.out.printf( " defaultHighOutputLatency = %3d msec\n",
+ ((int) (info.defaultHighOutputLatency * 1000)) );
+
+ assertTrue( "some channels",
+ (info.maxOutputChannels + info.maxInputChannels) > 0 );
+ assertTrue( "not too many channels", (info.maxInputChannels < 64) );
+ assertTrue( "not too many channels", (info.maxOutputChannels < 64) );
+ }
+
+ System.out.println( "defaultInput = "
+ + PortAudio.getDefaultInputDevice() );
+ System.out.println( "defaultOutput = "
+ + PortAudio.getDefaultOutputDevice() );
+
+ PortAudio.terminate();
+ }
+
+ public void testHostApis()
+ {
+ PortAudio.initialize();
+ int validApiCount = 0;
+ for( int hostApiType = 0; hostApiType < PortAudio.HOST_API_TYPE_COUNT; hostApiType++ )
+ {
+ int hostApiIndex = PortAudio
+ .hostApiTypeIdToHostApiIndex( hostApiType );
+ if( hostApiIndex >= 0 )
+ {
+ HostApiInfo info = PortAudio.getHostApiInfo( hostApiIndex );
+ System.out.println( "Checking Host API: " + info.name );
+ for( int apiDeviceIndex = 0; apiDeviceIndex < info.deviceCount; apiDeviceIndex++ )
+ {
+ int deviceIndex = PortAudio
+ .hostApiDeviceIndexToDeviceIndex( hostApiIndex,
+ apiDeviceIndex );
+ DeviceInfo deviceInfo = PortAudio
+ .getDeviceInfo( deviceIndex );
+ assertEquals( "host api must match up", hostApiIndex,
+ deviceInfo.hostApi );
+ }
+ validApiCount++;
+ }
+ }
+
+ assertEquals( "host api counts", PortAudio.getHostApiCount(),
+ validApiCount );
+ }
+
+ public void testListHostApis()
+ {
+ PortAudio.initialize();
+ int count = PortAudio.getHostApiCount();
+ assertTrue( "getHostApiCount", (count > 0) );
+ for( int i = 0; i < count; i++ )
+ {
+ HostApiInfo info = PortAudio.getHostApiInfo( i );
+ System.out.println( "------------------ #" + i );
+ System.out.println( " version = " + info.version );
+ System.out.println( " name = " + info.name );
+ System.out.println( " type = " + info.type );
+ System.out.println( " deviceCount = " + info.deviceCount );
+ System.out.println( " defaultInputDevice = "
+ + info.defaultInputDevice );
+ System.out.println( " defaultOutputDevice = "
+ + info.defaultOutputDevice );
+ assertTrue( "some devices", info.deviceCount > 0 );
+ }
+
+ System.out.println( "------\ndefaultHostApi = "
+ + PortAudio.getDefaultHostApi() );
+ PortAudio.terminate();
+ }
+
+ public void testCheckFormat()
+ {
+ PortAudio.initialize();
+ StreamParameters streamParameters = new StreamParameters();
+ streamParameters.device = PortAudio.getDefaultOutputDevice();
+ int result = PortAudio
+ .isFormatSupported( null, streamParameters, 44100 );
+ System.out.println( "isFormatSupported returns " + result );
+ assertEquals( "default output format", 0, result );
+ // Try crazy channelCount
+ streamParameters.channelCount = 8765;
+ result = PortAudio.isFormatSupported( null, streamParameters, 44100 );
+ System.out.println( "crazy isFormatSupported returns " + result );
+ assertTrue( "default output format", (result < 0) );
+ PortAudio.terminate();
+ }
+
+ static class SineOscillator
+ {
+ double phase = 0.0;
+ double phaseIncrement = 0.01;
+
+ SineOscillator(double freq, int sampleRate)
+ {
+ phaseIncrement = freq * Math.PI * 2.0 / sampleRate;
+ }
+
+ double next()
+ {
+ double value = Math.sin( phase );
+ phase += phaseIncrement;
+ if( phase > Math.PI )
+ {
+ phase -= Math.PI * 2.0;
+ }
+ return value;
+ }
+ }
+
+ public void testStreamError()
+ {
+ PortAudio.initialize();
+ StreamParameters streamParameters = new StreamParameters();
+ streamParameters.sampleFormat = PortAudio.FORMAT_FLOAT_32;
+ streamParameters.channelCount = 2;
+ streamParameters.device = PortAudio.getDefaultOutputDevice();
+ int framesPerBuffer = 256;
+ int flags = 0;
+ BlockingStream stream = PortAudio.openStream( null, streamParameters,
+ 44100, framesPerBuffer, flags );
+
+ // Try to write data to a stopped stream.
+ Throwable caught = null;
+ try
+ {
+ float[] buffer = new float[framesPerBuffer
+ * streamParameters.channelCount];
+ stream.write( buffer, framesPerBuffer );
+ } catch( Throwable e )
+ {
+ caught = e;
+ e.printStackTrace();
+ }
+
+ assertTrue( "caught no exception", (caught != null) );
+ assertTrue( "exception should say stream is stopped", caught
+ .getMessage().contains( "stopped" ) );
+
+ // Try to write null data.
+ caught = null;
+ try
+ {
+ stream.write( (float[]) null, framesPerBuffer );
+ } catch( Throwable e )
+ {
+ caught = e;
+ e.printStackTrace();
+ }
+ assertTrue( "caught no exception", (caught != null) );
+ assertTrue( "exception should say stream is stopped", caught
+ .getMessage().contains( "null" ) );
+
+ // Try to write short data to a float stream.
+ stream.start();
+ caught = null;
+ try
+ {
+ short[] buffer = new short[framesPerBuffer
+ * streamParameters.channelCount];
+ stream.write( buffer, framesPerBuffer );
+ } catch( Throwable e )
+ {
+ caught = e;
+ e.printStackTrace();
+ }
+
+ assertTrue( "caught no exception", (caught != null) );
+ assertTrue( "exception should say tried to", caught.getMessage()
+ .contains( "Tried to write short" ) );
+
+ stream.close();
+
+ PortAudio.terminate();
+ }
+
+ public void checkBlockingWriteFloat( int deviceId, double sampleRate )
+ {
+ StreamParameters streamParameters = new StreamParameters();
+ streamParameters.channelCount = 2;
+ streamParameters.device = deviceId;
+ streamParameters.suggestedLatency = PortAudio
+ .getDeviceInfo( streamParameters.device ).defaultLowOutputLatency;
+ System.out.println( "suggestedLatency = "
+ + streamParameters.suggestedLatency );
+
+ int framesPerBuffer = 256;
+ int flags = 0;
+ BlockingStream stream = PortAudio.openStream( null, streamParameters,
+ (int) sampleRate, framesPerBuffer, flags );
+ assertTrue( "got default stream", stream != null );
+
+ assertEquals( "stream isStopped", true, stream.isStopped() );
+ assertEquals( "stream isActive", false, stream.isActive() );
+
+ int numFrames = 80000;
+ double expected = ((double)numFrames) / sampleRate;
+ stream.start();
+ long startTime = System.currentTimeMillis();
+ double startStreamTime = stream.getTime();
+ assertEquals( "stream isStopped", false, stream.isStopped() );
+ assertEquals( "stream isActive", true, stream.isActive() );
+
+ writeSineData( stream, framesPerBuffer, numFrames, (int) sampleRate );
+
+ StreamInfo streamInfo = stream.getInfo();
+ System.out.println( "inputLatency of a stream = "+ streamInfo.inputLatency );
+ System.out.println( "outputLatency of a stream = "+streamInfo.outputLatency );
+ System.out.println( "sampleRate of a stream = "+ streamInfo.sampleRate );
+
+ assertEquals( "inputLatency of a stream ", 0.0, streamInfo.inputLatency, 0.000001 );
+ assertTrue( "outputLatency of a stream ",(streamInfo.outputLatency > 0) );
+ assertEquals( "sampleRate of a stream ", sampleRate, streamInfo.sampleRate, 3 );
+
+ double endStreamTime = stream.getTime();
+ stream.stop();
+ long stopTime = System.currentTimeMillis();
+
+ System.out.println( "startStreamTime = " + startStreamTime );
+ System.out.println( "endStreamTime = " + endStreamTime );
+ double elapsedStreamTime = endStreamTime - startStreamTime;
+ System.out.println( "elapsedStreamTime = " + elapsedStreamTime );
+ assertTrue( "elapsedStreamTime: " + elapsedStreamTime,
+ (elapsedStreamTime > 0.0) );
+ assertEquals( "elapsedStreamTime: ", expected, elapsedStreamTime, 0.10 );
+
+ assertEquals( "stream isStopped", true, stream.isStopped() );
+ assertEquals( "stream isActive", false, stream.isActive() );
+ stream.close();
+
+ double elapsed = (stopTime - startTime) / 1000.0;
+ assertEquals( "elapsed time to play", expected, elapsed, 0.20 );
+ }
+
+ public void testBlockingWriteFloat()
+ {
+ PortAudio.initialize();
+ checkBlockingWriteFloat( PortAudio.getDefaultOutputDevice(), 44100 );
+ PortAudio.terminate();
+ }
+
+ public void ZtestWriteEachHostAPI()
+ {
+ PortAudio.initialize();
+ for( int hostApiIndex = 0; hostApiIndex < PortAudio.getHostApiCount(); hostApiIndex++ )
+ {
+ HostApiInfo hostInfo = PortAudio.getHostApiInfo( hostApiIndex );
+ System.out.println( "-------------\nWriting using Host API: " + hostInfo.name );
+ int deviceId = hostInfo.defaultOutputDevice;
+ System.out.println( " Device ID =" + deviceId );
+ DeviceInfo deviceInfo = PortAudio.getDeviceInfo( deviceId );
+ System.out.println( " sampleRate =" + deviceInfo.defaultSampleRate );
+ checkBlockingWriteFloat( deviceId,
+ (int) deviceInfo.defaultSampleRate );
+ System.out.println( "Finished with " + hostInfo.name );
+ }
+ PortAudio.terminate();
+ }
+
+ private void writeSineData( BlockingStream stream, int framesPerBuffer,
+ int numFrames, int sampleRate )
+ {
+ float[] buffer = new float[framesPerBuffer * 2];
+ SineOscillator osc1 = new SineOscillator( 200.0, sampleRate );
+ SineOscillator osc2 = new SineOscillator( 300.0, sampleRate );
+ int framesLeft = numFrames;
+ while( framesLeft > 0 )
+ {
+ int index = 0;
+ int framesToWrite = (framesLeft > framesPerBuffer) ? framesPerBuffer
+ : framesLeft;
+ for( int j = 0; j < framesToWrite; j++ )
+ {
+ buffer[index++] = (float) osc1.next();
+ buffer[index++] = (float) osc2.next();
+ }
+ stream.write( buffer, framesToWrite );
+ framesLeft -= framesToWrite;
+ }
+ }
+
+ private void writeSineDataShort( BlockingStream stream,
+ int framesPerBuffer, int numFrames )
+ {
+ short[] buffer = new short[framesPerBuffer * 2];
+ SineOscillator osc1 = new SineOscillator( 200.0, 44100 );
+ SineOscillator osc2 = new SineOscillator( 300.0, 44100 );
+ int framesLeft = numFrames;
+ while( framesLeft > 0 )
+ {
+ int index = 0;
+ int framesToWrite = (framesLeft > framesPerBuffer) ? framesPerBuffer
+ : framesLeft;
+ for( int j = 0; j < framesToWrite; j++ )
+ {
+ buffer[index++] = (short) (osc1.next() * 32767);
+ buffer[index++] = (short) (osc2.next() * 32767);
+ }
+ stream.write( buffer, framesToWrite );
+ framesLeft -= framesToWrite;
+ }
+ }
+
+ public void testBlockingWriteShort()
+ {
+ PortAudio.initialize();
+
+ StreamParameters streamParameters = new StreamParameters();
+ streamParameters.sampleFormat = PortAudio.FORMAT_INT_16;
+ streamParameters.channelCount = 2;
+ streamParameters.device = PortAudio.getDefaultOutputDevice();
+ streamParameters.suggestedLatency = PortAudio
+ .getDeviceInfo( streamParameters.device ).defaultLowOutputLatency;
+ System.out.println( "suggestedLatency = "
+ + streamParameters.suggestedLatency );
+
+ int framesPerBuffer = 256;
+ int flags = 0;
+ BlockingStream stream = PortAudio.openStream( null, streamParameters,
+ 44100, framesPerBuffer, flags );
+ assertTrue( "got default stream", stream != null );
+
+ int numFrames = 80000;
+ stream.start();
+ long startTime = System.currentTimeMillis();
+ writeSineDataShort( stream, framesPerBuffer, numFrames );
+ stream.stop();
+ long stopTime = System.currentTimeMillis();
+ stream.close();
+
+ double elapsed = (stopTime - startTime) / 1000.0;
+ double expected = numFrames / 44100.0;
+ assertEquals( "elapsed time to play", expected, elapsed, 0.20 );
+ PortAudio.terminate();
+ }
+
+ public void testRecordPlayFloat() throws InterruptedException
+ {
+ checkRecordPlay( PortAudio.FORMAT_FLOAT_32 );
+ }
+
+ public void testRecordPlayShort() throws InterruptedException
+ {
+ checkRecordPlay( PortAudio.FORMAT_INT_16 );
+ }
+
+ public void checkRecordPlay( int sampleFormat ) throws InterruptedException
+ {
+ int framesPerBuffer = 256;
+ int flags = 0;
+ int sampleRate = 44100;
+ int numFrames = sampleRate * 3;
+ float[] floatBuffer = null;
+ short[] shortBuffer = null;
+
+ PortAudio.initialize();
+ StreamParameters inParameters = new StreamParameters();
+ inParameters.sampleFormat = sampleFormat;
+ inParameters.device = PortAudio.getDefaultInputDevice();
+
+ DeviceInfo info = PortAudio.getDeviceInfo( inParameters.device );
+ inParameters.channelCount = (info.maxInputChannels > 2) ? 2
+ : info.maxInputChannels;
+ System.out.println( "channelCount = " + inParameters.channelCount );
+ inParameters.suggestedLatency = PortAudio
+ .getDeviceInfo( inParameters.device ).defaultLowInputLatency;
+
+ if( sampleFormat == PortAudio.FORMAT_FLOAT_32 )
+ {
+ floatBuffer = new float[numFrames * inParameters.channelCount];
+ }
+ else if( sampleFormat == PortAudio.FORMAT_INT_16 )
+ {
+ shortBuffer = new short[numFrames * inParameters.channelCount];
+ }
+ // Record a few seconds of audio.
+ BlockingStream inStream = PortAudio.openStream( inParameters, null,
+ sampleRate, framesPerBuffer, flags );
+
+ System.out.println( "RECORDING - say something like testing 1,2,3..." );
+ inStream.start();
+
+ if( sampleFormat == PortAudio.FORMAT_FLOAT_32 )
+ {
+ inStream.read( floatBuffer, numFrames );
+ }
+ else if( sampleFormat == PortAudio.FORMAT_INT_16 )
+ {
+ inStream.read( shortBuffer, numFrames );
+ }
+ Thread.sleep( 100 );
+ int availableToRead = inStream.getReadAvailable();
+ System.out.println( "availableToRead = " + availableToRead );
+ assertTrue( "getReadAvailable ", availableToRead > 0 );
+
+ inStream.stop();
+ inStream.close();
+ System.out.println( "Finished recording. Begin Playback." );
+
+ // Play back what we recorded.
+ StreamParameters outParameters = new StreamParameters();
+ outParameters.sampleFormat = sampleFormat;
+ outParameters.channelCount = inParameters.channelCount;
+ outParameters.device = PortAudio.getDefaultOutputDevice();
+ outParameters.suggestedLatency = PortAudio
+ .getDeviceInfo( outParameters.device ).defaultLowOutputLatency;
+
+ BlockingStream outStream = PortAudio.openStream( null, outParameters,
+ sampleRate, framesPerBuffer, flags );
+ assertTrue( "got default stream", outStream != null );
+
+ assertEquals( "inStream isActive", false, inStream.isActive() );
+
+ outStream.start();
+ Thread.sleep( 100 );
+ int availableToWrite = outStream.getWriteAvailable();
+ System.out.println( "availableToWrite = " + availableToWrite );
+ assertTrue( "getWriteAvailable ", availableToWrite > 0 );
+
+ System.out.println( "inStream = " + inStream );
+ System.out.println( "outStream = " + outStream );
+ assertEquals( "inStream isActive", false, inStream.isActive() );
+ assertEquals( "outStream isActive", true, outStream.isActive() );
+ if( sampleFormat == PortAudio.FORMAT_FLOAT_32 )
+ {
+ outStream.write( floatBuffer, numFrames );
+ }
+ else if( sampleFormat == PortAudio.FORMAT_INT_16 )
+ {
+ outStream.write( shortBuffer, numFrames );
+ }
+ outStream.stop();
+
+ outStream.close();
+ PortAudio.terminate();
+ }
+}
diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/BlockingStream.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/BlockingStream.java
new file mode 100644
index 0000000..4c249ab
--- /dev/null
+++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/BlockingStream.java
@@ -0,0 +1,208 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+/** @file
+ @ingroup bindings_java
+
+ @brief A blocking read/write stream.
+*/
+package com.portaudio;
+
+/**
+ * Represents a stream for blocking read/write I/O.
+ *
+ * This Java object contains the pointer to a PortAudio stream stored as a long.
+ * It is passed to PortAudio when calling stream related functions.
+ *
+ * To create one of these, call PortAudio.openStream().
+ *
+ * @see PortAudio
+ *
+ * @author Phil Burk
+ *
+ */
+public class BlockingStream
+{
+ // nativeStream is only accessed by the native code. It contains a pointer
+ // to a PaStream.
+ private long nativeStream;
+ private int inputFormat = -1;
+ private int outputFormat = -1;
+
+ protected BlockingStream()
+ {
+ }
+
+ /**
+ * @return number of frames that can be read without blocking.
+ */
+ public native int getReadAvailable();
+
+ /**
+ * @return number of frames that can be written without blocking.
+ */
+ public native int getWriteAvailable();
+
+ private native boolean readFloats( float[] buffer, int numFrames );
+
+ private native boolean writeFloats( float[] buffer, int numFrames );
+
+ /**
+ * Read 32-bit floating point data from the stream into the array.
+ *
+ * @param buffer
+ * @param numFrames
+ * number of frames to read
+ * @return true if an input overflow occurred
+ */
+ public boolean read( float[] buffer, int numFrames )
+ {
+ if( inputFormat != PortAudio.FORMAT_FLOAT_32 )
+ {
+ throw new RuntimeException(
+ "Tried to read float samples from a non float stream." );
+ }
+ return readFloats( buffer, numFrames );
+ }
+
+ /**
+ * Write 32-bit floating point data to the stream from the array. The data
+ * should be in the range -1.0 to +1.0.
+ *
+ * @param buffer
+ * @param numFrames
+ * number of frames to write
+ * @return true if an output underflow occurred
+ */
+ public boolean write( float[] buffer, int numFrames )
+ {
+ if( outputFormat != PortAudio.FORMAT_FLOAT_32 )
+ {
+ throw new RuntimeException(
+ "Tried to write float samples to a non float stream." );
+ }
+ return writeFloats( buffer, numFrames );
+ }
+
+ private native boolean readShorts( short[] buffer, int numFrames );
+
+ private native boolean writeShorts( short[] buffer, int numFrames );
+
+ /**
+ * Read 16-bit integer data to the stream from the array.
+ *
+ * @param buffer
+ * @param numFrames
+ * number of frames to write
+ * @return true if an input overflow occurred
+ */
+ public boolean read( short[] buffer, int numFrames )
+ {
+ if( inputFormat != PortAudio.FORMAT_INT_16 )
+ {
+ throw new RuntimeException(
+ "Tried to read short samples from a non short stream." );
+ }
+ return readShorts( buffer, numFrames );
+ }
+
+ /**
+ * Write 16-bit integer data to the stream from the array.
+ *
+ * @param buffer
+ * @param numFrames
+ * number of frames to write
+ * @return true if an output underflow occurred
+ */
+ public boolean write( short[] buffer, int numFrames )
+ {
+ if( outputFormat != PortAudio.FORMAT_INT_16 )
+ {
+ throw new RuntimeException(
+ "Tried to write short samples from a non short stream." );
+ }
+ return writeShorts( buffer, numFrames );
+ }
+
+ /**
+ * Atart audio I/O.
+ */
+ public native void start();
+
+ /**
+ * Wait for the stream to play all of the data that has been written then
+ * stop.
+ */
+ public native void stop();
+
+ /**
+ * Stop immediately and lose any data that was written but not played.
+ */
+ public native void abort();
+
+ /**
+ * Close the stream and zero out the pointer. Do not reference the stream
+ * after this.
+ */
+ public native void close();
+
+ public native boolean isStopped();
+
+ public native boolean isActive();
+
+ public String toString()
+ {
+ return "BlockingStream: streamPtr = " + Long.toHexString( nativeStream )
+ + ", inFormat = " + inputFormat + ", outFormat = "
+ + outputFormat;
+ }
+
+ /**
+ * Get audio time related to this stream. Note that it may not start at 0.0.
+ */
+ public native double getTime();
+
+ private native void getInfo( StreamInfo streamInfo );
+
+ public StreamInfo getInfo()
+ {
+ StreamInfo streamInfo = new StreamInfo();
+ getInfo( streamInfo );
+ return streamInfo;
+ }
+}
diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java
new file mode 100644
index 0000000..1c4682e
--- /dev/null
+++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java
@@ -0,0 +1,65 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+/** @file
+ @ingroup bindings_java
+
+ @brief Information about a JPortAudio device.
+*/
+package com.portaudio;
+
+/**
+ * Equivalent to PaDeviceInfo
+ * @see PortAudio
+ * @see HostApiInfo
+ * @author Phil Burk
+ *
+ */
+public class DeviceInfo
+{
+ public int version;
+ public String name;
+ public int hostApi;
+ public int maxInputChannels;
+ public int maxOutputChannels;
+ public double defaultLowInputLatency;
+ public double defaultHighInputLatency;
+ public double defaultLowOutputLatency;
+ public double defaultHighOutputLatency;
+ public double defaultSampleRate;
+}
diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java
new file mode 100644
index 0000000..dc2cdce
--- /dev/null
+++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java
@@ -0,0 +1,61 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+/** @file
+ @ingroup bindings_java
+
+ @brief Information about a JPortAudio Host API.
+*/
+package com.portaudio;
+
+/**
+ * Equivalent to PaHostApiInfo
+ * @see PortAudio
+ * @see DeviceInfo
+ * @author Phil Burk
+ *
+ */
+public class HostApiInfo
+{
+ public int version;
+ public int type;
+ public String name;
+ public int deviceCount;
+ public int defaultInputDevice;
+ public int defaultOutputDevice;
+}
diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/PortAudio.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/PortAudio.java
new file mode 100644
index 0000000..41b3c67
--- /dev/null
+++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/PortAudio.java
@@ -0,0 +1,261 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+/** @file
+ @ingroup bindings_java
+
+ @brief Java wrapper for the PortAudio API.
+*/
+package com.portaudio;
+
+/**
+ * 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.
+ *
+ * @see BlockingStream
+ * @see DeviceInfo
+ * @see HostApiInfo
+ * @see StreamInfo
+ * @see StreamParameters
+ *
+ * @author Phil Burk
+ *
+ */
+public class PortAudio
+{
+ public final static int FLAG_CLIP_OFF = (1 << 0);
+ public final static int FLAG_DITHER_OFF = (1 << 1);
+
+ /** Sample Formats */
+ public final static int FORMAT_FLOAT_32 = (1 << 0);
+ public final static int FORMAT_INT_32 = (1 << 1); // not supported
+ public final static int FORMAT_INT_24 = (1 << 2); // not supported
+ public final static int FORMAT_INT_16 = (1 << 3);
+ public final static int FORMAT_INT_8 = (1 << 4); // not supported
+ public final static int FORMAT_UINT_8 = (1 << 5); // not supported
+
+ /** These HOST_API_TYPES will not change in the future. */
+ public final static int HOST_API_TYPE_DEV = 0;
+ public final static int HOST_API_TYPE_DIRECTSOUND = 1;
+ public final static int HOST_API_TYPE_MME = 2;
+ public final static int HOST_API_TYPE_ASIO = 3;
+ /** Apple Sound Manager. Obsolete. */
+ public final static int HOST_API_TYPE_SOUNDMANAGER = 4;
+ public final static int HOST_API_TYPE_COREAUDIO = 5;
+ public final static int HOST_API_TYPE_OSS = 7;
+ public final static int HOST_API_TYPE_ALSA = 8;
+ public final static int HOST_API_TYPE_AL = 9;
+ public final static int HOST_API_TYPE_BEOS = 10;
+ public final static int HOST_API_TYPE_WDMKS = 11;
+ public final static int HOST_API_TYPE_JACK = 12;
+ public final static int HOST_API_TYPE_WASAPI = 13;
+ public final static int HOST_API_TYPE_AUDIOSCIENCE = 14;
+ public final static int HOST_API_TYPE_COUNT = 15;
+
+ static
+ {
+ String os = System.getProperty( "os.name" ).toLowerCase();
+ // On Windows we have separate libraries for 32 and 64-bit JVMs.
+ if( os.indexOf( "win" ) >= 0 )
+ {
+ if( System.getProperty( "os.arch" ).contains( "64" ) )
+ {
+ System.loadLibrary( "jportaudio_x64" );
+ }
+ else
+ {
+ System.loadLibrary( "jportaudio_x86" );
+ }
+ }
+ else
+ {
+ System.loadLibrary( "jportaudio" );
+ }
+ System.out.println( "---- JPortAudio version " + getVersion() + ", "
+ + getVersionText() );
+ }
+
+ /**
+ * @return the release number of the currently running PortAudio build, eg
+ * 1900.
+ */
+ public native static int getVersion();
+
+ /**
+ * @return a textual description of the current PortAudio build, eg
+ * "PortAudio V19-devel 13 October 2002".
+ */
+ public native static String getVersionText();
+
+ /**
+ * 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.
+ */
+ public native static void initialize();
+
+ /**
+ * 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.
+ */
+ public native static void terminate();
+
+ /**
+ * @return the number of available devices. The number of available devices
+ * may be zero.
+ */
+ public native static int getDeviceCount();
+
+ private native static void getDeviceInfo( int index, DeviceInfo deviceInfo );
+
+ /**
+ * @param index
+ * A valid device index in the range 0 to (getDeviceCount()-1)
+ * @return An DeviceInfo structure.
+ * @throws RuntimeException
+ * if the device parameter is out of range.
+ */
+ public static DeviceInfo getDeviceInfo( int index )
+ {
+ DeviceInfo deviceInfo = new DeviceInfo();
+ getDeviceInfo( index, deviceInfo );
+ return deviceInfo;
+ }
+
+ /**
+ * @return the number of available host APIs.
+ */
+ public native static int getHostApiCount();
+
+ private native static void getHostApiInfo( int index,
+ HostApiInfo hostApiInfo );
+
+ /**
+ * @param index
+ * @return information about the Host API
+ */
+ public static HostApiInfo getHostApiInfo( int index )
+ {
+ HostApiInfo hostApiInfo = new HostApiInfo();
+ getHostApiInfo( index, hostApiInfo );
+ return hostApiInfo;
+ }
+
+ /**
+ * @param hostApiType
+ * A unique host API identifier, for example
+ * HOST_API_TYPE_COREAUDIO.
+ * @return a runtime host API index
+ */
+ public native static int hostApiTypeIdToHostApiIndex( int hostApiType );
+
+ /**
+ * @param hostApiIndex
+ * A valid host API index ranging from 0 to (getHostApiCount()-1)
+ * @param apiDeviceIndex
+ * A valid per-host device index in the range 0 to
+ * (getHostApiInfo(hostApi).deviceCount-1)
+ * @return standard PortAudio device index
+ */
+ public native static int hostApiDeviceIndexToDeviceIndex( int hostApiIndex,
+ int apiDeviceIndex );
+
+ public native static int getDefaultInputDevice();
+
+ public native static int getDefaultOutputDevice();
+
+ public native static int getDefaultHostApi();
+
+ /**
+ * @param inputStreamParameters
+ * input description, may be null
+ * @param outputStreamParameters
+ * output description, may be null
+ * @param sampleRate
+ * typically 44100 or 48000, or maybe 22050, 16000, 8000, 96000
+ * @return 0 if supported or a negative error
+ */
+ public native static int isFormatSupported(
+ StreamParameters inputStreamParameters,
+ StreamParameters outputStreamParameters, int sampleRate );
+
+ private native static void openStream( BlockingStream blockingStream,
+ StreamParameters inputStreamParameters,
+ StreamParameters outputStreamParameters, int sampleRate,
+ int framesPerBuffer, int flags );
+
+ /**
+ *
+ * @param inputStreamParameters
+ * input description, may be null
+ * @param outputStreamParameters
+ * output description, may be null
+ * @param sampleRate
+ * typically 44100 or 48000, or maybe 22050, 16000, 8000, 96000
+ * @param framesPerBuffer
+ * @param flags
+ * @return
+ */
+ public static BlockingStream openStream(
+ StreamParameters inputStreamParameters,
+ StreamParameters outputStreamParameters, int sampleRate,
+ int framesPerBuffer, int flags )
+ {
+ BlockingStream blockingStream = new BlockingStream();
+ openStream( blockingStream, inputStreamParameters,
+ outputStreamParameters, sampleRate, framesPerBuffer, flags );
+ return blockingStream;
+ }
+
+}
diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamInfo.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamInfo.java
new file mode 100644
index 0000000..685f94d
--- /dev/null
+++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamInfo.java
@@ -0,0 +1,60 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+
+/** @file
+ @ingroup bindings_java
+
+ @brief Information about a JPortAudio Stream.
+*/
+
+package com.portaudio;
+
+/**
+ * Equivalent to PaStreamInfo
+ * @see PortAudio
+ * @author Phil Burk
+ *
+ */
+public class StreamInfo
+{
+ public int structVersion;
+ public double outputLatency;
+ public double inputLatency;
+ public double sampleRate;
+}
diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamParameters.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamParameters.java
new file mode 100644
index 0000000..707dab5
--- /dev/null
+++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamParameters.java
@@ -0,0 +1,57 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+/** @file
+ @ingroup bindings_java
+
+ @brief Options to use when opening a stream.
+*/
+package com.portaudio;
+/**
+ * Equivalent to PaStreamParameters
+ * @see PortAudio
+ * @author Phil Burk
+ *
+ */
+public class StreamParameters
+{
+ public int device = 0;
+ public int channelCount = 2;
+ public int sampleFormat = PortAudio.FORMAT_FLOAT_32;
+ public double suggestedLatency = 0.050;
+}