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); } }
public static bool SetRawStartOffset(this SndFile sndFile, long offset) { if (sndFile == null) { throw new ArgumentNullException(nameof(sndFile)); } return(SetLong(sndFile, SfCommand.SetRawStartOffset, offset)); }
public static bool FileTruncate([NotNull] this SndFile sndFile, long frames) { if (sndFile == null) { throw new ArgumentNullException(nameof(sndFile)); } return(SetLong(sndFile, SfCommand.FileTruncate, frames)); }
private static bool GetBool([NotNull] SndFile sndFile, SfCommand command) { if (sndFile == null) { throw new ArgumentNullException(nameof(sndFile)); } return(SetBool(sndFile, command, false)); }
public static void UpdateHeaderNow([NotNull] this SndFile sndFile) { if (sndFile == null) { throw new ArgumentNullException(nameof(sndFile)); } sf_command(sndFile, SfCommand.UpdateHeaderNow, IntPtr.Zero, 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); }
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); }
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); }
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)); }
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)); }
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); }
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()); } }
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); }
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)); } }
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); } }
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)); } }
public static bool SetScaleFloatIntRead(this SndFile sndFile, bool enable) { return(SetBool(sndFile, SfCommand.SetScaleFloatIntRead, enable)); }
public static bool SetBroadcastInfo(this SndFile sndFile, SfBroadcastInfo broadcastInfo) { return(SetStructure(sndFile, SfCommand.SetBroadcastInfo, broadcastInfo, SF_TRUE)); }
public static bool SetCartInfo(this SndFile sndFile, SfCartInfo cartInfo) { return(SetStructure(sndFile, SfCommand.SetCartInfo, cartInfo, SF_TRUE)); }
public static bool SetClipping(this SndFile sndFile, bool enable) { return(SetBool(sndFile, SfCommand.SetClipping, enable)); }
public static bool SetCue(this SndFile sndFile, SfCues cues) { return(SetStructure(sndFile, SfCommand.SetCue, cues, SF_TRUE)); }
public static bool SetInstrument(this SndFile sndFile, SfInstrument instrument) { return(SetStructure(sndFile, SfCommand.SetInstrument, instrument, SF_TRUE)); }
public static bool SetNormFloat(this SndFile sndFile, bool enable) { return(SetBool(sndFile, SfCommand.SetNormFloat, enable)); }
public static bool SetScaleIntFloatWrite(this SndFile sndFile, bool enable) { return(SetBool(sndFile, SfCommand.SetScaleIntFloatWrite, enable)); }
public static bool Rf64AutoDowngrade(this SndFile sndFile, bool enable) { return(SetBool(sndFile, SfCommand.Rf64AutoDowngrade, enable)); }
public static double?CalcNormSignalMax(this SndFile sndFile) { return(GetDouble(sndFile, SfCommand.CalcNormSignalMax, 0)); }
public static double[] CalcNormMaxAllChannels(this SndFile sndFile) { return(GetDoubles(sndFile, SfCommand.CalcNormMaxAllChannels, 0)); }
public static bool SetAddPeakChunk(this SndFile sndFile, bool enable) { return(SetBool(sndFile, SfCommand.SetAddPeakChunk, enable)); }
public static unsafe string GetErrorMessage([CanBeNull] SndFile sndFile = null) { return(GetErrorMessage(sndFile == null ? null : sndFile.Handle)); }
public static bool SetUpdateHeaderAuto(this SndFile sndFile, bool enable) { return(SetBool(sndFile, SfCommand.SetUpdateHeaderAuto, enable)); }