]> Repos - portaudio/commitdiff
Initial check-in for an experimental Java binding for PortAudio called JPortAudio.
authorphilburk <philburk@0f58301d-fd10-0410-b4af-bbb618454e57>
Sat, 1 Sep 2012 18:43:58 +0000 (18:43 +0000)
committerphilburk <philburk@0f58301d-fd10-0410-b4af-bbb618454e57>
Sat, 1 Sep 2012 18:43:58 +0000 (18:43 +0000)
24 files changed:
Doxyfile
Doxyfile.developer
bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.sln [new file with mode: 0644]
bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcproj [new file with mode: 0644]
bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcxproj [new file with mode: 0644]
bindings/java/c/src/com_portaudio_BlockingStream.c [new file with mode: 0644]
bindings/java/c/src/com_portaudio_BlockingStream.h [new file with mode: 0644]
bindings/java/c/src/com_portaudio_PortAudio.c [new file with mode: 0644]
bindings/java/c/src/com_portaudio_PortAudio.h [new file with mode: 0644]
bindings/java/c/src/jpa_tools.c [new file with mode: 0644]
bindings/java/c/src/jpa_tools.h [new file with mode: 0644]
bindings/java/jportaudio.dox [new file with mode: 0644]
bindings/java/jportaudio/.classpath [new file with mode: 0644]
bindings/java/jportaudio/.project [new file with mode: 0644]
bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java [new file with mode: 0644]
bindings/java/jportaudio/src/com/portaudio/BlockingStream.java [new file with mode: 0644]
bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java [new file with mode: 0644]
bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java [new file with mode: 0644]
bindings/java/jportaudio/src/com/portaudio/PortAudio.java [new file with mode: 0644]
bindings/java/jportaudio/src/com/portaudio/StreamInfo.java [new file with mode: 0644]
bindings/java/jportaudio/src/com/portaudio/StreamParameters.java [new file with mode: 0644]
bindings/java/scripts/make_header.bat [new file with mode: 0644]
doc/src/mainpage.dox
doc/src/tutorial/tutorial_start.dox

index 33b9aae67cd71f3b23df442f469f17ff6b2ce505..6680898497d24f9f1f75ae65e81f2cae55ae5361 100644 (file)
--- a/Doxyfile
+++ b/Doxyfile
@@ -84,6 +84,7 @@ WARN_LOGFILE           =
 #---------------------------------------------------------------------------
 INPUT                  = doc/src \
                          include \
+                         bindings/java \
                          examples
 FILE_PATTERNS          = *.h \
                          *.c \
index f018ed3e003c8cefce9a9efd628b771a75f8ab82..b9fa931c6af9ed66938439278ec2a09a3b7d47ec 100644 (file)
@@ -84,6 +84,7 @@ WARN_LOGFILE           =
 #---------------------------------------------------------------------------\r
 INPUT                  = doc/src \\r
                          include \\r
+                         bindings/java \\r
                          examples \          \r
                          src \\r
                          test \\r
