Exemplo n.º 1
0
        public unsafe static bool BASS_Encode_GetACMFormat(int handle, ref ACMFORMAT codec, string title, BASSACMFormat flags)
        {
            int num = BassEnc.BASS_Encode_GetACMFormatUnicode(0, IntPtr.Zero, 0, null, BASSACMFormat.BASS_ACM_NONE);

            byte[] array  = new byte[(num > codec.FormatLength) ? num : codec.FormatLength];
            bool   result = false;

            byte[] array2 = new byte[Marshal.SizeOf(codec) + (int)codec.waveformatex.cbSize];
            int    num2   = Marshal.SizeOf(codec);
            IntPtr intPtr = Marshal.AllocHGlobal(num2);

            Marshal.StructureToPtr(codec, intPtr, false);
            Marshal.Copy(intPtr, array2, 0, num2);
            Marshal.FreeHGlobal(intPtr);
            for (int i = 0; i < codec.extension.Length; i++)
            {
                array2[18 + i] = codec.extension[i];
            }
            Array.Copy(array2, array, num2);
            fixed(byte *ptr = array)
            {
                if (BassEnc.BASS_Encode_GetACMFormat(handle, (IntPtr)((void *)ptr), num, title, flags) > 0)
                {
                    codec  = new ACMFORMAT((IntPtr)((void *)ptr));
                    result = true;
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public static bool SaveToFile(ACMFORMAT form, string fileName)
        {
            if (form == null)
            {
                return(false);
            }
            bool            result          = false;
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            Stream          stream          = null;

            try
            {
                stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
                binaryFormatter.Serialize(stream, form);
                result = true;
            }
            catch
            {
            }
            finally
            {
                if (stream != null)
                {
                    stream.Flush();
                    stream.Close();
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public unsafe static ACMFORMAT BASS_Encode_GetACMFormatSuggest(int handle, BASSACMFormat flags, WAVEFormatTag format)
        {
            ACMFORMAT result = null;
            int       num    = BassEnc.BASS_Encode_GetACMFormatUnicode(0, IntPtr.Zero, 0, null, BASSACMFormat.BASS_ACM_NONE);

            fixed(byte *ptr = new byte[num])
            {
                if (BassEnc.BASS_Encode_GetACMFormat(handle, (IntPtr)((void *)ptr), num, null, (BASSACMFormat)Utils.MakeLong((int)flags, (int)format)) > 0)
                {
                    result = new ACMFORMAT((IntPtr)((void *)ptr));
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        public static ACMFORMAT LoadFromFile(string fileName)
        {
            ACMFORMAT  acmformat = null;
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = null;

            try
            {
                stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                bool flag = false;
                while (!flag)
                {
                    try
                    {
                        acmformat = (formatter.Deserialize(stream) as ACMFORMAT);
                        if (acmformat != null)
                        {
                            flag = true;
                        }
                    }
                    catch
                    {
                        flag = true;
                    }
                }
            }
            catch
            {
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                    stream.Dispose();
                    stream = null;
                }
            }
            return(acmformat);
        }
Exemplo n.º 5
0
 public static int BASS_Encode_StartACMFile(int handle, ACMFORMAT form, BASSEncode flags, string filename)
 {
     flags |= BASSEncode.BASS_UNICODE;
     return(BassEnc.BASS_Encode_StartACMFileUnicode(handle, form, flags, filename));
 }
Exemplo n.º 6
0
 private static extern int BASS_Encode_StartACMFileUnicode(int handle, [In] ACMFORMAT form, BASSEncode flags, [MarshalAs(UnmanagedType.LPWStr)][In] string file);
Exemplo n.º 7
0
 public static extern int BASS_Encode_StartACM(int handle, [In] ACMFORMAT form, BASSEncode flags, ENCODEPROC proc, IntPtr user);