-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathss_wavefile.h
95 lines (81 loc) · 2.92 KB
/
ss_wavefile.h
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
/*
* ss_wavefile.h - definitions for WaveFile, routines and data structures
* for reading and working with entire datasets of waveform data.
*
* Copyright 1999, Stephen G. Tell.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef WAVEFILE_H
#define WAVEFILE_H
#include "ss_spicestream.h"
typedef struct _WaveFile WaveFile;
typedef struct _WaveVar WaveVar;
typedef struct _WDataSet WDataSet;
/* Wave Data Set -
* an array of double-precision floating-point values, used to store a
* column of values. Organized as a block structure because we don't know
* how many entries there will be without reading the file, and we don't
* want to read the whole thing twice.
*
* Depending on what the memory allocator does, this might even
* end up being relatively cache-friendly. TODO: think more about this.
*/
#define DS_DBLKSIZE 8192
#define DS_INBLKS 1024
#define ds_blockno(n) ((n) / DS_DBLKSIZE)
#define ds_offset(n) ((n) % DS_DBLKSIZE)
struct _WDataSet {
double min;
double max;
/* remaining stuff is an array storage structure
* that could be abstracted out and/or replaced with somthing else */
/* pointer to array of pointers to blocks of doubles */
double **bptr;
int bpsize; /* size of array of pointers */
int bpused; /* number of blocks actually allocated */
int nreallocs;
};
/* Wave Variable - used for independent or dependent variable.
*/
struct _WaveVar {
SpiceVar *sv;
WaveFile *wfile; /* backpointer to file */
WDataSet *wds; /* data for one or more columns */
void *udata;
};
#define wv_name sv->name
#define wv_type sv->type
#define wv_ncols sv->ncols
#define wv_nvalues wfile->nvalues
#define wv_iv wfile->iv
struct _WaveFile {
SpiceStream *ss;
int nvalues; /* number of rows */
WaveVar *iv; /* pointer to single independent variable */
WaveVar *dv; /* pointer to array of dependent var info */
};
#define wf_filename ss->filename
#define wf_ndv ss->ndv
#define wf_ncols ss->ncols
/* defined in wavefile.c */
extern WaveFile *wf_read(char *name, char *format);
extern double wv_interp_value(WaveVar *dv, double ival);
extern int wf_find_point(WaveVar *iv, double ival);
extern double wds_get_point(WDataSet *ds, int n);
extern void wf_free(WaveFile *df);
extern WaveVar *wf_find_variable(WaveFile *wf, char *varname);
#endif /* WAVEFILE_H */