Exemple #1
0
 private static void CheckOpenParameters(SfFormat format,
                                         [AssertionCondition(AssertionConditionType.IS_TRUE)] SfMode mode)
 {
     if (format == SfFormat.Empty && mode != SfMode.Read)
     {
         throw new ArgumentNullException(nameof(format));
     }
 }
Exemple #2
0
 public bool Equals(SfFormat other)
 {
     return(Major == other.Major &&
            Subtype == other.Subtype &&
            Endian == other.Endian &&
            Channels == other.Channels &&
            SampleRate == other.SampleRate);
 }
Exemple #3
0
        public static SndFile OpenWrite([NotNull] string path, SfFormat format)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            return(Open__(path, format, SfMode.Write));
        }
Exemple #4
0
        private static unsafe SndFile Open__(
            SfVirtual @virtual, SfMode mode, IntPtr userData, SfFormat format)
        {
            if (@virtual == SfVirtual.Empty)
            {
                throw new ArgumentNullException(nameof(@virtual));
            }

            CheckOpenParameters(format, mode);

            var info    = format.ToInfo();
            var sndFile = sf_open_virtual(ref @virtual, mode, ref info, userData);

            return(sndFile == null ? null : new SndFile(sndFile, info));
        }
Exemple #5
0
        private static unsafe SndFile Open__(
            [NotNull] string path, SfFormat format, SfMode mode)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            CheckOpenParameters(format, mode);

            var info    = format.ToInfo();
            var sndFile = sf_wchar_open(path, mode, ref info);

            return(sndFile == null ? null : new SndFile(sndFile, info));
        }
Exemple #6
0
        public static bool FormatCheck(SfFormat format)
        {
            var info = (SfInfo)format;

            return(sf_format_check(ref info));
        }
Exemple #7
0
 public static SndFile OpenWrite(SfVirtual @virtual, SfFormat format, IntPtr userData = default)
 {
     return(Open__(@virtual, SfMode.Write, userData, format));
 }