~ubuntu-branches/ubuntu/gutsy/audacity/gutsy-backports

« back to all changes in this revision

Viewing changes to lib-src/libsndfile/src/wve.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-18 21:58:19 UTC
  • mfrom: (13.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080218215819-tmbcf1rx238r8gdv
Tags: 1.3.4-1.1ubuntu1~gutsy1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
3
 
**
4
 
** This program is free software; you can redistribute it and/or modify
5
 
** it under the terms of the GNU Lesser General Public License as published by
6
 
** the Free Software Foundation; either version 2.1 of the License, or
7
 
** (at your option) any later version.
8
 
**
9
 
** This program is distributed in the hope that it will be useful,
10
 
** but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
** GNU Lesser General Public License for more details.
13
 
**
14
 
** You should have received a copy of the GNU Lesser General Public License
15
 
** along with this program; if not, write to the Free Software
16
 
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
 
*/
18
 
 
19
 
#include        "sfconfig.h"
20
 
 
21
 
#include        <stdio.h>
22
 
#include        <fcntl.h>
23
 
#include        <string.h>
24
 
#include        <ctype.h>
25
 
 
26
 
#include        "sndfile.h"
27
 
#include        "sfendian.h"
28
 
#include        "common.h"
29
 
 
30
 
#if (ENABLE_EXPERIMENTAL_CODE == 0)
31
 
 
32
 
int
33
 
wve_open        (SF_PRIVATE *psf)
34
 
{       if (psf)
35
 
                return SFE_UNIMPLEMENTED ;
36
 
        return (psf && 0) ;
37
 
} /* wve_open */
38
 
 
39
 
#else
40
 
 
41
 
#define SFE_WVE_NOT_WVE 666
42
 
 
43
 
/*------------------------------------------------------------------------------
44
 
** Macros to handle big/little endian issues.
45
 
*/
46
 
 
47
 
#define ALAW_MARKER             MAKE_MARKER ('A', 'L', 'a', 'w')
48
 
#define SOUN_MARKER             MAKE_MARKER ('S', 'o', 'u', 'n')
49
 
#define DFIL_MARKER             MAKE_MARKER ('d', 'F', 'i', 'l')
50
 
 
51
 
/*------------------------------------------------------------------------------
52
 
** Private static functions.
53
 
*/
54
 
 
55
 
static int      wve_read_header (SF_PRIVATE *psf) ;
56
 
 
57
 
/*------------------------------------------------------------------------------
58
 
** Public function.
59
 
*/
60
 
 
61
 
int
62
 
wve_open (SF_PRIVATE *psf)
63
 
{       int     subformat, error = 0 ;
64
 
 
65
 
        if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
66
 
                return SFE_UNIMPLEMENTED ;
67
 
 
68
 
        if ((error = wve_read_header (psf)))
69
 
                return error ;
70
 
 
71
 
        if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WVE)
72
 
                return  SFE_BAD_OPEN_FORMAT ;
73
 
 
74
 
        subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
75
 
 
76
 
        return error ;
77
 
} /* wve_open */
78
 
 
79
 
/*------------------------------------------------------------------------------
80
 
*/
81
 
 
82
 
static int
83
 
wve_read_header (SF_PRIVATE *psf)
84
 
{       int marker ;
85
 
 
86
 
        /* Set position to start of file to begin reading header. */
87
 
        psf_binheader_readf (psf, "pm", 0, &marker) ;
88
 
        if (marker != ALAW_MARKER)
89
 
                return SFE_WVE_NOT_WVE ;
90
 
 
91
 
        psf_binheader_readf (psf, "m", &marker) ;
92
 
        if (marker != SOUN_MARKER)
93
 
                return SFE_WVE_NOT_WVE ;
94
 
 
95
 
        psf_binheader_readf (psf, "m", &marker) ;
96
 
        if (marker != DFIL_MARKER)
97
 
                return SFE_WVE_NOT_WVE ;
98
 
 
99
 
        psf_log_printf (psf, "Read only : Psion Palmtop Alaw (.wve)\n"
100
 
                        "  Sample Rate : 8000\n"
101
 
                        "  Channels    : 1\n"
102
 
                        "  Encoding    : A-law\n") ;
103
 
 
104
 
        psf->dataoffset = 0x20 ;
105
 
        psf->datalength = psf->filelength - psf->dataoffset ;
106
 
 
107
 
        psf->sf.format          = SF_FORMAT_WVE | SF_FORMAT_ALAW ;
108
 
        psf->sf.samplerate      = 8000 ;
109
 
        psf->sf.frames          = psf->datalength ;
110
 
        psf->sf.channels        = 1 ;
111
 
 
112
 
        return alaw_init (psf) ;
113
 
} /* wve_read_header */
114
 
 
115
 
/*------------------------------------------------------------------------------
116
 
*/
117
 
 
118
 
#endif
119
 
/*
120
 
** Do not edit or modify anything in this comment block.
121
 
** The arch-tag line is a file identity tag for the GNU Arch 
122
 
** revision control system.
123
 
**
124
 
** arch-tag: ba368cb5-523f-45e4-98c1-5b99a102f73f
125
 
*/