예제 #1
0
 private static bool SetStructure <T>(SndFile sndFile, SfCommand command, T structure, int valid) where T : struct
 {
     using (var m = new Marshaller <T>(structure))
     {
         var i = sf_command(sndFile, command, m.Address, m.Size);
         return(i == valid);
     }
 }
예제 #2
0
        public static bool SetRawStartOffset(this SndFile sndFile, long offset)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            return(SetLong(sndFile, SfCommand.SetRawStartOffset, offset));
        }
예제 #3
0
        public static bool FileTruncate([NotNull] this SndFile sndFile, long frames)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            return(SetLong(sndFile, SfCommand.FileTruncate, frames));
        }
예제 #4
0
        private static bool GetBool([NotNull] SndFile sndFile, SfCommand command)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            return(SetBool(sndFile, command, false));
        }
예제 #5
0
        public static void UpdateHeaderNow([NotNull] this SndFile sndFile)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            sf_command(sndFile, SfCommand.UpdateHeaderNow, IntPtr.Zero, 0);
        }
예제 #6
0
        private static unsafe int sf_command([NotNull] SndFile sndFile, SfCommand cmd, void *data, int dataSize)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            var i = sf_command(sndFile.Handle, cmd, data, dataSize);

            return(i);
        }
예제 #7
0
        private static unsafe bool SetLong([NotNull] SndFile sndFile, SfCommand command, long value)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }


            var i = sf_command(sndFile, command, &value, sizeof(long));

            return(i == 0);
        }
예제 #8
0
        public static unsafe uint?GetCueCount(this SndFile sndFile)
        {
            var u = default(uint);

            var i = sf_command(sndFile, SfCommand.GetCueCount, &u, sizeof(uint));

            if (i != SF_TRUE)
            {
                return(null);
            }

            return(u);
        }
예제 #9
0
        public static bool SetVbrEncodingQuality(this SndFile sndFile, double quality)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            if (quality < 0.0d || quality > 1.0d)
            {
                throw new ArgumentOutOfRangeException(nameof(quality));
            }

            return(SetDouble(sndFile, SfCommand.SetVbrEncodingQuality, quality));
        }
예제 #10
0
        public static bool SetCompressionLevel(this SndFile sndFile, double level)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            if (level < 0.0d || level > 1.0d)
            {
                throw new ArgumentOutOfRangeException(nameof(level));
            }

            return(SetDouble(sndFile, SfCommand.SetCompressionLevel, level));
        }
예제 #11
0
        public static SfAmbisonic?SetAmbisonic([NotNull] this SndFile sndFile, SfAmbisonic ambisonic)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            var i = sf_command(sndFile, SfCommand.WavexSetAmbisonic, IntPtr.Zero, (int)ambisonic);

            if (i == 0)
            {
                return(null);
            }

            return((SfAmbisonic)i);
        }
예제 #12
0
        private static unsafe T?GetStructure <T>([CanBeNull] SndFile sndFile, SfCommand command, T structure, int valid)
            where T : struct
        {
            using (var m = new Marshaller <T>(structure))
            {
                var handle = sndFile != null ? sndFile.Handle : null;

                var i = sf_command(handle, command, m.Address, m.Size);
                if (i != valid)
                {
                    return(null);
                }

                return(m.Pop());
            }
        }
예제 #13
0
        private static unsafe double?GetDouble([NotNull] SndFile sndFile, SfCommand command, int match)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            var d = default(double);

            var i = sf_command(sndFile, command, &d, sizeof(double));

            if (i != match)
            {
                return(null);
            }

            return(d);
        }
예제 #14
0
        private static unsafe bool SetDouble([NotNull] SndFile sndFile, SfCommand command, double value)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            var i = sf_command(sndFile, command, &value, sizeof(double));

            switch (i)
            {
            case SF_TRUE:
                return(true);

            case SF_FALSE:
                return(false);

            default:
                throw new ArgumentOutOfRangeException(nameof(i));
            }
        }
