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