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

@@ -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");
}
}
}