mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Small refactorings in CUETools.DSP.Resampler.
This commit is contained in:
@@ -1,17 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using NAudio.CoreAudioApi;
|
using System.Windows.Forms;
|
||||||
using CUETools.Codecs;
|
using CUETools.Codecs;
|
||||||
using CUETools.Codecs.CoreAudio;
|
using CUETools.Codecs.CoreAudio;
|
||||||
using CUETools.DSP.Resampler;
|
|
||||||
using CUETools.DSP.Mixer;
|
using CUETools.DSP.Mixer;
|
||||||
using CUETools.Processor;
|
using CUETools.DSP.Resampler;
|
||||||
|
using NAudio.CoreAudioApi;
|
||||||
|
|
||||||
namespace CUEPlayer
|
namespace CUEPlayer
|
||||||
{
|
{
|
||||||
@@ -80,10 +74,10 @@ namespace CUEPlayer
|
|||||||
{
|
{
|
||||||
_player = new WasapiOut(_device, NAudio.CoreAudioApi.AudioClientShareMode.Shared, true, delay, new AudioPCMConfig(32, 2, 48000));
|
_player = new WasapiOut(_device, NAudio.CoreAudioApi.AudioClientShareMode.Shared, true, delay, new AudioPCMConfig(32, 2, 48000));
|
||||||
SOXResamplerConfig cfg;
|
SOXResamplerConfig cfg;
|
||||||
cfg.quality = SOXResamplerQuality.Very;
|
cfg.Quality = SOXResamplerQuality.Very;
|
||||||
cfg.phase = 50;
|
cfg.Phase = 50;
|
||||||
cfg.allow_aliasing = false;
|
cfg.AllowAliasing = false;
|
||||||
cfg.bandwidth = 0;
|
cfg.Bandwidth = 0;
|
||||||
_resampler = new SOXResampler(parent.Mixer.PCM, _player.PCM, cfg);
|
_resampler = new SOXResampler(parent.Mixer.PCM, _player.PCM, cfg);
|
||||||
resampled = new AudioBuffer(_player.PCM, parent.Mixer.BufferSize * 2 * parent.Mixer.PCM.SampleRate / _player.PCM.SampleRate);
|
resampled = new AudioBuffer(_player.PCM, parent.Mixer.BufferSize * 2 * parent.Mixer.PCM.SampleRate / _player.PCM.SampleRate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace CUETools.DSP.Resampler
|
|||||||
if (inputPCM.ChannelCount != outputPCM.ChannelCount)
|
if (inputPCM.ChannelCount != outputPCM.ChannelCount)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
|
|
||||||
if (outputPCM.SampleRate == inputPCM.SampleRate * 4 && config.quality >= SOXResamplerQuality.Medium)
|
if (outputPCM.SampleRate == inputPCM.SampleRate * 4 && config.Quality >= SOXResamplerQuality.Medium)
|
||||||
{
|
{
|
||||||
this.rate = new rate_t[inputPCM.ChannelCount];
|
this.rate = new rate_t[inputPCM.ChannelCount];
|
||||||
this.shared = new rate_shared_t();
|
this.shared = new rate_shared_t();
|
||||||
@@ -31,9 +31,9 @@ namespace CUETools.DSP.Resampler
|
|||||||
for (int i = 0; i < inputPCM.ChannelCount; i++)
|
for (int i = 0; i < inputPCM.ChannelCount; i++)
|
||||||
{
|
{
|
||||||
rateUp2[i] = new rate_t(inputPCM.SampleRate, inputPCM.SampleRate * 2, sharedUp2, 0.5,
|
rateUp2[i] = new rate_t(inputPCM.SampleRate, inputPCM.SampleRate * 2, sharedUp2, 0.5,
|
||||||
config.quality, -1, config.phase, config.bandwidth, config.allow_aliasing);
|
config.Quality, -1, config.Phase, config.Bandwidth, config.AllowAliasing);
|
||||||
rate[i] = new rate_t(inputPCM.SampleRate * 2, inputPCM.SampleRate * 4, shared, 0.5,
|
rate[i] = new rate_t(inputPCM.SampleRate * 2, inputPCM.SampleRate * 4, shared, 0.5,
|
||||||
config.quality, -1, 50, 90, true);
|
config.Quality, -1, 50, 90, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -44,7 +44,7 @@ namespace CUETools.DSP.Resampler
|
|||||||
for (int i = 0; i < inputPCM.ChannelCount; i++)
|
for (int i = 0; i < inputPCM.ChannelCount; i++)
|
||||||
{
|
{
|
||||||
rate[i] = new rate_t(inputPCM.SampleRate, outputPCM.SampleRate, shared, (double)inputPCM.SampleRate / outputPCM.SampleRate,
|
rate[i] = new rate_t(inputPCM.SampleRate, outputPCM.SampleRate, shared, (double)inputPCM.SampleRate / outputPCM.SampleRate,
|
||||||
config.quality, -1, config.phase, config.bandwidth, config.allow_aliasing);
|
config.Quality, -1, config.Phase, config.Bandwidth, config.AllowAliasing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
{
|
{
|
||||||
public struct SOXResamplerConfig
|
public struct SOXResamplerConfig
|
||||||
{
|
{
|
||||||
public double phase;
|
public double Phase;
|
||||||
public double bandwidth;
|
public double Bandwidth;
|
||||||
public bool allow_aliasing;
|
public bool AllowAliasing;
|
||||||
public SOXResamplerQuality quality;
|
public SOXResamplerQuality Quality;
|
||||||
/*double coef_interp; -- interpolation...*/
|
/*double coef_interp; -- interpolation...*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
using CUETools.DSP.Resampler;
|
using System;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using CUETools.Codecs;
|
using CUETools.Codecs;
|
||||||
using System;
|
using CUETools.DSP.Resampler;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
namespace CUETools.TestCodecs
|
namespace CUETools.TestCodecs
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///This is a test class for SOXResamplerTest and is intended
|
///This is a test class for SOXResamplerTest and is intended
|
||||||
///to contain all SOXResamplerTest Unit Tests
|
///to contain all SOXResamplerTest Unit Tests
|
||||||
@@ -14,8 +12,6 @@ namespace CUETools.TestCodecs
|
|||||||
[TestClass()]
|
[TestClass()]
|
||||||
public class SOXResamplerTest
|
public class SOXResamplerTest
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
private TestContext testContextInstance;
|
private TestContext testContextInstance;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -74,10 +70,10 @@ namespace CUETools.TestCodecs
|
|||||||
AudioPCMConfig inputPCM = new AudioPCMConfig(32, 1, 44100);
|
AudioPCMConfig inputPCM = new AudioPCMConfig(32, 1, 44100);
|
||||||
AudioPCMConfig outputPCM = new AudioPCMConfig(32, 1, 48000);
|
AudioPCMConfig outputPCM = new AudioPCMConfig(32, 1, 48000);
|
||||||
SOXResamplerConfig cfg;
|
SOXResamplerConfig cfg;
|
||||||
cfg.quality = SOXResamplerQuality.Very;
|
cfg.Quality = SOXResamplerQuality.Very;
|
||||||
cfg.phase = 50;
|
cfg.Phase = 50;
|
||||||
cfg.allow_aliasing = false;
|
cfg.AllowAliasing = false;
|
||||||
cfg.bandwidth = 0;
|
cfg.Bandwidth = 0;
|
||||||
SOXResampler resampler = new SOXResampler(inputPCM, outputPCM, cfg);
|
SOXResampler resampler = new SOXResampler(inputPCM, outputPCM, cfg);
|
||||||
AudioBuffer src = new AudioBuffer(inputPCM, 400 * inputPCM.SampleRate / 1000);
|
AudioBuffer src = new AudioBuffer(inputPCM, 400 * inputPCM.SampleRate / 1000);
|
||||||
AudioBuffer dst = new AudioBuffer(outputPCM, src.Size * 3);
|
AudioBuffer dst = new AudioBuffer(outputPCM, src.Size * 3);
|
||||||
|
|||||||
Reference in New Issue
Block a user