annotate dmwav.h @ 300:4972ca91d062

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 11 Oct 2012 17:55:15 +0300
parents 9622c139cb9f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
205
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * DMLib
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * -- Wav file writing
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * Programmed and designed by Matti 'ccr' Hamalainen
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 * (C) Copyright 2012 Tecnic Software productions (TNSP)
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 */
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 #ifndef DMWAV_H
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #define DMWAV_H
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 #include "dmlib.h"
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #include <stdio.h>
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #ifdef __cplusplus
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 extern "C" {
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 #endif
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 #define DM_WAVE_FORMAT_PCM (1)
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 #define DM_WAVE_RIFF_ID "RIFF"
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 #define DM_WAVE_WAVE_ID "WAVE"
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 #define DM_WAVE_FMT_ID "fmt "
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 #define DM_WAVE_DATA_ID "data"
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 typedef struct
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 {
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 Uint8 chunkID[4];
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 Uint32 chunkSize;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 } DMWaveChunk;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 typedef struct
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 {
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 Uint8 riffID[4];
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 Uint32 fileSize;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 Uint8 riffType[4];
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 DMWaveChunk chFormat;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 Uint16 wFormatTag;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 Uint16 nChannels;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 Uint32 nSamplesPerSec;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 Uint32 nAvgBytesPerSec;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 Uint16 nBlockAlign;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 Uint16 wBitsPerSample;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 DMWaveChunk chData;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 // Data follows here
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 } DMWaveFile;
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 BOOL dmWriteWAVChunk(FILE * f, DMWaveChunk *ch);
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 void dmMakeWAVChunk(DMWaveChunk *ch, const char *chunkID, const Uint32 chunkSize);
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 void dmWriteWAVHeader(FILE *outFile, int sampBits, int sampFreq, int sampChn, size_t sampLen);
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 #ifdef __cplusplus
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 }
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 #endif
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
9622c139cb9f Separate the WAV header / chunk writing functions from mod2wav into dmwav.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 #endif // DMWAV_H