Skip to content

Commit

Permalink
fixes #455
Browse files Browse the repository at this point in the history
  • Loading branch information
victorvhpg committed Jul 6, 2021
1 parent 13bbebb commit 54e4008
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 11 additions & 11 deletions CSCore/DSP/PitchShifterInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ namespace CSCore.DSP
internal class PitchShifterInternal
{
private static readonly int MaxFrameLength = 16000;
private static readonly float[] InFifo = new float[MaxFrameLength];
private static readonly float[] OutFifo = new float[MaxFrameLength];
private static readonly float[] FfTworksp = new float[2 * MaxFrameLength];
private static readonly float[] LastPhase = new float[MaxFrameLength / 2 + 1];
private static readonly float[] SumPhase = new float[MaxFrameLength / 2 + 1];
private static readonly float[] OutputAccum = new float[2 * MaxFrameLength];
private static readonly float[] AnaFreq = new float[MaxFrameLength];
private static readonly float[] AnaMagn = new float[MaxFrameLength];
private static readonly float[] SynFreq = new float[MaxFrameLength];
private static readonly float[] SynMagn = new float[MaxFrameLength];
private static long _gRover;
private readonly float[] InFifo = new float[MaxFrameLength];
private readonly float[] OutFifo = new float[MaxFrameLength];
private readonly float[] FfTworksp = new float[2 * MaxFrameLength];
private readonly float[] LastPhase = new float[MaxFrameLength / 2 + 1];
private readonly float[] SumPhase = new float[MaxFrameLength / 2 + 1];
private readonly float[] OutputAccum = new float[2 * MaxFrameLength];
private readonly float[] AnaFreq = new float[MaxFrameLength];
private readonly float[] AnaMagn = new float[MaxFrameLength];
private readonly float[] SynFreq = new float[MaxFrameLength];
private readonly float[] SynMagn = new float[MaxFrameLength];
private long _gRover;

public static void PitchShift(float pitchShift, long numSampsToProcess,
float sampleRate, float[] indata)
Expand Down
4 changes: 3 additions & 1 deletion CSCore/Streams/Effects/PitchShifter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace CSCore.Streams.Effects
/// </remarks>
public class PitchShifter : SampleAggregatorBase
{
private readonly PitchShifterInternal _pitchShifterInternal;
/// <summary>
/// Gets or sets the pitch shift factor.
/// </summary>
Expand All @@ -34,6 +35,7 @@ public class PitchShifter : SampleAggregatorBase
public PitchShifter(ISampleSource source) : base(source)
{
PitchShiftFactor = 1.0f;
_pitchShifterInternal = new PitchShifterInternal();
}

/// <summary>
Expand Down Expand Up @@ -62,7 +64,7 @@ public override int Read(float[] buffer, int offset, int count)
Buffer.BlockCopy(buffer, offset, pitchBuffer, 0, read);
}

PitchShifterInternal.PitchShift(PitchShiftFactor, read, WaveFormat.SampleRate, buffer);
_pitchShifterInternal.PitchShift(PitchShiftFactor, read, WaveFormat.SampleRate, buffer);

if (offset != 0)
{
Expand Down

0 comments on commit 54e4008

Please sign in to comment.