AS3 функция для повторной выборки.Вы можете легко изменить, чтобы преобразовать этот код в C #:
private function resampling(fromSampleRate:int, toSampleRate:int, quality:int = 10):void
{
var samples:Vector.<Number> = new Vector.<Number>;
var srcLength:uint = this._samples.length;
var destLength:uint = this._samples.length*toSampleRate/fromSampleRate;
var dx:Number = srcLength/destLength;
// fmax : nyqist half of destination sampleRate
// fmax / fsr = 0.5;
var fmaxDivSR:Number = 0.5;
var r_g:Number = 2 * fmaxDivSR;
// Quality is half the window width
var wndWidth2:int = quality;
var wndWidth:int = quality*2;
var x:Number = 0;
var i:uint, j:uint;
var r_y:Number;
var tau:int;
var r_w:Number;
var r_a:Number;
var r_snc:Number;
for (i=0;i<destLength;++i)
{
r_y = 0.0;
for (tau=-wndWidth2;tau < wndWidth2;++tau)
{
// input sample index
j = (int)(x+tau);
// Hann Window. Scale and calculate sinc
r_w = 0.5 - 0.5 * Math.cos(2*Math.PI*(0.5 + (j-x)/wndWidth));
r_a = 2*Math.PI*(j-x)*fmaxDivSR;
r_snc = 1.0;
if (r_a != 0)
r_snc = Math.sin(r_a)/r_a;
if ((j >= 0) && (j < srcLength))
{
r_y += r_g * r_w * r_snc * this._samples[j];
}
}
samples[i] = r_y;
x += dx;
}
this._samples = samples.concat();
samples.length = 0;
}