Exemple #1
0
        public void WaveformSynthesis2(WorldParameters world_parameters, int fs, int y_length, double[] y)
        {
            var synthesizer = new WorldSynthesizer();
            int buffer_size = 64;

            Core.InitializeSynthesizer(world_parameters.fs, world_parameters.frame_period,
                                       world_parameters.fft_size, buffer_size, 100, synthesizer);

            Core.AddParameters(world_parameters.f0, world_parameters.f0_length,
                               world_parameters.spectrogram, world_parameters.aperiodicity,
                               synthesizer);

            int index;
            var _buf = new double[buffer_size];

            for (var i = 0; Core.Synthesis2(synthesizer); ++i)
            {
                index = i * buffer_size;
                synthesizer.CopyFromBufferToArray(_buf);
                for (var j = 0; j < buffer_size; ++j)
                {
                    y [j + index] = _buf[j];
                }
            }

            Core.DestroySynthesizer(synthesizer);
        }
Exemple #2
0
 public static bool IsLocked(WorldSynthesizer synth)
 => CoreDefinitions.IsLocked(synth) == 1;
Exemple #3
0
 public static void DestroySynthesizer(WorldSynthesizer synth)
 => CoreDefinitions.DestroySynthesizer(synth);
Exemple #4
0
 public static void RefreshSynthesizer(WorldSynthesizer synth)
 => CoreDefinitions.RefreshSynthesizer(synth);
Exemple #5
0
        public static bool AddParameters(double[] f0, int f0_length, double[,] spectrogram, double[,] aperiodicity, WorldSynthesizer synth)
        {
            int outer = aperiodicity.GetLength(0);
            int inner = aperiodicity.GetLength(1);

            IntPtr[] ptrs_ap = new IntPtr[outer];
            IntPtr[] ptrs_sp = new IntPtr[outer];

            var tmp_arr = new double[inner];

            for (var i = 0; i < outer; i++)
            {
                ptrs_ap[i] = Marshal.AllocHGlobal(inner * Marshal.SizeOf <double>());
                ptrs_sp[i] = Marshal.AllocHGlobal(inner * Marshal.SizeOf <double>());

                Buffer.BlockCopy(spectrogram, i * inner * sizeof(double), tmp_arr, 0, inner * sizeof(double));
                Marshal.Copy(tmp_arr, 0, ptrs_sp[i], inner);
                Buffer.BlockCopy(aperiodicity, i * inner * sizeof(double), tmp_arr, 0, inner * sizeof(double));
                Marshal.Copy(tmp_arr, 0, ptrs_ap[i], inner);
            }

            var res = CoreDefinitions.AddParameters(f0, f0_length, ptrs_sp, ptrs_ap, synth);

            // WorldSynthesizer はアドレスを保持しているからここでは解放できない => この IntPtr を保持して Destroy 前に破棄?
            for (var i = 0; i < outer; i++)
            {
                Marshal.FreeHGlobal(ptrs_ap[i]);
                Marshal.FreeHGlobal(ptrs_sp[i]);
            }

            return(res == 1);
        }
Exemple #6
0
 public static void InitializeSynthesizer(int fs, double frame_period, int fft_size, int buffer_size, int number_of_pointers, WorldSynthesizer synth)
 => CoreDefinitions.InitializeSynthesizer(fs, frame_period, fft_size, buffer_size, number_of_pointers, synth);
 public static bool Synthesis2(WorldSynthesizer synth)
 {
     throw null;
 }
Exemple #8
0
 public static extern int IsLocked([In] WorldSynthesizer synth);
 public static void DestroySynthesizer(WorldSynthesizer synth)
 {
 }
 public static void RefreshSynthesizer(WorldSynthesizer synth)
 {
 }
 public static bool AddParameters(double[] f0, int f0_length, double[,] spectrogram, double[,] aperiodicity, WorldSynthesizer synth)
 {
     throw null;
 }
 public static void InitializeSynthesizer(int fs, double frame_period, int fft_size, int buffer_size, int number_of_pointers, WorldSynthesizer synth)
 {
 }
Exemple #13
0
 public static extern void RefreshSynthesizer([In][Out] WorldSynthesizer synth);
Exemple #14
0
 public static extern int AddParameters([In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] double[] f0,
                                        int f0_length, [In] IntPtr[] spectrogram, [In] IntPtr[] aperiodicity, [In][Out] WorldSynthesizer synth);
Exemple #15
0
 public static extern int Synthesis2([In][Out] WorldSynthesizer synth);
Exemple #16
0
 public static bool Synthesis2(WorldSynthesizer synth)
 => CoreDefinitions.Synthesis2(synth) == 1;
 public static bool IsLocked(WorldSynthesizer synth)
 {
     throw null;
 }
Exemple #18
0
 public static extern void DestroySynthesizer([In][Out] WorldSynthesizer synth);