annotate src/libsndfile-1.0.25/doc/octave.html @ 0:c7265573341e

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