From 0586befa36faba57a0462af7dd9795178d1b5111 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Mon, 27 Oct 2008 21:24:55 +1100 Subject: [PATCH] Octave/sndfile.cc : Add Octave function sfversion which returns the libsndfile version that the module is linked against. --- ChangeLog | 4 ++++ Octave/PKG_ADD | 1 + Octave/sndfile.cc | 32 +++++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7cc29682..20f3f542 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,10 @@ * Octave/* Reduce 3 C++ files to one, fix build for octave 3.0, fix build. + * Octave/sndfile.cc Octave/PKG_ADD + Add Octave function sfversion which returns the libsndfile version that the + module is linked against. + 2008-10-26 Erik de Castro Lopo * programs/common.c diff --git a/Octave/PKG_ADD b/Octave/PKG_ADD index 676e8bf4..3efd6885 100644 --- a/Octave/PKG_ADD +++ b/Octave/PKG_ADD @@ -1,2 +1,3 @@ autoload ("sfread", "sndfile.oct"); +autoload ("sfversion", "sndfile.oct"); autoload ("sfwrite", "sndfile.oct"); diff --git a/Octave/sndfile.cc b/Octave/sndfile.cc index 26138c58..e8d49b78 100644 --- a/Octave/sndfile.cc +++ b/Octave/sndfile.cc @@ -28,12 +28,35 @@ static int format_of_str (const std::string & fmt) ; static void string_of_format (std::string & fmt, int format) ; +DEFUN_DLD (sfversion, args, nargout , +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {@var{version} =} sfversion ()\n\ +@cindex Reading sound files\n\ +Return a string containing the libsndfile version.\n\ +@end deftypefn") +{ char buffer [256] ; + octave_value_list retval ; + + /* Bail out if the input parameters are bad. */ + if (args.length () != 0 || nargout > 1) + { print_usage () ; + return retval ; + } ; + + sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ; + + std::string version (buffer) ; + + retval.append (version) ; + return retval ; +} /* sfversion */ + + DEFUN_DLD (sfread, args, nargout , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {@var{I},@var{srate},@var{format} =} sfread (@var{filename})\n\ +@deftypefn {Loadable Function} {@var{data},@var{srate},@var{format} =} sfread (@var{filename})\n\ @cindex Reading sound files\n\ Read a sound file from disk using libsndfile.\n\ -\n\ @seealso{wavread}\n\ @end deftypefn") { SNDFILE * file ; @@ -105,11 +128,10 @@ Read a sound file from disk using libsndfile.\n\ return retval ; } /* sfread */ -DEFUN_DLD (sfwrite, args, nargout , "\ --*- texinfo -*-\n\ +DEFUN_DLD (sfwrite, args, nargout , +"-*- texinfo -*-\n\ @deftypefn {Function File} sfwrite (@var{filename},@var{data},@var{srate},@var{format})\n\ Write a sound file to disk using libsndfile.\n\ -\n\ @seealso{wavwrite}\n\ @end deftypefn\n\ ")