mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Updated the build system, now using .NET Framework v4.0 for most things
This commit is contained in:
@@ -1,146 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{FAD09EE2-D6B2-4A8E-9F1C-2A9FB293661A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CUETools.Codecs.CoreAudio</RootNamespace>
|
||||
<TargetFrameworks>net40;net20</TargetFrameworks>
|
||||
<Version>2.1.6.0</Version>
|
||||
<AssemblyName>CUETools.Codecs.CoreAudio</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<RootNamespace>CUETools.Codecs.CoreAudio</RootNamespace>
|
||||
<Product>CUETools</Product>
|
||||
<Description>A library for playing sound on Windows using NAudio.</Description>
|
||||
<Copyright>Copyright (c) 2008-2018 Grigory Chudov. Uses NAudio by Mark Heath</Copyright>
|
||||
<Authors>Grigory Chudov</Authors>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<OutputPath>..\bin\$(Configuration)</OutputPath>
|
||||
<RepositoryUrl>https://github.com/gchudov/cuetools.net</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<Company />
|
||||
</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>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</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>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CoreAudioApi\AudioCaptureClient.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioClient.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioClientBufferFlags.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioClientShareMode.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioClientStreamFlags.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioEndpointVolume.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioEndpointVolumeCallback.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioEndpointVolumeChannel.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioEndpointVolumeChannels.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioEndpointVolumeNotificationDelegate.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioEndpointVolumeStepInformation.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioEndpointVolumeVolumeRange.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioMeterInformation.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioMeterInformationChannels.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioRenderClient.cs" />
|
||||
<Compile Include="CoreAudioApi\AudioVolumeNotificationData.cs" />
|
||||
<Compile Include="CoreAudioApi\DataFlow.cs" />
|
||||
<Compile Include="CoreAudioApi\DeviceState.cs" />
|
||||
<Compile Include="CoreAudioApi\EEndpointHardwareSupport.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\AudioVolumeNotificationDataStruct.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\Blob.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\ClsCtx.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\ErrorCodes.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IAudioCaptureClient.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IAudioClient.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IAudioEndpointVolume.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IAudioEndpointVolumeCallback.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IAudioMeterInformation.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IAudioRenderClient.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IMMDevice.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IMMDeviceCollection.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IMMDeviceEnumerator.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IMMEndpoint.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IMMNotificationClient.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\IPropertyStore.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\MMDeviceEnumeratorComObject.cs" />
|
||||
<Compile Include="CoreAudioApi\Interfaces\StorageAccessMode.cs" />
|
||||
<Compile Include="CoreAudioApi\MMDevice.cs" />
|
||||
<Compile Include="CoreAudioApi\MMDeviceCollection.cs" />
|
||||
<Compile Include="CoreAudioApi\MMDeviceEnumerator.cs" />
|
||||
<Compile Include="CoreAudioApi\PropertyKey.cs" />
|
||||
<Compile Include="CoreAudioApi\PropertyKeys.cs" />
|
||||
<Compile Include="CoreAudioApi\PropertyStore.cs" />
|
||||
<Compile Include="CoreAudioApi\PropertyStoreProperty.cs" />
|
||||
<Compile Include="CoreAudioApi\PropVariant.cs" />
|
||||
<Compile Include="CoreAudioApi\Role.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="WasapiOut.cs" />
|
||||
<Compile Include="WaveFormats\AdpcmWaveFormat.cs" />
|
||||
<Compile Include="WaveFormats\AudioMediaSubtypes.cs" />
|
||||
<Compile Include="WaveFormats\WaveFormat.cs" />
|
||||
<Compile Include="WaveFormats\WaveFormatEncoding.cs" />
|
||||
<Compile Include="WaveFormats\WaveFormatExtensible.cs" />
|
||||
<Compile Include="WaveFormats\WaveFormatExtraData.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CUETools.Codecs\CUETools.Codecs.csproj">
|
||||
<Project>{6458A13A-30EF-45A9-9D58-E5031B17BEE2}</Project>
|
||||
<Name>CUETools.Codecs</Name>
|
||||
|
||||
<ItemDefinitionGroup>
|
||||
<ProjectReference>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<ProjectReference Include="..\CUETools.Codecs\CUETools.Codecs.csproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.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>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,216 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NAudio.Wave;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Capture using Wasapi
|
||||
/// See http://msdn.microsoft.com/en-us/library/dd370800%28VS.85%29.aspx
|
||||
/// </summary>
|
||||
public class WasapiCapture : IWaveIn
|
||||
{
|
||||
private const long REFTIMES_PER_SEC = 10000000;
|
||||
private const long REFTIMES_PER_MILLISEC = 10000;
|
||||
private volatile bool stop;
|
||||
private byte[] recordBuffer;
|
||||
private Thread captureThread;
|
||||
private AudioClient audioClient;
|
||||
private int bytesPerFrame;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates recorded data is available
|
||||
/// </summary>
|
||||
public event EventHandler<WaveInEventArgs> DataAvailable;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that all recorded data has now been received.
|
||||
/// </summary>
|
||||
public event EventHandler RecordingStopped;
|
||||
|
||||
/// <summary>
|
||||
/// Initialises a new instance of the WASAPI capture class
|
||||
/// </summary>
|
||||
public WasapiCapture() :
|
||||
this(GetDefaultCaptureDevice())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises a new instance of the WASAPI capture class
|
||||
/// </summary>
|
||||
/// <param name="captureDevice">Capture device to use</param>
|
||||
public WasapiCapture(MMDevice captureDevice)
|
||||
{
|
||||
this.audioClient = captureDevice.AudioClient;
|
||||
WaveFormat = audioClient.MixFormat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recording wave format
|
||||
/// </summary>
|
||||
public WaveFormat WaveFormat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default audio capture device
|
||||
/// </summary>
|
||||
/// <returns>The default audio capture device</returns>
|
||||
public static MMDevice GetDefaultCaptureDevice()
|
||||
{
|
||||
MMDeviceEnumerator devices = new MMDeviceEnumerator();
|
||||
return devices.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console);
|
||||
}
|
||||
|
||||
private void InitializeCaptureDevice()
|
||||
{
|
||||
long requestedDuration = REFTIMES_PER_MILLISEC * 100;
|
||||
|
||||
if (!audioClient.IsFormatSupported(AudioClientShareMode.Shared, WaveFormat))
|
||||
{
|
||||
throw new ArgumentException("Unsupported Wave Format");
|
||||
}
|
||||
|
||||
audioClient.Initialize(AudioClientShareMode.Shared,
|
||||
AudioClientStreamFlags.None,
|
||||
requestedDuration,
|
||||
0,
|
||||
WaveFormat,
|
||||
Guid.Empty);
|
||||
|
||||
int bufferFrameCount = audioClient.BufferSize;
|
||||
bytesPerFrame = WaveFormat.Channels * WaveFormat.BitsPerSample / 8;
|
||||
recordBuffer = new byte[bufferFrameCount * bytesPerFrame];
|
||||
Debug.WriteLine(string.Format("record buffer size = {0}", recordBuffer.Length));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start Recording
|
||||
/// </summary>
|
||||
public void StartRecording()
|
||||
{
|
||||
InitializeCaptureDevice();
|
||||
ThreadStart start = delegate { this.CaptureThread(this.audioClient); };
|
||||
this.captureThread = new Thread(start);
|
||||
|
||||
Debug.WriteLine("Thread starting...");
|
||||
this.stop = false;
|
||||
this.captureThread.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop Recording
|
||||
/// </summary>
|
||||
public void StopRecording()
|
||||
{
|
||||
if (this.captureThread != null)
|
||||
{
|
||||
this.stop = true;
|
||||
|
||||
Debug.WriteLine("Thread ending...");
|
||||
|
||||
// wait for thread to end
|
||||
this.captureThread.Join();
|
||||
this.captureThread = null;
|
||||
|
||||
Debug.WriteLine("Done.");
|
||||
|
||||
this.stop = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void CaptureThread(AudioClient client)
|
||||
{
|
||||
Debug.WriteLine(client.BufferSize);
|
||||
int bufferFrameCount = audioClient.BufferSize;
|
||||
|
||||
// Calculate the actual duration of the allocated buffer.
|
||||
long actualDuration = (long)((double)REFTIMES_PER_SEC *
|
||||
bufferFrameCount / WaveFormat.SampleRate);
|
||||
int sleepMilliseconds = (int)(actualDuration / REFTIMES_PER_MILLISEC / 2);
|
||||
|
||||
AudioCaptureClient capture = client.AudioCaptureClient;
|
||||
client.Start();
|
||||
|
||||
try
|
||||
{
|
||||
Debug.WriteLine(string.Format("sleep: {0} ms", sleepMilliseconds));
|
||||
while (!this.stop)
|
||||
{
|
||||
Thread.Sleep(sleepMilliseconds);
|
||||
ReadNextPacket(capture);
|
||||
}
|
||||
|
||||
client.Stop();
|
||||
|
||||
if (RecordingStopped != null)
|
||||
{
|
||||
RecordingStopped(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (capture != null)
|
||||
{
|
||||
capture.Dispose();
|
||||
}
|
||||
if (client != null)
|
||||
{
|
||||
client.Dispose();
|
||||
}
|
||||
|
||||
client = null;
|
||||
capture = null;
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("stop wasapi");
|
||||
}
|
||||
|
||||
private void ReadNextPacket(AudioCaptureClient capture)
|
||||
{
|
||||
IntPtr buffer;
|
||||
int framesAvailable;
|
||||
AudioClientBufferFlags flags;
|
||||
int packetSize = capture.GetNextPacketSize();
|
||||
int recordBufferOffset = 0;
|
||||
//Debug.WriteLine(string.Format("packet size: {0} samples", packetSize / 4));
|
||||
|
||||
while (packetSize != 0)
|
||||
{
|
||||
buffer = capture.GetBuffer(out framesAvailable, out flags);
|
||||
|
||||
int bytesAvailable = framesAvailable * bytesPerFrame;
|
||||
|
||||
//Debug.WriteLine(string.Format("got buffer: {0} frames", framesAvailable));
|
||||
|
||||
// if not silence...
|
||||
if ((flags & AudioClientBufferFlags.Silent) != AudioClientBufferFlags.Silent)
|
||||
{
|
||||
Marshal.Copy(buffer, recordBuffer, recordBufferOffset, bytesAvailable);
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Clear(recordBuffer, recordBufferOffset, bytesAvailable);
|
||||
}
|
||||
recordBufferOffset += bytesAvailable;
|
||||
capture.ReleaseBuffer(framesAvailable);
|
||||
packetSize = capture.GetNextPacketSize();
|
||||
}
|
||||
if (DataAvailable != null)
|
||||
{
|
||||
DataAvailable(this, new WaveInEventArgs(recordBuffer, recordBufferOffset));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
StopRecording();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
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("CUETools.Codecs.CoreAudio")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("CUETools.Codecs.CoreAudio")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("f597837f-dd1c-4e0f-b915-0e929bf0dd35")]
|
||||
|
||||
// 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")]
|
||||
Reference in New Issue
Block a user