public static void GenerateMusicProperty(ref MusicProperty prop, WAVEFORMATEX format, EDataType type, byte[] data)
        {
            IntPtr propPtr = Marshal.AllocHGlobal(Marshal.SizeOf(prop));

            Marshal.StructureToPtr(prop, propPtr, false);

            IntPtr formatPtr = Marshal.AllocHGlobal(Marshal.SizeOf(format));

            Marshal.StructureToPtr(format, formatPtr, false);

            IntPtr ptr = Marshal.AllocHGlobal(data.Length);

            Marshal.Copy(data, 0, ptr, data.Length);

            WaveFileManagerNative.generateMusicProperty(propPtr, formatPtr, type, ptr, (uint)data.Length);

            prop = Marshal.PtrToStructure <MusicProperty>(propPtr);

            Marshal.FreeHGlobal(propPtr);
            Marshal.FreeHGlobal(formatPtr);

            // It should be free, but can't do that.
            // This bug will be fixed.
            // Marshal.FreeHGlobal(ptr);
        }
        public static void CreateFile(string path, MusicProperty prop)
        {
            IntPtr propPointer = Marshal.AllocHGlobal(Marshal.SizeOf(prop));

            Marshal.StructureToPtr(prop, propPointer, false);
            WaveFileManagerNative.createFile(path, propPointer);
            Marshal.FreeHGlobal(propPointer);
        }
        public static void GenerateWAVEFORMATEX(ref WAVEFORMATEX format, EDataType dataType)
        {
            IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(format));

            Marshal.StructureToPtr(format, ptr, false);
            WaveFileManagerNative.generateWAVEFORMATEX(ptr, dataType);
            format = Marshal.PtrToStructure <WAVEFORMATEX>(ptr);
            Marshal.FreeHGlobal(ptr);
        }
        public static void GenerateSoundMonaural16bits(byte[] data, double herth, int samplesPerSec = 44100, int volume = 30000)
        {
            var dataPtr = Marshal.AllocHGlobal(data.Length);

            Marshal.Copy(data, 0, dataPtr, data.Length);

            WaveFileManagerNative.generateSoundMonaural16bits(dataPtr, (uint)data.Length, herth, samplesPerSec, volume);

            Marshal.Copy(dataPtr, data, 0, data.Length);
        }