public static void CheapTrick(double[] x, int x_length, int fs, double[] temporal_positions, double[] f0, int f0_length, CheapTrickOption option, double[,] spectrogram) { int outer = spectrogram.GetLength(0); int inner = spectrogram.GetLength(1); IntPtr[] ptrs_sp = new IntPtr[outer]; for (var i = 0; i < outer; i++) { ptrs_sp[i] = Marshal.AllocHGlobal(inner * Marshal.SizeOf <double>()); } CoreDefinitions.CheapTrick(x, x_length, fs, temporal_positions, f0, f0_length, option, ptrs_sp); var tmp_arr = new double[inner]; for (var i = 0; i < spectrogram.GetLength(0); i++) { Marshal.Copy(ptrs_sp[i], tmp_arr, 0, inner); Buffer.BlockCopy(tmp_arr, 0, spectrogram, i * inner * sizeof(double), inner * sizeof(double)); Marshal.FreeHGlobal(ptrs_sp[i]); } }
public void SpectralEnvelopeEstimation(double[] x, int x_length, WorldParameters world_parameters) { var option = new CheapTrickOption(); Core.InitializeCheapTrickOption(world_parameters.fs, option); option.q1 = -0.15; option.f0_floor = 71.0; world_parameters.fft_size = Core.GetFFTSizeForCheapTrick(world_parameters.fs, option); world_parameters.spectrogram = new double[world_parameters.f0_length, world_parameters.fft_size / 2 + 1]; Core.CheapTrick(x, x_length, world_parameters.fs, world_parameters.time_axis, world_parameters.f0, world_parameters.f0_length, option, world_parameters.spectrogram); }
public static void InitializeCheapTrickOption(int fs, CheapTrickOption option) => CoreDefinitions.InitializeCheapTrickOption(fs, option);
public static int GetFFTSizeForCheapTrick(int fs, CheapTrickOption option) => CoreDefinitions.GetFFTSizeForCheapTrick(fs, option);
static extern void InitOption(int fs, [Out] out CheapTrickOption option);
static extern int GetFftSize(int fs, [In] ref CheapTrickOption option);
public static void CheapTrick(double[] x, int x_length, int fs, double[] temporal_positions, double[] f0, int f0_length, CheapTrickOption option, double[,] spectrogram) { }
static extern void Compute([In] double[] x, int x_length, int fs, [In] double[] temporal_positions, [In] double[] f0, int f0_length, [In] ref CheapTrickOption option, [In, Out] IntPtr[] spectrogram);
public static int GetFFTSizeForCheapTrick(int fs, CheapTrickOption option) { throw null; }
public static void InitializeCheapTrickOption(int fs, CheapTrickOption option) { }
public static extern int GetFFTSizeForCheapTrick(int fs, [Out] CheapTrickOption option);
public static extern void InitializeCheapTrickOption(int fs, [Out] CheapTrickOption option);
public static extern void CheapTrick([In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] double[] x, int x_length, int fs, [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] double[] temporal_positions, [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] double[] f0, int f0_length, [In] CheapTrickOption option, [In][Out] IntPtr[] spectrogram);