Waveform Data Block (WDB) structure
Libcwav provides a data structure for describing the various
waveform properties called a Waveform Data Block and defined as:
typedef struct {
short format;
short file_type;
short smplbits;
unsigned short sample_rate;
short ref_level;
short n_segments;
short n_per_rec;
float scale;
float bias;
short error;
} WDB;
When existing files are opened, the WDB structure is
set by the open waveform function opnwav(). when a new file is to be
created. The structure should be initialized by the application program
and passed to opnwav(). The elements of a WDB are:
- WDB.format
- Binary format of data in file. Possible values:
- O8_format
- 8 bit Offset Binary
- OB_format
- 12 bit Offset Binary
- PC_format
- 16 bit Twos Complement
- TC_format
- 12 bit Twos Complement
- GT_format
- Generic Twos Complement (bits per sample in WDB.smplbits)
- GO_format
- Generic Offset Binary (bits per sample in WDB.smplbits)
- WDB.file_type
- Storage format of the waveform in file. Possible values:
- RIFF
- A waveform file format using the standard IBM/Microsoft Resource
Interchange File Format (RIFF).
- ASEL
- A waveform file using the ASEL internal storage format
- WDB.smplbits
- Number of bits per sample. (1-16) Only needed for formats
GT_format and GO_format.
- WDB.sample_rate
- The sample rate in Hz.
- WDB.n_segments
- Number of segments defined in file, (only applicable for existing
waveforms.) See wavgst for a description of segment tables.
- WDB.n_per_rec
- Total channels of data (i.e. samples) per record.
- WDB.scale
- Together with WDB.bias allows linear
scaling from integer sample values to real-world
coordinates. Sample values are intended to be transformed as:
real_value = WDB.scale * sample_value + WDB.bias;
- WDB.bias
- The intercept for linear transformation of sample values to
real-world values.
- WDB.error
- One of the following constants will be returned by
opnwav if an error occurs in opening a file:
- NO_FILE
- File could not be found or created
- INVALID_FORMAT
- Format not one of those defined
- NO_SEGMENT
- Segment not found in file
- INVALID_CHANNEL
- Channel number > total channels per record
- INSUF_MEMORY
- Memory allocation failure
- INSUF_BUFFER
- Predefined buffer too small for record.
- INVALID_FILE
- File neither RIFF nor ASEL format.
SEE ALSO
opnwav(),
Libcwav library
AUTHOR
Shirley Peters, H.T.Bunnell