public long Retrieve(float[][] output, long samples) { for (int i = 0; i < output.Length; i++) { if (output[i].Length < samples) { throw new Exception("Invalid output buffer: Channel " + i + " does not have enough space for " + samples + " samples"); } } long totalSamples = output.Length * samples; if (totalSamples > _outputBuffer.Length) { _outputBuffer = new float[totalSamples]; } long actualSamples = RubberBandNativeMethods.RubberBandStretcher_Retrieve(_rbs, _outputBuffer, new IntPtr(samples), output.Length).ToInt64(); for (int i = 0; i < output.Length; i++) { Array.Copy(_outputBuffer, i * samples, output[i], 0, actualSamples); } return(actualSamples); }
public void Dispose() { if (_rbs != IntPtr.Zero) { RubberBandNativeMethods.RubberBandStretcher_Delete(_rbs); _rbs = IntPtr.Zero; } }
public float[] GetPhaseResetCurve() { long numberOfCurveElements = RubberBandNativeMethods.RubberBandStretcher_GetPhaseResetCurve(_rbs, null, IntPtr.Zero).ToInt64(); float[] buffer = new float[numberOfCurveElements]; RubberBandNativeMethods.RubberBandStretcher_GetPhaseResetCurve(_rbs, buffer, new IntPtr(buffer.Length)); return(buffer); }
public int[] GetExactTimePoints() { long numberOfTimePoints = RubberBandNativeMethods.RubberBandStretcher_GetExactTimePoints(_rbs, null, IntPtr.Zero).ToInt64(); int[] buffer = new int[numberOfTimePoints]; RubberBandNativeMethods.RubberBandStretcher_GetExactTimePoints(_rbs, buffer, new IntPtr(buffer.Length)); return(buffer); }
public void SetKeyFrameMap(SortedDictionary <long, long> map) { var mappingData = new List <IntPtr>(); foreach (var mapping in map) { mappingData.Add(new IntPtr(mapping.Key)); mappingData.Add(new IntPtr(mapping.Value)); } RubberBandNativeMethods.RubberBandStretcher_SetKeyFrameMap(_rbs, mappingData.ToArray(), mappingData.Count / 2); }
public void Process(float[][] input, long samples, bool final) { for (int i = 0; i < input.Length; i++) { if (input[i].Length < samples) { throw new Exception("Invalid input data: Channel " + i + " does not have " + samples + " samples of data"); } } long totalSamples = input.Length * samples; if (totalSamples > _processBuffer.Length) { _processBuffer = new float[totalSamples]; } for (int i = 0; i < input.Length; i++) { Array.Copy(input[i], 0, _processBuffer, i * samples, samples); } RubberBandNativeMethods.RubberBandStretcher_Process(_rbs, _processBuffer, new IntPtr(samples), input.Length, final); }
public long GetChannelCount() { return(RubberBandNativeMethods.RubberBandStretcher_GetChannelCount(_rbs).ToInt64()); }
public void CalculateStretch() { RubberBandNativeMethods.RubberBandStretcher_CalculateStretch(_rbs); }
public double GetTimeRatio() { return(RubberBandNativeMethods.RubberBandStretcher_GetTimeRatio(_rbs)); }
public void SetPitchScale(double scale) { RubberBandNativeMethods.RubberBandStretcher_SetPitchScale(_rbs, scale); }
public void SetFrequencyCutoff(int n, float f) { RubberBandNativeMethods.RubberBandStretcher_SetFrequencyCutoff(_rbs, n, f); }
public long GetInputIncrement() { return(RubberBandNativeMethods.RubberBandStretcher_GetInputIncrement(_rbs).ToInt64()); }
public double GetPitchScale() { return(RubberBandNativeMethods.RubberBandStretcher_GetPitchScale(_rbs)); }
public void SetExpectedInputDuration(long samples) { RubberBandNativeMethods.RubberBandStretcher_SetExpectedInputDuration(_rbs, new IntPtr(samples)); }
public RubberBandStretcher(int sampleRate, int channels, Options options = DefaultOptions, double initialTimeRatio = 1.0, double initialPitchScale = 1.0) { _rbs = RubberBandNativeMethods.RubberBandStretcher_Create(new IntPtr(sampleRate), new IntPtr(channels), (int)options, initialTimeRatio, initialPitchScale); }
public void SetTimeRatio(double ratio) { RubberBandNativeMethods.RubberBandStretcher_SetTimeRatio(_rbs, ratio); }
public long GetLatency() { return(RubberBandNativeMethods.RubberBandStretcher_GetLatency(_rbs).ToInt64()); }
public long GetSamplesRequired() { return(RubberBandNativeMethods.RubberBandStretcher_GetSamplesRequired(_rbs).ToInt64()); }
public void SetMaxProcessSize(long samples) { RubberBandNativeMethods.RubberBandStretcher_SetMaxProcessSize(_rbs, new IntPtr(samples)); }
public void SetDebugLevel(int level) { RubberBandNativeMethods.RubberBandStretcher_SetDebugLevel(_rbs, level); }
public float GetFrequencyCutoff(int n) { return(RubberBandNativeMethods.RubberBandStretcher_GetFrequencyCutoff(_rbs, n)); }
public static void SetDefaultDebugLevel(int level) { RubberBandNativeMethods.RubberBandStretcher_SetDefaultDebugLevel(level); }
public void SetPitchOption(Options options) { RubberBandNativeMethods.RubberBandStretcher_SetPitchOption(_rbs, (int)options); }
public int Available() { return(RubberBandNativeMethods.RubberBandStretcher_Available(_rbs)); }
public void Reset() { RubberBandNativeMethods.RubberBandStretcher_Reset(_rbs); }