diff options
author | Matthew S <matthewsot@outlook.com> | 2016-12-26 22:57:16 -0800 |
---|---|---|
committer | Matthew S <matthewsot@outlook.com> | 2016-12-26 22:57:16 -0800 |
commit | 848aabdfb9fa834242c16c473ffacf60a0b98b97 (patch) | |
tree | bb4a30e0d90799ba125f586f21572c514e742c6d | |
parent | 0ce0a36bace3a76483aece5b123cd020de5bb365 (diff) |
UWP recorder, started on Android one
-rw-r--r-- | WAVRecorder/WAVRecorder.Android/Properties/AssemblyInfo.cs | 30 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.Android/Resources/AboutResources.txt | 44 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.Android/Resources/Resource.Designer.cs | 60 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.Android/Resources/Values/Strings.xml | 5 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.Android/WAVRecorder.Android.csproj | 70 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.Android/WAVRecorder.cs | 55 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.UWP/Properties/AssemblyInfo.cs | 29 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.UWP/Properties/WAVRecorder.UWP.rd.xml | 33 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.UWP/WAVRecorder.UWP.csproj | 131 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.UWP/WAVRecorder.cs | 54 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.UWP/project.json | 16 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder.sln | 76 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder/IWAVRecorder.cs | 29 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder/Properties/AssemblyInfo.cs | 30 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder/WAVRecorder.csproj | 70 | ||||
-rw-r--r-- | WAVRecorder/WAVRecorder/packages.config | 4 |
16 files changed, 736 insertions, 0 deletions
diff --git a/WAVRecorder/WAVRecorder.Android/Properties/AssemblyInfo.cs b/WAVRecorder/WAVRecorder.Android/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6cf2363 --- /dev/null +++ b/WAVRecorder/WAVRecorder.Android/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Android.App; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WAVRecorder.Android")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WAVRecorder.Android")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WAVRecorder/WAVRecorder.Android/Resources/AboutResources.txt b/WAVRecorder/WAVRecorder.Android/Resources/AboutResources.txt new file mode 100644 index 0000000..c2bca97 --- /dev/null +++ b/WAVRecorder/WAVRecorder.Android/Resources/AboutResources.txt @@ -0,0 +1,44 @@ +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.axml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.axml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "R" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the R class would expose: + +public class R { + public class drawable { + public const int icon = 0x123; + } + + public class layout { + public const int main = 0x456; + } + + public class strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main +to reference the layout/main.axml file, or R.strings.first_string to reference the first +string in the dictionary file values/strings.xml.
\ No newline at end of file diff --git a/WAVRecorder/WAVRecorder.Android/Resources/Resource.Designer.cs b/WAVRecorder/WAVRecorder.Android/Resources/Resource.Designer.cs new file mode 100644 index 0000000..524f031 --- /dev/null +++ b/WAVRecorder/WAVRecorder.Android/Resources/Resource.Designer.cs @@ -0,0 +1,60 @@ +#pragma warning disable 1591 +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +[assembly: global::Android.Runtime.ResourceDesignerAttribute("WAVRecorder.Android.Resource", IsApplication=false)] + +namespace WAVRecorder.Android +{ + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")] + public partial class Resource + { + + static Resource() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + public partial class Attribute + { + + static Attribute() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Attribute() + { + } + } + + public partial class String + { + + // aapt resource value: 0x7f020001 + public static int ApplicationName = 2130837505; + + // aapt resource value: 0x7f020000 + public static int Hello = 2130837504; + + static String() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private String() + { + } + } + } +} +#pragma warning restore 1591 diff --git a/WAVRecorder/WAVRecorder.Android/Resources/Values/Strings.xml b/WAVRecorder/WAVRecorder.Android/Resources/Values/Strings.xml new file mode 100644 index 0000000..8fd1763 --- /dev/null +++ b/WAVRecorder/WAVRecorder.Android/Resources/Values/Strings.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="Hello">Hello World, Click Me!</string> + <string name="ApplicationName">$projectname$</string> +</resources> diff --git a/WAVRecorder/WAVRecorder.Android/WAVRecorder.Android.csproj b/WAVRecorder/WAVRecorder.Android/WAVRecorder.Android.csproj new file mode 100644 index 0000000..0233324 --- /dev/null +++ b/WAVRecorder/WAVRecorder.Android/WAVRecorder.Android.csproj @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{11371366-96DD-4E63-BA74-D69C3983C49F}</ProjectGuid> + <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>WAVRecorder.Android</RootNamespace> + <AssemblyName>WAVRecorder.Android</AssemblyName> + <FileAlignment>512</FileAlignment> + <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> + <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> + <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk> + <TargetFrameworkVersion>v6.0</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Mono.Android" /> + <Reference Include="mscorlib" /> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="WAVRecorder.cs" /> + <Compile Include="Resources\Resource.Designer.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="Resources\AboutResources.txt" /> + </ItemGroup> + <ItemGroup> + <AndroidResource Include="Resources\Values\Strings.xml" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\WAVRecorder\WAVRecorder.csproj"> + <Project>{67f9d3a8-f71e-4428-913f-c37ae82cdb24}</Project> + <Name>WAVRecorder</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/WAVRecorder/WAVRecorder.Android/WAVRecorder.cs b/WAVRecorder/WAVRecorder.Android/WAVRecorder.cs new file mode 100644 index 0000000..8aa8ce1 --- /dev/null +++ b/WAVRecorder/WAVRecorder.Android/WAVRecorder.cs @@ -0,0 +1,55 @@ +using Android.Media; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WAVRecorder.Android +{ + public class WAVRecorder : IWAVRecorder + { + public IDisposable RawWAVStream { get; private set; } + + public System.IO.Stream WAVStream + { + get + { + return null; + } + } + + private AudioRecord audioRecorder; + private byte[] audioBuffer; + + //See: https://raw.githubusercontent.com/xamarin/monodroid-samples/master/Example_WorkingWithAudio/Example_WorkingWithAudio/LowLevelRecordAudio.cs + public async Task<bool> RequestPermissionsAndInitAsync() + { + audioBuffer = new Byte[100000]; + audioRecorder = new AudioRecord( + // Hardware source of recording. + AudioSource.Mic, + // Frequency + 16000, + // Mono or stereo + ChannelIn.Mono, + // Audio encoding + Encoding.Pcm16bit, + // Length of the audio clip. + audioBuffer.Length + ); + + return true; + } + + public async void StartRecordingAsync() + { + audioRecorder.StartRecording(); + // Off line this so that we do not block the UI thread. + await ReadAudioAsync(); + } + + public async void StopRecordingAsync() + { + } + } +} diff --git a/WAVRecorder/WAVRecorder.UWP/Properties/AssemblyInfo.cs b/WAVRecorder/WAVRecorder.UWP/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8b0f51c --- /dev/null +++ b/WAVRecorder/WAVRecorder.UWP/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WAVRecorder.UWP")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WAVRecorder.UWP")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ComVisible(false)]
\ No newline at end of file diff --git a/WAVRecorder/WAVRecorder.UWP/Properties/WAVRecorder.UWP.rd.xml b/WAVRecorder/WAVRecorder.UWP/Properties/WAVRecorder.UWP.rd.xml new file mode 100644 index 0000000..bb71d59 --- /dev/null +++ b/WAVRecorder/WAVRecorder.UWP/Properties/WAVRecorder.UWP.rd.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + This file contains Runtime Directives, specifications about types your application accesses + through reflection and other dynamic code patterns. Runtime Directives are used to control the + .NET Native optimizer and ensure that it does not remove code accessed by your library. If your + library does not do any reflection, then you generally do not need to edit this file. However, + if your library reflects over types, especially types passed to it or derived from its types, + then you should write Runtime Directives. + + The most common use of reflection in libraries is to discover information about types passed + to the library. Runtime Directives have three ways to express requirements on types passed to + your library. + + 1. Parameter, GenericParameter, TypeParameter, TypeEnumerableParameter + Use these directives to reflect over types passed as a parameter. + + 2. SubTypes + Use a SubTypes directive to reflect over types derived from another type. + + 3. AttributeImplies + Use an AttributeImplies directive to indicate that your library needs to reflect over + types or methods decorated with an attribute. + + For more information on writing Runtime Directives for libraries, please visit + https://go.microsoft.com/fwlink/?LinkID=391919 +--> +<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata"> + <Library Name="WAVRecorder.UWP"> + + <!-- add directives for your library here --> + + </Library> +</Directives> diff --git a/WAVRecorder/WAVRecorder.UWP/WAVRecorder.UWP.csproj b/WAVRecorder/WAVRecorder.UWP/WAVRecorder.UWP.csproj new file mode 100644 index 0000000..4e26b57 --- /dev/null +++ b/WAVRecorder/WAVRecorder.UWP/WAVRecorder.UWP.csproj @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{E6E7973C-034F-4CAA-BA71-7A5B615881F9}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>WAVRecorder.UWP</RootNamespace> + <AssemblyName>WAVRecorder.UWP</AssemblyName> + <DefaultLanguage>en-US</DefaultLanguage> + <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier> + <TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion> + <TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion> + <MinimumVisualStudioVersion>14</MinimumVisualStudioVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> + <PlatformTarget>x86</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x86\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> + <NoWarn>;2008</NoWarn> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> + <PlatformTarget>x86</PlatformTarget> + <OutputPath>bin\x86\Release\</OutputPath> + <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> + <Optimize>true</Optimize> + <NoWarn>;2008</NoWarn> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'"> + <PlatformTarget>ARM</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\ARM\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> + <NoWarn>;2008</NoWarn> + <DebugType>full</DebugType> + <PlatformTarget>ARM</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'"> + <PlatformTarget>ARM</PlatformTarget> + <OutputPath>bin\ARM\Release\</OutputPath> + <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> + <Optimize>true</Optimize> + <NoWarn>;2008</NoWarn> + <DebugType>pdbonly</DebugType> + <PlatformTarget>ARM</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + <PlatformTarget>x64</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\x64\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> + <NoWarn>;2008</NoWarn> + <DebugType>full</DebugType> + <PlatformTarget>x64</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + <PlatformTarget>x64</PlatformTarget> + <OutputPath>bin\x64\Release\</OutputPath> + <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> + <Optimize>true</Optimize> + <NoWarn>;2008</NoWarn> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x64</PlatformTarget> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <ItemGroup> + <!-- A reference to the entire .Net Framework and Windows SDK are automatically included --> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Compile Include="WAVRecorder.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <EmbeddedResource Include="Properties\WAVRecorder.UWP.rd.xml" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\WAVRecorder\WAVRecorder.csproj"> + <Project>{67f9d3a8-f71e-4428-913f-c37ae82cdb24}</Project> + <Name>WAVRecorder</Name> + </ProjectReference> + </ItemGroup> + <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' "> + <VisualStudioVersion>14.0</VisualStudioVersion> + </PropertyGroup> + <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/WAVRecorder/WAVRecorder.UWP/WAVRecorder.cs b/WAVRecorder/WAVRecorder.UWP/WAVRecorder.cs new file mode 100644 index 0000000..31f47d7 --- /dev/null +++ b/WAVRecorder/WAVRecorder.UWP/WAVRecorder.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.Media.Capture; +using Windows.Media.MediaProperties; +using Windows.Storage.Streams; + +namespace WAVRecorder.UWP +{ + public class WAVRecorder : IWAVRecorder + { + public IDisposable RawWAVStream { get; private set; } + + public Stream WAVStream { + get + { + return ((InMemoryRandomAccessStream)RawWAVStream).AsStream(); + } + } + + private MediaCapture mediaCapture; + private MediaEncodingProfile mediaProfile; + + public async Task<bool> RequestPermissionsAndInitAsync() + { + mediaCapture = new MediaCapture(); + + var settings = new MediaCaptureInitializationSettings() + { + StreamingCaptureMode = StreamingCaptureMode.Audio + }; + await mediaCapture.InitializeAsync(); + + mediaProfile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.Auto); + + RawWAVStream = new InMemoryRandomAccessStream(); + + return true; + } + + public async void StartRecordingAsync() + { + await mediaCapture.StartRecordToStreamAsync(mediaProfile, (InMemoryRandomAccessStream)RawWAVStream); + } + + public async void StopRecordingAsync() + { + await mediaCapture.StopRecordAsync(); + } + } +} diff --git a/WAVRecorder/WAVRecorder.UWP/project.json b/WAVRecorder/WAVRecorder.UWP/project.json new file mode 100644 index 0000000..32d9274 --- /dev/null +++ b/WAVRecorder/WAVRecorder.UWP/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +}
\ No newline at end of file diff --git a/WAVRecorder/WAVRecorder.sln b/WAVRecorder/WAVRecorder.sln new file mode 100644 index 0000000..b4cfedf --- /dev/null +++ b/WAVRecorder/WAVRecorder.sln @@ -0,0 +1,76 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26009.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WAVRecorder", "WAVRecorder\WAVRecorder.csproj", "{67F9D3A8-F71E-4428-913F-C37AE82CDB24}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WAVRecorder.UWP", "WAVRecorder.UWP\WAVRecorder.UWP.csproj", "{E6E7973C-034F-4CAA-BA71-7A5B615881F9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WAVRecorder.Android", "WAVRecorder.Android\WAVRecorder.Android.csproj", "{11371366-96DD-4E63-BA74-D69C3983C49F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|ARM.ActiveCfg = Debug|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|ARM.Build.0 = Debug|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|x64.ActiveCfg = Debug|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|x64.Build.0 = Debug|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|x86.ActiveCfg = Debug|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|x86.Build.0 = Debug|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|Any CPU.Build.0 = Release|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|ARM.ActiveCfg = Release|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|ARM.Build.0 = Release|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x64.ActiveCfg = Release|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x64.Build.0 = Release|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x86.ActiveCfg = Release|Any CPU + {67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|x86.Build.0 = Release|Any CPU + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Debug|ARM.ActiveCfg = Debug|ARM + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Debug|ARM.Build.0 = Debug|ARM + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Debug|x64.ActiveCfg = Debug|x64 + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Debug|x64.Build.0 = Debug|x64 + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Debug|x86.ActiveCfg = Debug|x86 + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Debug|x86.Build.0 = Debug|x86 + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Release|Any CPU.Build.0 = Release|Any CPU + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Release|ARM.ActiveCfg = Release|ARM + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Release|ARM.Build.0 = Release|ARM + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Release|x64.ActiveCfg = Release|x64 + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Release|x64.Build.0 = Release|x64 + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Release|x86.ActiveCfg = Release|x86 + {E6E7973C-034F-4CAA-BA71-7A5B615881F9}.Release|x86.Build.0 = Release|x86 + {11371366-96DD-4E63-BA74-D69C3983C49F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Debug|ARM.ActiveCfg = Debug|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Debug|ARM.Build.0 = Debug|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Debug|x64.ActiveCfg = Debug|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Debug|x64.Build.0 = Debug|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Debug|x86.ActiveCfg = Debug|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Debug|x86.Build.0 = Debug|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Release|Any CPU.Build.0 = Release|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Release|ARM.ActiveCfg = Release|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Release|ARM.Build.0 = Release|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Release|x64.ActiveCfg = Release|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Release|x64.Build.0 = Release|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Release|x86.ActiveCfg = Release|Any CPU + {11371366-96DD-4E63-BA74-D69C3983C49F}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/WAVRecorder/WAVRecorder/IWAVRecorder.cs b/WAVRecorder/WAVRecorder/IWAVRecorder.cs new file mode 100644 index 0000000..dc3f0f7 --- /dev/null +++ b/WAVRecorder/WAVRecorder/IWAVRecorder.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WAVRecorder +{ + public enum WAVRecorderStatus + { + Recording, + Stopped + } + public interface IWAVRecorder + { + //WAVRecorderStatus Status { get; } + + Task<bool> RequestPermissionsAndInitAsync(); + + Stream WAVStream { get; } + + IDisposable RawWAVStream { get; } + + void StartRecordingAsync(); + + void StopRecordingAsync(); + } +} diff --git a/WAVRecorder/WAVRecorder/Properties/AssemblyInfo.cs b/WAVRecorder/WAVRecorder/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0261594 --- /dev/null +++ b/WAVRecorder/WAVRecorder/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Resources; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WAVRecorder")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WAVRecorder")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WAVRecorder/WAVRecorder/WAVRecorder.csproj b/WAVRecorder/WAVRecorder/WAVRecorder.csproj new file mode 100644 index 0000000..211eead --- /dev/null +++ b/WAVRecorder/WAVRecorder/WAVRecorder.csproj @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{67F9D3A8-F71E-4428-913F-C37AE82CDB24}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>WAVRecorder</RootNamespace> + <AssemblyName>WAVRecorder</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <TargetFrameworkProfile>Profile259</TargetFrameworkProfile> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Compile Include="IWAVRecorder.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <Reference Include="Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\Xamarin.Forms.2.3.3.168\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll</HintPath> + </Reference> + <Reference Include="Xamarin.Forms.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\Xamarin.Forms.2.3.3.168\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll</HintPath> + </Reference> + <Reference Include="Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\Xamarin.Forms.2.3.3.168\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> + <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> + <Import Project="..\packages\Xamarin.Forms.2.3.3.168\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.3.3.168\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> + </PropertyGroup> + <Error Condition="!Exists('..\packages\Xamarin.Forms.2.3.3.168\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Forms.2.3.3.168\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets'))" /> + </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/WAVRecorder/WAVRecorder/packages.config b/WAVRecorder/WAVRecorder/packages.config new file mode 100644 index 0000000..07fbf54 --- /dev/null +++ b/WAVRecorder/WAVRecorder/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Xamarin.Forms" version="2.3.3.168" targetFramework="portable45-net45+win8+wp8+wpa81" /> +</packages>
\ No newline at end of file |