/// <summary> /// Attempts to execute the <paramref name="command"/> against the <paramref name="sndfile"/> audio /// file while either passing or receiving data through the <paramref name="data"/> buffer. /// </summary> /// <param name="sndfile">Audio file we run this command against. /// Use NULL if you wish to run a static command against the library.</param> /// <param name="command"><see cref="NLibsndfile.Native.LibsndfileCommand"/> to run against the given audio file.</param> /// <param name="data">IntPtr(Void*) buffer for passing or receiving data based on the <paramref name="command"/> specifications.</param> /// <param name="size">Length in bytes of the data being passed through the <paramref name="data"/> buffer.</param> /// <returns>Returns a specific value based on the <paramref name="command"/>.</returns> public int Command(IntPtr sndfile, LibsndfileCommand command, IntPtr data, int size) { if (sndfile == IntPtr.Zero && !LibsndfileCommandUtilities.IsStaticCommand(command)) { throw new ArgumentException("File handle is invalid/closed."); } var retval = m_Api.Command(sndfile, command, data, size); if (!LibsndfileCommandUtilities.IsValidResult(sndfile, command, retval)) { throw new LibsndfileException(string.Format("Command {0} returned an invalid result.", command)); } return(retval); }
/// <summary> /// Returns the version of the Libsndfile library. /// </summary> /// <returns>Libsndfile library version.</returns> public string GetLibVersion() { const int MaxVersionLength = 128; using (var memory = m_Marshaller.Allocate(MaxVersionLength)) { var retval = m_Api.Command(IntPtr.Zero, LibsndfileCommand.GetLibVersion, memory, MaxVersionLength); if (!LibsndfileCommandUtilities.IsValidResult(IntPtr.Zero, LibsndfileCommand.GetLibVersion, retval)) { throw new LibsndfileException("Unable to retrieve Libsndfile library version."); } return(m_Marshaller.MemoryHandleToString(memory)); } }