2
** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
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.
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.
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.
30
#if (ENABLE_EXPERIMENTAL_CODE == 0)
33
wve_open (SF_PRIVATE *psf)
35
return SFE_UNIMPLEMENTED ;
41
#define SFE_WVE_NOT_WVE 666
43
/*------------------------------------------------------------------------------
44
** Macros to handle big/little endian issues.
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')
51
/*------------------------------------------------------------------------------
52
** Private static functions.
55
static int wve_read_header (SF_PRIVATE *psf) ;
57
/*------------------------------------------------------------------------------
62
wve_open (SF_PRIVATE *psf)
63
{ int subformat, error = 0 ;
65
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
66
return SFE_UNIMPLEMENTED ;
68
if ((error = wve_read_header (psf)))
71
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WVE)
72
return SFE_BAD_OPEN_FORMAT ;
74
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
79
/*------------------------------------------------------------------------------
83
wve_read_header (SF_PRIVATE *psf)
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 ;
91
psf_binheader_readf (psf, "m", &marker) ;
92
if (marker != SOUN_MARKER)
93
return SFE_WVE_NOT_WVE ;
95
psf_binheader_readf (psf, "m", &marker) ;
96
if (marker != DFIL_MARKER)
97
return SFE_WVE_NOT_WVE ;
99
psf_log_printf (psf, "Read only : Psion Palmtop Alaw (.wve)\n"
100
" Sample Rate : 8000\n"
102
" Encoding : A-law\n") ;
104
psf->dataoffset = 0x20 ;
105
psf->datalength = psf->filelength - psf->dataoffset ;
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 ;
112
return alaw_init (psf) ;
113
} /* wve_read_header */
115
/*------------------------------------------------------------------------------
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.
124
** arch-tag: ba368cb5-523f-45e4-98c1-5b99a102f73f