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