diff --git a/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.sln b/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.sln
new file mode 100644 (file)
index 0000000..829bd67
--- /dev/null
@@ -0,0 +1,26 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 11.00\r
+# Visual Studio 2010\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PortAudioJNI", "PortAudioJNI.vcxproj", "{4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Debug|x64 = Debug|x64\r
+               Release|Win32 = Release|Win32\r
+               Release|x64 = Release|x64\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Debug|Win32.Build.0 = Debug|Win32\r
+               {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Debug|x64.ActiveCfg = Debug|x64\r
+               {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Debug|x64.Build.0 = Debug|x64\r
+               {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Release|Win32.ActiveCfg = Release|Win32\r
+               {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Release|Win32.Build.0 = Release|Win32\r
+               {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Release|x64.ActiveCfg = Release|x64\r
+               {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Release|x64.Build.0 = Release|x64\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcproj b/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcproj
new file mode 100644 (file)
index 0000000..e66cd56
--- /dev/null
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="9.00"\r
+       Name="PortAudioJNI"\r
+       ProjectGUID="{4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}"\r
+       RootNamespace="PortAudioJNI"\r
+       Keyword="Win32Proj"\r
+       TargetFrameworkVersion="196613"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="..\..\..\..\jportaudio"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       CharacterSet="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="C:\glassfish3\jdk\include;C:\glassfish3\jdk\include\win32"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               EnableIntrinsicFunctions="true"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="2"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\src\com_portaudio_PortAudio.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\src\com_portaudio_PortAudio.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcxproj b/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcxproj
new file mode 100644 (file)
index 0000000..d9ebb48
--- /dev/null
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|x64">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|x64">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}</ProjectGuid>\r
+    <RootNamespace>PortAudioJNI</RootNamespace>\r
+    <Keyword>Win32Proj</Keyword>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
+    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
+    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup>\r
+    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\..\..\jportaudio\</OutDir>\r
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\..\..\jportaudio\</OutDir>\r
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>\r
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>\r
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>\r
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>\r
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\..\..\jportaudio</OutDir>\r
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\..\..\jportaudio</OutDir>\r
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>\r
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir>\r
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>\r
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>\r
+    <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">jportaudio_x64</TargetName>\r
+    <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">jportaudio_x86</TargetName>\r
+    <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">jportaudio_x86</TargetName>\r
+    <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">jportaudio_x64</TargetName>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <Optimization>Disabled</Optimization>\r
+      <AdditionalIncludeDirectories>C:\glassfish3\jdk\include;C:\glassfish3\jdk\include\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <MinimalRebuild>true</MinimalRebuild>\r
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <SubSystem>Windows</SubSystem>\r
+      <TargetMachine>MachineX86</TargetMachine>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <ClCompile>\r
+      <Optimization>Disabled</Optimization>\r
+      <AdditionalIncludeDirectories>C:\Users\phil\Work\portaudio\pasvn\include;C:\glassfish3\jdk\include;C:\glassfish3\jdk\include\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <SubSystem>Windows</SubSystem>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r
+      <AdditionalIncludeDirectories>C:\Users\phil\Work\portaudio\pasvn\include;C:\glassfish3\jdk\include;C:\glassfish3\jdk\include\win32</AdditionalIncludeDirectories>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <SubSystem>Windows</SubSystem>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <TargetMachine>MachineX86</TargetMachine>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <ClCompile>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r
+      <AdditionalIncludeDirectories>C:\Users\phil\Work\portaudio\pasvn\include;C:\glassfish3\jdk\include;C:\glassfish3\jdk\include\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <SubSystem>Windows</SubSystem>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\..\src\com_portaudio_BlockingStream.c" />\r
+    <ClCompile Include="..\..\..\src\com_portaudio_PortAudio.c" />\r
+    <ClCompile Include="..\..\..\src\jpa_tools.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\..\..\src\com_portaudio_BlockingStream.h" />\r
+    <ClInclude Include="..\..\..\src\com_portaudio_PortAudio.h" />\r
+    <ClInclude Include="..\..\..\src\jpa_tools.h" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Library Include="..\..\..\..\jportaudio\portaudio_x64.lib" />\r
+    <Library Include="..\..\..\..\jportaudio\portaudio_x86.lib" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/bindings/java/c/src/com_portaudio_BlockingStream.c b/bindings/java/c/src/com_portaudio_BlockingStream.c
new file mode 100644 (file)
index 0000000..28e5ba6
--- /dev/null
@@ -0,0 +1,312 @@
+/*
+ * 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.
+ */
+
+#include "com_portaudio_BlockingStream.h"
+#include "portaudio.h"
+#include "jpa_tools.h"
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    getReadAvailable
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getReadAvailable
+  (JNIEnv *env, jobject blockingStream)
+{
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       if( stream == NULL ) return 0;
+       return Pa_GetStreamReadAvailable( stream );
+}
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    getWriteAvailable
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getWriteAvailable
+  (JNIEnv *env, jobject blockingStream)
+{
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       if( stream == NULL ) return 0;
+       return Pa_GetStreamWriteAvailable( stream );
+}
+
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    writeFloats
+ * Signature: ([FI)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_writeFloats
+  (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames)
+{
+       jfloat *carr;
+       jint err;
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       if( buffer == NULL )
+       {
+               (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+                  "null stream buffer");
+               return;
+       }
+       carr = (*env)->GetFloatArrayElements(env, buffer, NULL);
+       if (carr == NULL)
+       {
+               (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+                  "invalid stream buffer");
+               return;
+       }
+       err = Pa_WriteStream( stream, carr, numFrames );
+       (*env)->ReleaseFloatArrayElements(env, buffer, carr, 0);
+       jpa_CheckError( env, err );
+}
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    readFloats
+ * Signature: ([FI)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_readFloats
+  (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames)
+{
+       jfloat *carr;
+       jint err;
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       if( buffer == NULL )
+       {
+               (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+                  "null stream buffer");
+               return;
+       }
+       carr = (*env)->GetFloatArrayElements(env, buffer, NULL);
+       if (carr == NULL)
+       {
+               (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+                  "invalid stream buffer");
+               return;
+       }
+       err = Pa_ReadStream( stream, carr, numFrames );
+       (*env)->ReleaseFloatArrayElements(env, buffer, carr, 0);
+       jpa_CheckError( env, err );
+}
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    writeShorts
+ * Signature: ([FI)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_writeShorts
+  (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames)
+{
+       jshort *carr;
+       jint err;
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       if( buffer == NULL )
+       {
+               (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+                  "null stream buffer");
+               return;
+       }
+       carr = (*env)->GetShortArrayElements(env, buffer, NULL);
+       if (carr == NULL)
+       {
+               (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+                  "invalid stream buffer");
+               return;
+       }
+       err = Pa_WriteStream( stream, carr, numFrames );
+       (*env)->ReleaseShortArrayElements(env, buffer, carr, 0);
+       jpa_CheckError( env, err );
+}
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    readShorts
+ * Signature: ([FI)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_readShorts
+  (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames)
+{
+       jshort *carr;
+       jint err;
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       if( buffer == NULL )
+       {
+               (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+                  "null stream buffer");
+               return;
+       }
+       carr = (*env)->GetShortArrayElements(env, buffer, NULL);
+       if (carr == NULL)
+       {
+               (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+                  "invalid stream buffer");
+               return;
+       }
+       err = Pa_ReadStream( stream, carr, numFrames );
+       (*env)->ReleaseShortArrayElements(env, buffer, carr, 0);
+       jpa_CheckError( env, err );
+}
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    start
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_start
+  (JNIEnv *env, jobject blockingStream )
+{
+       PaStream *stream = jpa_GetStreamPointer( env, blockingStream );
+       int err = Pa_StartStream( stream );
+       jpa_CheckError( env, err );
+}
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    stop
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_stop
+  (JNIEnv *env, jobject blockingStream )
+{
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       int err = Pa_StopStream( stream );
+       jpa_CheckError( env, err );
+}
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    abort
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_abort
+  (JNIEnv *env, jobject blockingStream )
+{
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       int err = Pa_AbortStream( stream );
+       jpa_CheckError( env, err );
+}
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_close
+  (JNIEnv *env, jobject blockingStream )
+{
+       jclass cls;
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       if( stream != NULL )
+       {
+               int err = Pa_CloseStream( stream );
+               jpa_CheckError( env, err );
+               cls = (*env)->GetObjectClass(env, blockingStream);
+               jpa_SetLongField( env, cls, blockingStream, "nativeStream", (jlong) 0 );
+       }
+}
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    isStopped
+ * Signature: ()V
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isStopped
+  (JNIEnv *env, jobject blockingStream )
+{
+       int err;
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       if( stream == NULL ) return 1;
+       err = Pa_IsStreamStopped( stream );
+       return (jpa_CheckError( env, err ) > 0);
+}
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    isActive
+ * Signature: ()V
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isActive
+  (JNIEnv *env, jobject blockingStream )
+{
+       int err;
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       if( stream == NULL ) return 0;
+       err = Pa_IsStreamActive( stream );
+       return (jpa_CheckError( env, err ) > 0);
+}
+
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    getTime
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_portaudio_BlockingStream_getTime
+  (JNIEnv *env, jobject blockingStream )
+{
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       if( stream == NULL ) return 0.0;
+       return Pa_GetStreamTime( stream );
+}
+
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    getInfo
+ * Signature: ()Lcom/portaudio/StreamInfo;
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_getInfo
+  (JNIEnv *env, jobject blockingStream, jobject streamInfo)
+{
+       
+       PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+       const PaStreamInfo *info = Pa_GetStreamInfo( stream );
+       if( streamInfo == NULL )
+       {
+               jpa_ThrowError( env, "Invalid stream." );
+       }
+       else
+       {
+               /* Get a reference to obj's class */
+               jclass cls = (*env)->GetObjectClass(env, streamInfo);
+               jpa_SetIntField( env, cls, streamInfo, "structVersion", info->structVersion );
+               jpa_SetDoubleField( env, cls, streamInfo, "inputLatency", info->inputLatency );
+               jpa_SetDoubleField( env, cls, streamInfo, "outputLatency", info->outputLatency );
+               jpa_SetDoubleField( env, cls, streamInfo, "sampleRate", info->sampleRate );
+       }
+}
+
diff --git a/bindings/java/c/src/com_portaudio_BlockingStream.h b/bindings/java/c/src/com_portaudio_BlockingStream.h
new file mode 100644 (file)
index 0000000..c42421c
--- /dev/null
@@ -0,0 +1,125 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_portaudio_BlockingStream */
+
+#ifndef _Included_com_portaudio_BlockingStream
+#define _Included_com_portaudio_BlockingStream
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    getReadAvailable
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getReadAvailable
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    getWriteAvailable
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getWriteAvailable
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    readFloats
+ * Signature: ([FI)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_readFloats
+  (JNIEnv *, jobject, jfloatArray, jint);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    writeFloats
+ * Signature: ([FI)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_writeFloats
+  (JNIEnv *, jobject, jfloatArray, jint);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    readShorts
+ * Signature: ([SI)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_readShorts
+  (JNIEnv *, jobject, jshortArray, jint);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    writeShorts
+ * Signature: ([SI)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_writeShorts
+  (JNIEnv *, jobject, jshortArray, jint);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    start
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_start
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    stop
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_stop
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    abort
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_abort
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_close
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    isStopped
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isStopped
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    isActive
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isActive
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    getTime
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_portaudio_BlockingStream_getTime
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     com_portaudio_BlockingStream
+ * Method:    getInfo
+ * Signature: (Lcom/portaudio/StreamInfo;)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_getInfo
+  (JNIEnv *, jobject, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/bindings/java/c/src/com_portaudio_PortAudio.c b/bindings/java/c/src/com_portaudio_PortAudio.c
new file mode 100644 (file)
index 0000000..77c42eb
--- /dev/null
@@ -0,0 +1,279 @@
+/*
+ * 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.
+ */
+
+#include "com_portaudio_PortAudio.h"
+#include "portaudio.h"
+#include "jpa_tools.h"
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getVersion
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getVersion
+  (JNIEnv *env, jclass clazz)
+{
+       return Pa_GetVersion();
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getVersionText
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_portaudio_PortAudio_getVersionText
+  (JNIEnv *env, jclass clazz)
+{
+       return (*env)->NewStringUTF(env, Pa_GetVersionText() );
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    initialize
+ * Signature: ()I
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_initialize
+  (JNIEnv *env, jclass clazz)
+{
+       PaError err = Pa_Initialize();
+       jpa_CheckError( env, err );
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    terminate
+ * Signature: ()I
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_terminate
+  (JNIEnv *env, jclass clazz)
+{
+       PaError err = Pa_Terminate();
+       jpa_CheckError( env, err );
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getDeviceCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDeviceCount
+  (JNIEnv *env, jclass clazz)
+{
+       jint count = Pa_GetDeviceCount();
+       return jpa_CheckError( env, count );
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getDeviceInfo
+ * Signature: (ILcom/portaudio/DeviceInfo;)I
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getDeviceInfo
+  (JNIEnv *env, jclass clazz, jint index, jobject deviceInfo)
+{
+       const PaDeviceInfo *info;
+            /* Get a reference to obj's class */
+       jclass cls = (*env)->GetObjectClass(env, deviceInfo);
+       info = Pa_GetDeviceInfo( index );
+       if( info == NULL )
+       {
+               jpa_ThrowError( env, "Pa_GetDeviceInfo returned NULL." );
+       }
+       else
+       {
+               jpa_SetStringField( env, cls, deviceInfo, "name", info->name );
+               jpa_SetIntField( env, cls, deviceInfo, "maxInputChannels", info->maxInputChannels );
+               jpa_SetIntField( env, cls, deviceInfo, "maxOutputChannels", info->maxOutputChannels );
+               jpa_SetIntField( env, cls, deviceInfo, "hostApi", info->hostApi );
+               jpa_SetDoubleField( env, cls, deviceInfo, "defaultSampleRate", info->defaultSampleRate );
+               jpa_SetDoubleField( env, cls, deviceInfo, "defaultLowInputLatency", info->defaultLowInputLatency );
+               jpa_SetDoubleField( env, cls, deviceInfo, "defaultLowInputLatency", info->defaultHighInputLatency );
+               jpa_SetDoubleField( env, cls, deviceInfo, "defaultLowOutputLatency", info->defaultLowOutputLatency );
+               jpa_SetDoubleField( env, cls, deviceInfo, "defaultHighOutputLatency", info->defaultHighOutputLatency );
+       }
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    geHostApiCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getHostApiCount
+  (JNIEnv *env, jclass clazz)
+{
+       jint count = Pa_GetHostApiCount();
+       return jpa_CheckError( env, count );
+}
+
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    hostApiTypeIdToHostApiIndex
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiTypeIdToHostApiIndex
+  (JNIEnv *env, jclass clazz, jint hostApiType)
+{
+       return Pa_HostApiTypeIdToHostApiIndex( (PaHostApiTypeId) hostApiType );
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    hostApiDeviceIndexToDeviceIndex
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiDeviceIndexToDeviceIndex
+  (JNIEnv *env, jclass clazz, jint hostApiIndex, jint apiDeviceIndex)
+{
+       return Pa_HostApiDeviceIndexToDeviceIndex( hostApiIndex, apiDeviceIndex );
+}
+
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getHostApiInfo
+ * Signature: (ILcom/portaudio/HostApiInfo;)I
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getHostApiInfo
+  (JNIEnv *env, jclass clazz, jint index, jobject hostApiInfo)
+{
+       const PaHostApiInfo *info;
+            /* Get a reference to obj's class */
+       jclass cls = (*env)->GetObjectClass(env, hostApiInfo);
+       info = Pa_GetHostApiInfo( index );
+       if( info == NULL )
+       {
+               jpa_ThrowError( env, "Pa_GetHostApiInfo returned NULL." );
+       }
+       else
+       {
+               jpa_SetIntField( env, cls, hostApiInfo, "version", info->structVersion );
+               jpa_SetIntField( env, cls, hostApiInfo, "type", info->type );
+               jpa_SetStringField( env, cls, hostApiInfo, "name", info->name );
+               jpa_SetIntField( env, cls, hostApiInfo, "deviceCount", info->deviceCount );
+               jpa_SetIntField( env, cls, hostApiInfo, "defaultInputDevice", info->defaultInputDevice );
+               jpa_SetIntField( env, cls, hostApiInfo, "defaultOutputDevice", info->defaultOutputDevice );
+       }
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getDefaultInputDevice
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultInputDevice
+  (JNIEnv *env, jclass clazz)
+{
+       jint deviceId = Pa_GetDefaultInputDevice();
+       return jpa_CheckError( env, deviceId );
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getDefaultOutputDevice
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultOutputDevice
+  (JNIEnv *env, jclass clazz)
+{
+       jint deviceId = Pa_GetDefaultOutputDevice();
+       return jpa_CheckError( env, deviceId );
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getDefaultHostApi
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultHostApi
+  (JNIEnv *env, jclass clazz)
+{
+       jint deviceId = Pa_GetDefaultHostApi();
+       return jpa_CheckError( env, deviceId );
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    isFormatSupported
+ * Signature: (Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_isFormatSupported
+  (JNIEnv *env, jclass clazz, jobject inParams, jobject outParams, jint sampleRate )
+{
+       PaStreamParameters myInParams, *paInParams;
+       PaStreamParameters myOutParams, *paOutParams;
+       
+       paInParams = jpa_FillStreamParameters(  env, inParams, &myInParams );
+       paOutParams = jpa_FillStreamParameters(  env, outParams, &myOutParams );
+       
+       return Pa_IsFormatSupported( paInParams, paOutParams, sampleRate );
+
+}
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    openStream
+ * Signature: (Lcom/portaudio/BlockingStream;Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;III)I
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_openStream
+  (JNIEnv *env, jclass clazz, jobject blockingStream,  jobject inParams, jobject outParams, jint sampleRate, jint framesPerBuffer, jint flags )
+{
+       int err;
+       PaStreamParameters myInParams, *paInParams;
+       PaStreamParameters myOutParams, *paOutParams;
+       PaStream *stream;
+       
+       paInParams = jpa_FillStreamParameters(  env, inParams, &myInParams );
+       paOutParams = jpa_FillStreamParameters(  env, outParams, &myOutParams );
+       err = Pa_OpenStream( &stream, paInParams, paOutParams, sampleRate, framesPerBuffer, flags, NULL, NULL );
+       if( jpa_CheckError( env, err ) == 0 )
+       {
+               jclass cls = (*env)->GetObjectClass(env, blockingStream);
+               jpa_SetLongField( env, cls, blockingStream, "nativeStream", (jlong) stream );
+               if( paInParams != NULL )
+               {
+                       jpa_SetIntField( env, cls, blockingStream, "inputFormat", paInParams->sampleFormat );
+               }
+               if( paOutParams != NULL )
+               {
+                       jpa_SetIntField( env, cls, blockingStream, "outputFormat", paOutParams->sampleFormat );
+               }
+       }
+}
diff --git a/bindings/java/c/src/com_portaudio_PortAudio.h b/bindings/java/c/src/com_portaudio_PortAudio.h
new file mode 100644 (file)
index 0000000..67c13a0
--- /dev/null
@@ -0,0 +1,179 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_portaudio_PortAudio */
+
+#ifndef _Included_com_portaudio_PortAudio
+#define _Included_com_portaudio_PortAudio
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_portaudio_PortAudio_FLAG_CLIP_OFF
+#define com_portaudio_PortAudio_FLAG_CLIP_OFF 1L
+#undef com_portaudio_PortAudio_FLAG_DITHER_OFF
+#define com_portaudio_PortAudio_FLAG_DITHER_OFF 2L
+#undef com_portaudio_PortAudio_FORMAT_FLOAT_32
+#define com_portaudio_PortAudio_FORMAT_FLOAT_32 1L
+#undef com_portaudio_PortAudio_FORMAT_INT_32
+#define com_portaudio_PortAudio_FORMAT_INT_32 2L
+#undef com_portaudio_PortAudio_FORMAT_INT_24
+#define com_portaudio_PortAudio_FORMAT_INT_24 4L
+#undef com_portaudio_PortAudio_FORMAT_INT_16
+#define com_portaudio_PortAudio_FORMAT_INT_16 8L
+#undef com_portaudio_PortAudio_FORMAT_INT_8
+#define com_portaudio_PortAudio_FORMAT_INT_8 16L
+#undef com_portaudio_PortAudio_FORMAT_UINT_8
+#define com_portaudio_PortAudio_FORMAT_UINT_8 32L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_DEV
+#define com_portaudio_PortAudio_HOST_API_TYPE_DEV 0L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_DIRECTSOUND
+#define com_portaudio_PortAudio_HOST_API_TYPE_DIRECTSOUND 1L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_MME
+#define com_portaudio_PortAudio_HOST_API_TYPE_MME 2L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_ASIO
+#define com_portaudio_PortAudio_HOST_API_TYPE_ASIO 3L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_SOUNDMANAGER
+#define com_portaudio_PortAudio_HOST_API_TYPE_SOUNDMANAGER 4L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_COREAUDIO
+#define com_portaudio_PortAudio_HOST_API_TYPE_COREAUDIO 5L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_OSS
+#define com_portaudio_PortAudio_HOST_API_TYPE_OSS 7L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_ALSA
+#define com_portaudio_PortAudio_HOST_API_TYPE_ALSA 8L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_AL
+#define com_portaudio_PortAudio_HOST_API_TYPE_AL 9L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_BEOS
+#define com_portaudio_PortAudio_HOST_API_TYPE_BEOS 10L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_WDMKS
+#define com_portaudio_PortAudio_HOST_API_TYPE_WDMKS 11L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_JACK
+#define com_portaudio_PortAudio_HOST_API_TYPE_JACK 12L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_WASAPI
+#define com_portaudio_PortAudio_HOST_API_TYPE_WASAPI 13L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_AUDIOSCIENCE
+#define com_portaudio_PortAudio_HOST_API_TYPE_AUDIOSCIENCE 14L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_COUNT
+#define com_portaudio_PortAudio_HOST_API_TYPE_COUNT 15L
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getVersion
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getVersion
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getVersionText
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_portaudio_PortAudio_getVersionText
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    initialize
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_initialize
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    terminate
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_terminate
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getDeviceCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDeviceCount
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getDeviceInfo
+ * Signature: (ILcom/portaudio/DeviceInfo;)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getDeviceInfo
+  (JNIEnv *, jclass, jint, jobject);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getHostApiCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getHostApiCount
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getHostApiInfo
+ * Signature: (ILcom/portaudio/HostApiInfo;)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getHostApiInfo
+  (JNIEnv *, jclass, jint, jobject);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    hostApiTypeIdToHostApiIndex
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiTypeIdToHostApiIndex
+  (JNIEnv *, jclass, jint);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    hostApiDeviceIndexToDeviceIndex
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiDeviceIndexToDeviceIndex
+  (JNIEnv *, jclass, jint, jint);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getDefaultInputDevice
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultInputDevice
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getDefaultOutputDevice
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultOutputDevice
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    getDefaultHostApi
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultHostApi
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    isFormatSupported
+ * Signature: (Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_isFormatSupported
+  (JNIEnv *, jclass, jobject, jobject, jint);
+
+/*
+ * Class:     com_portaudio_PortAudio
+ * Method:    openStream
+ * Signature: (Lcom/portaudio/BlockingStream;Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;III)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_openStream
+  (JNIEnv *, jclass, jobject, jobject, jobject, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/bindings/java/c/src/jpa_tools.c b/bindings/java/c/src/jpa_tools.c
new file mode 100644 (file)
index 0000000..9754470
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * 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.
+ */
+
+#include "com_portaudio_PortAudio.h"
+#include "portaudio.h"
+#include "jpa_tools.h"
+
+jint jpa_GetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName )
+{
+     /* Look for the instance field maxInputChannels in cls */
+     jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "I");
+     if (fid == NULL)
+        {
+                jpa_ThrowError( env, "Cannot find integer JNI field." );
+               return 0;
+     }
+        else
+        {
+               return (*env)->GetIntField(env, obj, fid );
+        }
+}
+
+void jpa_SetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jint value )
+{
+     /* Look for the instance field maxInputChannels in cls */
+     jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "I");
+     if (fid == NULL)
+        {
+                jpa_ThrowError( env, "Cannot find integer JNI field." );
+     }
+        else
+        {
+               (*env)->SetIntField(env, obj, fid, value );
+        }
+}
+
+jlong jpa_GetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName )
+{
+     /* Look for the instance field maxInputChannels in cls */
+     jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "J");
+     if (fid == NULL)
+        {
+                jpa_ThrowError( env, "Cannot find long JNI field." );
+               return 0L;
+     }
+        else
+        {
+               return (*env)->GetLongField(env, obj, fid );
+        }
+}
+
+void jpa_SetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jlong value )
+{
+     /* Look for the instance field maxInputChannels in cls */
+     jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "J");
+     if (fid == NULL)
+        {
+                jpa_ThrowError( env, "Cannot find long JNI field." );
+     }
+        else
+        {
+               (*env)->SetLongField(env, obj, fid, value );
+        }
+}
+
+
+void jpa_SetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jdouble value )
+{
+     /* Look for the instance field maxInputChannels in cls */
+     jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "D");
+     if (fid == NULL)
+        {
+                jpa_ThrowError( env, "Cannot find double JNI field." );
+     }
+        else
+        {
+               (*env)->SetDoubleField(env, obj, fid, value );
+        }
+}
+
+
+jdouble jpa_GetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName )
+{
+     /* Look for the instance field maxInputChannels in cls */
+     jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "D");
+     if (fid == NULL)
+        {
+                jpa_ThrowError( env, "Cannot find double JNI field." );
+               return 0;
+     }
+        else
+        {
+               return (*env)->GetDoubleField(env, obj, fid );
+        }
+}
+
+void jpa_SetStringField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, const char *value )
+{
+     /* Look for the instance field maxInputChannels in cls */
+     jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "Ljava/lang/String;");
+     if (fid == NULL)
+        {
+                jpa_ThrowError( env, "Cannot find String JNI field." );
+     }
+        else
+        {
+               jstring jstr = (*env)->NewStringUTF(env, value);
+               if (jstr == NULL)
+               {
+                       jpa_ThrowError( env, "Cannot create new String." );
+               }
+               else
+               {
+                       (*env)->SetObjectField(env, obj, fid, jstr );
+               }
+        }
+}
+
+PaStreamParameters *jpa_FillStreamParameters( JNIEnv *env, jobject jstreamParam, PaStreamParameters *myParams )
+{
+       jclass cls;
+       
+       if( jstreamParam == NULL ) return NULL; // OK, not an error
+
+       cls = (*env)->GetObjectClass(env, jstreamParam);
+       
+       myParams->channelCount = jpa_GetIntField( env, cls, jstreamParam, "channelCount" );
+       myParams->device = jpa_GetIntField( env, cls, jstreamParam, "device" );
+       myParams->sampleFormat = jpa_GetIntField( env, cls, jstreamParam, "sampleFormat" );
+       myParams->suggestedLatency = jpa_GetDoubleField( env, cls, jstreamParam, "suggestedLatency" );
+       myParams->hostApiSpecificStreamInfo = NULL;
+
+       return myParams;
+}
+
+// Create an exception that will be thrown when we return from the JNI call.
+jint jpa_ThrowError( JNIEnv *env, const char *message )
+{
+       return (*env)->ThrowNew(env, (*env)->FindClass( env, "java/lang/RuntimeException"),
+                  message );
+}
+
+// Throw an exception on error.
+jint jpa_CheckError( JNIEnv *env, PaError err )
+{
+       if( err < 0 )
+       {
+               if( err == paUnanticipatedHostError )
+               {
+                       const PaHostErrorInfo *hostErrorInfo = Pa_GetLastHostErrorInfo();
+                       return jpa_ThrowError( env, hostErrorInfo->errorText );
+               }
+               else
+               {
+                       return jpa_ThrowError( env, Pa_GetErrorText( err ) );
+               }
+       }
+       else
+       {
+               return err;
+       }
+}
+
+// Get the stream pointer from a BlockingStream long field.
+PaStream *jpa_GetStreamPointer( JNIEnv *env, jobject blockingStream )
+{
+       jclass cls = (*env)->GetObjectClass(env, blockingStream);
+       return (PaStream *) jpa_GetLongField( env, cls, blockingStream, "nativeStream" );
+}
diff --git a/bindings/java/c/src/jpa_tools.h b/bindings/java/c/src/jpa_tools.h
new file mode 100644 (file)
index 0000000..11e724c
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+#include "com_portaudio_PortAudio.h"
+#include "portaudio.h"
+
+#ifndef JPA_TOOLS_H
+#define JPA_TOOLS_H
+
+jint jpa_GetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName );
+void jpa_SetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jint value );
+
+jlong jpa_GetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName );
+void jpa_SetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jlong value );
+
+jdouble jpa_GetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName );
+void jpa_SetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jdouble value );
+
+void jpa_SetStringField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, const char *value );
+PaStreamParameters *jpa_FillStreamParameters( JNIEnv *env, jobject jstreamParam, PaStreamParameters *myParams );
+
+jint jpa_CheckError( JNIEnv *env, PaError err );
+jint jpa_ThrowError( JNIEnv *env, const char *message );
+
+PaStream *jpa_GetStreamPointer( JNIEnv *env, jobject blockingStream );
+
+#endif /* JPA_TOOLS_H */
diff --git a/bindings/java/jportaudio.dox b/bindings/java/jportaudio.dox
new file mode 100644 (file)
index 0000000..d0f4639
--- /dev/null
@@ -0,0 +1,37 @@
+/** \r
+@page java_binding JPortAudio Java Binding\r
+@ingroup jportaudio\r
+\r
+<i>Note: this page has not been reviewed, and may contain errors.</i>\r
+\r
+@section java_draft DRAFT - IN PROGRESS\r
+\r
+9/1/12 JPortAudio is very new and should be considered an "alpha" release.\r
+The building of JPortAudio will eventually be integrated into the Makefile as an optional build.\r
+\r
+Currently JPortAudio is only supported for Windows. Please contact us if you want to help with porting to Mac or Linux.\r
+\r
+@section java_comp_windows Building JPortAudio on Windows\r
+\r
+Build the Java code using the Eclipse project in "jportaudio". Export as "jportaudio.jar".\r
+\r
+If you modify the JNI API then you will need to regenerate the JNI .h files using:\r
+\r
+@code\r
+cd bindings/java/scripts\r
+make_header.bat\r
+@endcode\r
+\r
+Build the JNI DLL using the Visual Studio 2010 solution in "java/c/build/vs2010/PortAudioJNI".\r
+\r
+@section java_use_windows Using JPortAudio on Windows\r
+\r
+Put the "jportaudio.jar" in the classpath for your application.\r
+Place the following libraries where they can be found, typically in the same folder as your application.\r
+\r
+- portaudio_x86.dll\r
+- portaudio_x64.dll\r
+- jportaudio_x86.dll\r
+- jportaudio_x64.dll\r
+\r
+*/
\ No newline at end of file
diff --git a/bindings/java/jportaudio/.classpath b/bindings/java/jportaudio/.classpath
new file mode 100644 (file)
index 0000000..ea36295
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="src" path="jtests"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bindings/java/jportaudio/.project b/bindings/java/jportaudio/.project
new file mode 100644 (file)
index 0000000..7395b15
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>JPortAudio</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java b/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java
new file mode 100644 (file)
index 0000000..b05750d
--- /dev/null
@@ -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 expection", (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 expection", (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 expection", (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/bindings/java/jportaudio/src/com/portaudio/BlockingStream.java b/bindings/java/jportaudio/src/com/portaudio/BlockingStream.java
new file mode 100644 (file)
index 0000000..5a1ab3a
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * 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;
+
+/**
+ * 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().
+ * 
+ * @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 void readFloats( float[] buffer, int numFrames );
+
+       private native void 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
+        */
+       public void read( float[] buffer, int numFrames )
+       {
+               if( inputFormat != PortAudio.FORMAT_FLOAT_32 )
+               {
+                       throw new RuntimeException(
+                                       "Tried to read float samples from a non float stream." );
+               }
+               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
+        */
+       public void write( float[] buffer, int numFrames )
+       {
+               if( outputFormat != PortAudio.FORMAT_FLOAT_32 )
+               {
+                       throw new RuntimeException(
+                                       "Tried to write float samples to a non float stream." );
+               }
+               writeFloats( buffer, numFrames );
+       }
+
+       private native void readShorts( short[] buffer, int numFrames );
+
+       private native void 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
+        */
+       public void read( short[] buffer, int numFrames )
+       {
+               if( inputFormat != PortAudio.FORMAT_INT_16 )
+               {
+                       throw new RuntimeException(
+                                       "Tried to read short samples from a non short stream." );
+               }
+               readShorts( buffer, numFrames );
+       }
+
+       /**
+        * Write 16-bit integer data to the stream from the array.
+        * 
+        * @param buffer
+        * @param numFrames
+        *            number of frames to write
+        */
+       public void write( short[] buffer, int numFrames )
+       {
+               if( outputFormat != PortAudio.FORMAT_INT_16 )
+               {
+                       throw new RuntimeException(
+                                       "Tried to write short samples from a non short stream." );
+               }
+               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/bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java b/bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java
new file mode 100644 (file)
index 0000000..9c7966b
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+/**
+ * Equivalent to PaDeviceInfo
+ * @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/bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java b/bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java
new file mode 100644 (file)
index 0000000..74a8235
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+/**
+ * Equivalent to PaHostApiInfo
+ * @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/bindings/java/jportaudio/src/com/portaudio/PortAudio.java b/bindings/java/jportaudio/src/com/portaudio/PortAudio.java
new file mode 100644 (file)
index 0000000..4208cd5
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+ * 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;
+
+/**
+ * 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
+ *
+ */
+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
+       {
+               if( System.getProperty( "os.arch" ).contains( "64" ) )
+               {
+                       System.loadLibrary( "jportaudio_x64" );
+               }
+               else
+               {
+                       System.loadLibrary( "jportaudio_x86" );
+               }
+               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/bindings/java/jportaudio/src/com/portaudio/StreamInfo.java b/bindings/java/jportaudio/src/com/portaudio/StreamInfo.java
new file mode 100644 (file)
index 0000000..fdd0207
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+/**
+ * Equivalent to PaStreamInfo
+ * @author Phil Burk
+ *
+ */
+public class StreamInfo
+{
+       public int structVersion;
+       public double outputLatency;
+       public double inputLatency;
+       public double sampleRate;
+}
diff --git a/bindings/java/jportaudio/src/com/portaudio/StreamParameters.java b/bindings/java/jportaudio/src/com/portaudio/StreamParameters.java
new file mode 100644 (file)
index 0000000..845da2c
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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;
+/**
+ * Equivalent to PaStreamParameters
+ * @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;
+}
diff --git a/bindings/java/scripts/make_header.bat b/bindings/java/scripts/make_header.bat
new file mode 100644 (file)
index 0000000..14fa280
--- /dev/null
@@ -0,0 +1,4 @@
+REM Generate the JNI header file from the Java code for JPortAudio\r
+REM by Phil Burk\r
+\r
+javah -classpath ../jportaudio/bin -d ../c/src com.portaudio.PortAudio com.portaudio.BlockingStream\r
index fdbe0b187ae4b5dc4f083589daa4f59e0bb39c10..7c4cd35191c6fbfdcc937b3c05d7b521598d94ce 100644 (file)
@@ -3,8 +3,8 @@
 \r
 @section overview Overview\r
 \r
-PortAudio is a cross-platform, open-source C language library for real-time audio input and output. The library provides functions that allow your software to acquire and output real-time audio streams from your computer's hardware audio interfaces. It is designed to simplify writing cross-platform audio applications, and also to simplify the development of audio software in general by hiding the complexities of dealing directly with each native audio API. PortAudio is used to implement sound recording, editing and mixing applications, software synthesizers, effects processors, music players, internet telephony applications, software defined radios and more. Supported platforms include MS Windows, Mac OS X and Linux. Third-party language bindings make it possible to call PortAudio from other programming languages including C++, C#, Python, PureBasic, FreePascal and Lazarus.\r
-\r
+PortAudio is a cross-platform, open-source C language library for real-time audio input and output.\r
+The library provides functions that allow your software to acquire and output real-time audio streams from your computer's hardware audio interfaces. It is designed to simplify writing cross-platform audio applications, and also to simplify the development of audio software in general by hiding the complexities of dealing directly with each native audio API. PortAudio is used to implement sound recording, editing and mixing applications, software synthesizers, effects processors, music players, internet telephony applications, software defined radios and more. Supported platforms include MS Windows, Mac OS X and Linux. Third-party language bindings make it possible to call PortAudio from other programming languages including @ref java_binding "Java", C++, C#, Python, PureBasic, FreePascal and Lazarus.\r
 \r
 @section start_here Start here\r
 \r
@@ -38,6 +38,8 @@ Documentation for non-portable platform-specific host API extensions
 \r
 - <a href="http://www.assembla.com/spaces/portaudio/wiki">The PortAudio wiki</a>\r
 \r
+- @ref java_binding<br>\r
+Documentation for the Java JNI interface to PortAudio\r
 \r
 @section developer_resources Developer Resources\r
 \r
index 7d3b3a8547001db74b07adf9187cc5a1013f7ff5..b39c82d136072802f8b96581be6767f37e13e461 100644 (file)
@@ -25,7 +25,7 @@ Many platforms with GCC/make can use the simple ./configure && make combination
 \r
 @section tut_start3 Programming with PortAudio\r
 \r
-Below are the steps to writing a PortAudio application:\r
+Below are the steps to writing a PortAudio application using the callback technique:\r
 \r
  - Write a callback function that will be called by PortAudio when audio processing is needed.\r
  - Initialize the PA library and open a stream for audio I/O.\r
@@ -38,7 +38,7 @@ In addition to this "Callback" architecture, V19 also supports a "Blocking I/O"
 \r
 In this tutorial, we'll show how to use the callback architecture to play a sawtooth wave. Much of the tutorial is taken from the file paex_saw.c, which is part of the PortAudio distribution. When you're done with this tutorial, you'll be armed with the basic knowledge you need to write an audio program. If you need more sample code, look in the "examples" and "test" directory of the PortAudio distribution. Another great source of info is the portaudio.h Doxygen page, which documents the entire V19 API. Also see the page for <a href="http://www.assembla.com/spaces/portaudio/wiki/Tips">tips on programming PortAudio</a> on the PortAudio wiki.\r
 \r
-If you are upgrading from V18, you may want to look at the <a href="http://www.portaudio.com/docs/proposals/index.html">Proposed Enhancements to PortAudio</a>, which describes the differences between V18 and V19.\r
+@section tut_start4 Programming Tutorial Contents\r
 \r
 - \ref writing_a_callback\r
 - \ref initializing_portaudio\r
@@ -49,6 +49,8 @@ If you are upgrading from V18, you may want to look at the <a href="http://www.p
 - \ref querying_devices\r
 - \ref blocking_read_write\r
 \r
+If you are upgrading from V18, you may want to look at the <a href="http://www.portaudio.com/docs/proposals/index.html">Proposed Enhancements to PortAudio</a>, which describes the differences between V18 and V19.\r
+\r
 Once you have a basic understanding of how to use PortAudio, you might be interested in \ref exploring.\r
 \r
 Next: \ref writing_a_callback\r