예제 #15
0
        private static unsafe double[] GetDoubles([NotNull] SndFile sndFile, SfCommand command, int match)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            var doubles = new double[sndFile.Format.Channels];

            fixed(double *d = doubles)
            {
                var i = sf_command(sndFile.Handle, command, d, sizeof(double) * doubles.Length);

                if (i != match)
                {
                    return(null);
                }

                return(doubles);
            }
        }
예제 #16
0
        private static bool SetBool([NotNull] SndFile sndFile, SfCommand command, bool value)
        {
            if (sndFile == null)
            {
                throw new ArgumentNullException(nameof(sndFile));
            }

            var i = sf_command(sndFile, command, IntPtr.Zero, value ? SF_TRUE : SF_FALSE);

            switch (i)
            {
            case SF_TRUE:
                return(true);

            case SF_FALSE:
                return(false);

            default:
                throw new ArgumentOutOfRangeException(nameof(i));
            }
        }
예제 #17
0
 public static bool SetScaleFloatIntRead(this SndFile sndFile, bool enable)
 {
     return(SetBool(sndFile, SfCommand.SetScaleFloatIntRead, enable));
 }
예제 #18
0
 public static bool SetBroadcastInfo(this SndFile sndFile, SfBroadcastInfo broadcastInfo)
 {
     return(SetStructure(sndFile, SfCommand.SetBroadcastInfo, broadcastInfo, SF_TRUE));
 }
예제 #19
0
 public static bool SetCartInfo(this SndFile sndFile, SfCartInfo cartInfo)
 {
     return(SetStructure(sndFile, SfCommand.SetCartInfo, cartInfo, SF_TRUE));
 }
예제 #20
0
 public static bool SetClipping(this SndFile sndFile, bool enable)
 {
     return(SetBool(sndFile, SfCommand.SetClipping, enable));
 }
예제 #21
0
 public static bool SetCue(this SndFile sndFile, SfCues cues)
 {
     return(SetStructure(sndFile, SfCommand.SetCue, cues, SF_TRUE));
 }
예제 #22
0
 public static bool SetInstrument(this SndFile sndFile, SfInstrument instrument)
 {
     return(SetStructure(sndFile, SfCommand.SetInstrument, instrument, SF_TRUE));
 }
예제 #23
0
 public static bool SetNormFloat(this SndFile sndFile, bool enable)
 {
     return(SetBool(sndFile, SfCommand.SetNormFloat, enable));
 }
예제 #24
0
 public static bool SetScaleIntFloatWrite(this SndFile sndFile, bool enable)
 {
     return(SetBool(sndFile, SfCommand.SetScaleIntFloatWrite, enable));
 }
예제 #25
0
 public static bool Rf64AutoDowngrade(this SndFile sndFile, bool enable)
 {
     return(SetBool(sndFile, SfCommand.Rf64AutoDowngrade, enable));
 }
예제 #26
0
 public static double?CalcNormSignalMax(this SndFile sndFile)
 {
     return(GetDouble(sndFile, SfCommand.CalcNormSignalMax, 0));
 }
예제 #27
0
 public static double[] CalcNormMaxAllChannels(this SndFile sndFile)
 {
     return(GetDoubles(sndFile, SfCommand.CalcNormMaxAllChannels, 0));
 }
예제 #28
0
 public static bool SetAddPeakChunk(this SndFile sndFile, bool enable)
 {
     return(SetBool(sndFile, SfCommand.SetAddPeakChunk, enable));
 }
예제 #29
0
 public static unsafe string GetErrorMessage([CanBeNull] SndFile sndFile = null)
 {
     return(GetErrorMessage(sndFile == null ? null : sndFile.Handle));
 }
예제 #30
0
 public static bool SetUpdateHeaderAuto(this SndFile sndFile, bool enable)
 {
     return(SetBool(sndFile, SfCommand.SetUpdateHeaderAuto, enable));
 }