CUEPlayer

This commit is contained in:
chudov
2010-04-06 14:22:27 +00:00
parent 8b692a8a54
commit a866b79341
56 changed files with 5494 additions and 41 deletions

View File

@@ -25,10 +25,11 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
@@ -43,6 +44,7 @@
<Compile Include="Crc32Test.cs" />
<Compile Include="FlakeWriterTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SOXResamplerTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CUETools.AccurateRip\CUETools.AccurateRip.csproj">
@@ -67,6 +69,10 @@
<Project>{6458A13A-30EF-45A9-9D58-E5031B17BEE2}</Project>
<Name>CUETools.Codecs</Name>
</ProjectReference>
<ProjectReference Include="..\..\CUETools.DSP.Resampler\CUETools.DSP.Resampler.csproj">
<Project>{A6303861-CA06-4C2C-A104-BA9291538F6F}</Project>
<Name>CUETools.DSP.Resampler</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>

View File

@@ -0,0 +1,100 @@
using CUETools.DSP.Resampler;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CUETools.Codecs;
using System;
namespace CUETools.TestCodecs
{
/// <summary>
///This is a test class for SOXResamplerTest and is intended
///to contain all SOXResamplerTest Unit Tests
///</summary>
[TestClass()]
public class SOXResamplerTest
{
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//Use TestInitialize to run code before running each test
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
/// <summary>
///A test for SOXResampler Constructor
///</summary>
[TestMethod()]
public void SOXResamplerConstructorTest()
{
AudioPCMConfig inputPCM = new AudioPCMConfig(32, 1, 44100);
AudioPCMConfig outputPCM = new AudioPCMConfig(32, 1, 48000);
SOXResamplerConfig cfg;
cfg.quality = SOXResamplerQuality.Very;
cfg.phase = 50;
cfg.allow_aliasing = false;
cfg.bandwidth = 0;
SOXResampler resampler = new SOXResampler(inputPCM, outputPCM, cfg);
AudioBuffer src = new AudioBuffer(inputPCM, 400 * inputPCM.SampleRate / 1000);
AudioBuffer dst = new AudioBuffer(outputPCM, src.Size * 3);
int offs = 0;
double delta = 0;
for (int i = 0; i < 100; i++)
{
src.Prepare(-1);
for (int j = 0; j < src.Size; j++)
src.Float[j, 0] = (float)Math.Sin((i * src.Size + j) * Math.PI / 44100);
src.Length = src.Size;
resampler.Flow(src, dst);
for (int j = 0; j < dst.Length; j++)
delta += dst.Float[j, 0] - Math.Sin((offs + j) * Math.PI / 48000);
offs += dst.Length;
}
Assert.IsTrue(Math.Abs(delta) < 0.00001, "Error too large");
}
}
}