Resampling methods
More...
|
static float [] | FactorUpscaler (float[] samples, int factor, int channels) |
|
static float [] | Resample (float[] samples, double oldSamplingRate, double newSamplingRate, int channels) |
|
static short [] | Resample (short[] samples, double oldSamplingRate, double newSamplingRate, int channels) |
|
|
static float [] float [] rightSamples | Resample ((float[] leftSamples, float[] rightSamples) samples, double oldSamplingRate, double newSamplingRate, int channels) |
|
Resampling methods
Definition at line 8 of file LinearInterpolation.cs.
◆ FactorUpscaler()
static float [] BGC.Audio.LinearInterpolation.FactorUpscaler |
( |
float [] |
samples, |
|
|
int |
factor, |
|
|
int |
channels |
|
) |
| |
|
inlinestatic |
Definition at line 23 of file LinearInterpolation.cs.
Referenced by BGC.Tests.WAVEncodingTests.UpScalingTest().
28 int inputSampleCount = samples.Length / channels;
29 int outputSampleCount = factor * inputSampleCount;
30 float[] outputSamples =
new float[outputSampleCount * channels];
32 for (
int chan = 0; chan < channels; chan++)
34 for (
int j = 0; j < inputSampleCount; j++)
36 outputSamples[factor * j * channels + chan] = samples[j * channels + chan];
◆ Resample() [1/3]
static float [] float [] rightSamples BGC.Audio.LinearInterpolation.Resample |
( |
(float[] leftSamples, float[] rightSamples) |
samples, |
|
|
double |
oldSamplingRate, |
|
|
double |
newSamplingRate, |
|
|
int |
channels |
|
) |
| |
|
inlinestaticprivate |
Definition at line 10 of file LinearInterpolation.cs.
Referenced by BGC.Audio.WaveEncoding.LoadBGCSimple(), BGC.Audio.WaveEncoding.LoadBGCStream(), BGC.Audio.WaveEncoding.LoadFile(), BGC.Audio.WaveEncoding.LoadPCMFile(), and BGC.Audio.WaveEncoding.LoadStereoFile().
16 float[] newLeftSamples =
Resample(samples.leftSamples, oldSamplingRate, newSamplingRate, 1);
17 float[] newRightSamples =
Resample(samples.rightSamples, oldSamplingRate, newSamplingRate, 1);
19 return (newLeftSamples, newRightSamples);
static float [] float [] rightSamples Resample((float[] leftSamples, float[] rightSamples) samples, double oldSamplingRate, double newSamplingRate, int channels)
◆ Resample() [2/3]
static float [] BGC.Audio.LinearInterpolation.Resample |
( |
float [] |
samples, |
|
|
double |
oldSamplingRate, |
|
|
double |
newSamplingRate, |
|
|
int |
channels |
|
) |
| |
|
inlinestatic |
Definition at line 44 of file LinearInterpolation.cs.
51 double rateRatio = newSamplingRate / oldSamplingRate;
53 double invRateRatio = oldSamplingRate / newSamplingRate;
55 int inputSampleCount = samples.Length / channels;
56 int outputSampleCount = (int)Math.Floor(inputSampleCount * rateRatio);
57 float[] outputSamples =
new float[outputSampleCount * channels];
63 for (
int chan = 0; chan < channels; chan++)
65 for (
int j = 0; j < outputSampleCount; j++)
71 outputSamples[j * channels + chan] = (float)((i1 - i) * samples[i0 * channels + chan] + (i - i0) * samples[i1 * channels + chan]);
◆ Resample() [3/3]
static short [] BGC.Audio.LinearInterpolation.Resample |
( |
short [] |
samples, |
|
|
double |
oldSamplingRate, |
|
|
double |
newSamplingRate, |
|
|
int |
channels |
|
) |
| |
|
inlinestatic |
Definition at line 78 of file LinearInterpolation.cs.
85 double rateRatio = newSamplingRate / oldSamplingRate;
87 double invRateRatio = oldSamplingRate / newSamplingRate;
89 int inputSampleCount = samples.Length / channels;
90 int outputSampleCount = (int)Math.Ceiling(inputSampleCount * rateRatio);
91 short[] outputSamples =
new short[outputSampleCount * channels];
97 for (
int chan = 0; chan < channels; chan++)
99 for (
int j = 0; j < outputSampleCount; j++)
101 i = j * invRateRatio;
105 outputSamples[j * channels + chan] = (short)Math.Round((i1 - i) * samples[i0 * channels + chan] + (i - i0) * samples[i1 * channels + chan]);
109 return outputSamples;
◆ leftSamples
float [] BGC.Audio.LinearInterpolation.leftSamples |
|
static |
The documentation for this class was generated from the following file: