annotate src/libsndfile-1.0.27/doc/octave.html @ 40:1df64224f5ac

Current libsndfile source
author Chris Cannam
date Tue, 18 Oct 2016 13:22:47 +0100
parents
children
rev   line source
Chris@40 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Chris@40 2 <HTML>
Chris@40 3
Chris@40 4 <HEAD>
Chris@40 5 <TITLE>
Chris@40 6 libsndfile and GNU Octave
Chris@40 7 </TITLE>
Chris@40 8 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
Chris@40 9 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
Chris@40 10 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
Chris@40 11 </HEAD>
Chris@40 12
Chris@40 13 <BODY>
Chris@40 14
Chris@40 15 <BR>
Chris@40 16 <H1><B>libsndfile and GNU Octave</B></H1>
Chris@40 17 <P>
Chris@40 18 <A HREF="http://www.octave.org/">GNU Octave</A> is a high-level interactive
Chris@40 19 language for numerical computations.
Chris@40 20 There are currently two development streams, a stable 2.0.X series and a
Chris@40 21 development 2.1.X series.
Chris@40 22 Octave reads and writes data in binary formats that were originally developed
Chris@40 23 for
Chris@40 24 <A HREF="http://www.mathworks.com/">MATLAB</A>.
Chris@40 25 Version 2.0.X of Octave uses binary data files compatible with MATLAB
Chris@40 26 version 4.2 while Octave 2.1.X uses binary data files compatible
Chris@40 27 with MATLAB version 5.0 as well as being able to read the older MATLAB 4.2
Chris@40 28 format.
Chris@40 29 </P>
Chris@40 30 <P>
Chris@40 31 From version 1.0.1 of libsndfile onwards, libsndfile has the ability of reading
Chris@40 32 and writing a small subset of the binary data files used by both versions
Chris@40 33 of GNU Octave.
Chris@40 34 This gives people using GNU Octave for audio based work an easy method of
Chris@40 35 moving audio data between GNU Octave and other programs which use libsndfile.
Chris@40 36 </P>
Chris@40 37 <P>
Chris@40 38 For instance it is now possible to do the following:
Chris@40 39 </P>
Chris@40 40
Chris@40 41 <UL>
Chris@40 42 <LI> Load a WAV file into a sound file editor such as
Chris@40 43 <A HREF="http://www.metadecks.org/software/sweep/">Sweep</A>.
Chris@40 44 <LI> Save it as a MAT4 file.
Chris@40 45 <LI> Load the data into Octave for manipulation.
Chris@40 46 <LI> Save the modified data.
Chris@40 47 <LI> Reload it in Sweep.
Chris@40 48 </UL>
Chris@40 49 <P>
Chris@40 50 Another example would be using the MAT4 or MAT5 file formats as a format which
Chris@40 51 can be easily loaded into Octave for viewing/analyzing as well as a format
Chris@40 52 which can be played with command line players such as the one included with
Chris@40 53 libsndfile.
Chris@40 54 </P>
Chris@40 55
Chris@40 56 <H2><B>Details</B></H2>
Chris@40 57 <P>
Chris@40 58 Octave, like most programming languages, uses variables to store data, and
Chris@40 59 Octave variables can contain both arrays and matrices.
Chris@40 60 It is also able to store one or more of these variables in a file.
Chris@40 61 When reading Octave files, libsndfile expects a file to contain two
Chris@40 62 variables and their associated data.
Chris@40 63 The first variable should contain a variable holding the file sample rate
Chris@40 64 while the second variable contains the audio data.
Chris@40 65 </P>
Chris@40 66 <P>
Chris@40 67 For example, to generate a sine wave and store it as a binary file which
Chris@40 68 is compatible with libsndfile, do the following:
Chris@40 69 </P>
Chris@40 70 <PRE>
Chris@40 71 octave:1 > samplerate = 44100 ;
Chris@40 72 octave:2 > wavedata = sin ((0:1023)*2*pi/1024) ;
Chris@40 73 octave:3 > save sine.mat samplerate wavedata
Chris@40 74 </PRE>
Chris@40 75
Chris@40 76 <P>
Chris@40 77 The process of reading and writing files compatible with libsndfile can be
Chris@40 78 made easier by use of two Octave script files :
Chris@40 79 </P>
Chris@40 80 <PRE>
Chris@40 81 octave:4 > [data fs] = sndfile_load ("sine.mat") ;
Chris@40 82 octave:5 > sndfile_save ("sine2.mat", data, fs) ;
Chris@40 83 </PRE>
Chris@40 84 <P>
Chris@40 85 In addition, libsndfile contains a command line program which which is able
Chris@40 86 to play the correct types of Octave files.
Chris@40 87 Using this command line player <B>sndfile-play</B> and a third Octave script
Chris@40 88 file allows Octave data to be played from within Octave on any of the platforms
Chris@40 89 which <B>sndfile-play</B> supports (at the moment: Linux, MacOS X, Solaris and
Chris@40 90 Win32).
Chris@40 91 </P>
Chris@40 92 <PRE>
Chris@40 93 octave:6 > sndfile_play (data, fs) ;
Chris@40 94 </PRE>
Chris@40 95 <P>
Chris@40 96 These three Octave scripts are installed automatically in Octave's site
Chris@40 97 script directory when libsndfile is installed (except on Win32) ie when
Chris@40 98 libsndfile is being installed into /usr/local, the Octave scripts will
Chris@40 99 be installed in /usr/local/share/octave/site/m/.
Chris@40 100 </P>
Chris@40 101
Chris@40 102 <P>
Chris@40 103 There are some other Octave scripts for audio to be found
Chris@40 104 <A HREF="http://octave.sourceforge.net/audio/index.html">here</A>.
Chris@40 105 </P>
Chris@40 106
Chris@40 107 <BR>
Chris@40 108 <!-- ========================================================================= -->
Chris@40 109
Chris@40 110 <HR>
Chris@40 111 <P>
Chris@40 112 The libsndfile home page is here :
Chris@40 113 <A HREF="http://www.mega-nerd.com/libsndfile/">
Chris@40 114 http://www.mega-nerd.com/libsndfile/</A>.
Chris@40 115 </P>
Chris@40 116
Chris@40 117 </BODY>
Chris@40 118 </HTML>