Mercurial > hg > dmlib
annotate tools/mod2wav.c @ 1432:a9516570cc26
Improve build, so that we can build the tools and tests with minimal
depencies (e.g. without libSDL linking when possible.) And this also on
Win32 MinGW.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 22 Nov 2017 01:33:21 +0200 |
parents | 5b8245e5f785 |
children | ad3ad5d9681b |
rev | line source |
---|---|
0 | 1 /* |
2 * mod2wav - Render XM/JSSMOD module to WAV waveform file | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
4 * (C) Copyright 2007 Tecnic Software productions (TNSP) | |
5 * | |
6 * Please read file 'COPYING' for information on license and distribution. | |
7 */ | |
1432
a9516570cc26
Improve build, so that we can build the tools and tests with minimal
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
8 #include "dmtool.h" |
0 | 9 #include <stdio.h> |
10 #include <stdlib.h> | |
11 #include <errno.h> | |
12 #include "jss.h" | |
13 #include "jssmod.h" | |
14 #include "jssmix.h" | |
15 #include "jssplr.h" | |
16 #include "dmlib.h" | |
17 #include "dmargs.h" | |
206
9b6c0ed66960
Use the routines factored into dmwav module.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
18 #include "dmwav.h" |
285
245b15cd1919
Don't link libSDL uselessly to utilities that do not actually use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
206
diff
changeset
|
19 #include "dmmutex.h" |
0 | 20 |
21 | |
300 | 22 char *optInFilename = NULL, *optOutFilename = NULL; |
0 | 23 int optOutFormat = JSS_AUDIO_S16, |
24 optOutChannels = 2, | |
25 optOutFreq = 44100, | |
26 optMuteOChannels = -1, | |
27 optStartOrder = -1; | |
28 BOOL optUsePlayTime = FALSE; | |
29 size_t optPlayTime; | |
30 | |
31 | |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
32 static const DMOptArg optList[] = |
37 | 33 { |
34 { 0, '?', "help", "Show this help", OPT_NONE }, | |
35 { 2, 'v', "verbose", "Be more verbose", OPT_NONE }, | |
36 { 3, '1', "16bit", "16-bit output", OPT_NONE }, | |
37 { 4, '8', "8bit", "8-bit output", OPT_NONE }, | |
38 { 5, 'm', "mono", "Mono output", OPT_NONE }, | |
39 { 6, 's', "stereo", "Stereo output", OPT_NONE }, | |
40 { 7, 'f', "freq", "Output frequency", OPT_ARGREQ }, | |
41 { 8, 'M', "mute", "Mute other channels than #", OPT_ARGREQ }, | |
42 { 9, 'o', "order", "Start from order #", OPT_ARGREQ }, | |
43 { 10, 't', "time", "Play for # seconds", OPT_ARGREQ }, | |
0 | 44 // {10, 'l', "loop", "Loop for # times", OPT_ARGREQ }, |
45 }; | |
46 | |
47 const int optListN = sizeof(optList) / sizeof(optList[0]); | |
48 | |
49 | |
50 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) | |
51 { | |
52 (void) optArg; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
53 |
37 | 54 switch (optN) |
55 { | |
56 case 0: | |
57 dmPrintBanner(stdout, dmProgName, | |
58 "[options] [sourcefile] [destfile]"); | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
59 |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
60 dmArgsPrintHelp(stdout, optList, optListN, 0); |
37 | 61 exit(0); |
62 break; | |
0 | 63 |
37 | 64 case 2: |
65 dmVerbosity++; | |
66 break; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
67 |
37 | 68 case 3: |
69 optOutFormat = JSS_AUDIO_S16; | |
70 break; | |
0 | 71 |
37 | 72 case 4: |
73 optOutFormat = JSS_AUDIO_U8; | |
74 break; | |
0 | 75 |
37 | 76 case 5: |
77 optOutChannels = JSS_AUDIO_MONO; | |
78 break; | |
0 | 79 |
37 | 80 case 6: |
38
8b04b0b51edc
Oops, fix a stupid bug in -s option .. it was setting the wrong variable. :|
Matti Hamalainen <ccr@tnsp.org>
parents:
37
diff
changeset
|
81 optOutChannels = JSS_AUDIO_STEREO; |
37 | 82 break; |
0 | 83 |
37 | 84 case 7: |
85 optOutFreq = atoi(optArg); | |
86 break; | |
0 | 87 |
37 | 88 case 8: |
89 optMuteOChannels = atoi(optArg); | |
90 break; | |
91 | |
92 case 9: | |
93 optStartOrder = atoi(optArg); | |
94 break; | |
0 | 95 |
37 | 96 case 10: |
97 optPlayTime = atoi(optArg); | |
98 optUsePlayTime = TRUE; | |
99 break; | |
0 | 100 |
37 | 101 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
102 dmErrorMsg("Unknown argument '%s'.\n", currArg); |
37 | 103 return FALSE; |
0 | 104 } |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
105 |
0 | 106 return TRUE; |
107 } | |
108 | |
109 | |
110 BOOL argHandleFile(char *currArg) | |
111 { | |
300 | 112 if (!optInFilename) |
113 optInFilename = currArg; | |
37 | 114 else |
300 | 115 if (!optOutFilename) |
116 optOutFilename = currArg; | |
37 | 117 else |
118 { | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
119 dmErrorMsg("Too many filename arguments (only source and dest needed) '%s'\n", currArg); |
0 | 120 return FALSE; |
121 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
122 |
0 | 123 return TRUE; |
124 } | |
125 | |
126 | |
127 int main(int argc, char *argv[]) | |
128 { | |
15
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
129 DMResource *inFile = NULL; |
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
130 FILE *outFile = NULL; |
68 | 131 JSSModule *mod = NULL; |
132 JSSMixer *dev = NULL; | |
133 JSSPlayer *plr = NULL; | |
0 | 134 int result = -1; |
135 size_t bufLen = 1024*4, dataTotal, dataWritten, sampSize; | |
136 Uint8 *mb = NULL; | |
137 | |
138 dmInitProg("mod2wav", "XM/JSSMOD to WAV renderer", "0.2", NULL, NULL); | |
139 dmVerbosity = 1; | |
140 | |
141 // Parse arguments | |
142 if (!dmArgsProcess(argc, argv, optList, optListN, | |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
143 argHandleOpt, argHandleFile, OPTH_BAILOUT)) |
0 | 144 exit(1); |
145 | |
146 // Check arguments | |
300 | 147 if (optInFilename == NULL || optOutFilename == NULL) |
37 | 148 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
149 dmErrorMsg("Input or output file not specified. Try --help.\n"); |
0 | 150 return 1; |
151 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
152 |
0 | 153 // Initialize miniJSS |
154 jssInit(); | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
155 |
0 | 156 // Open the source file |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
157 if ((result = dmf_create_stdio(optInFilename, "rb", &inFile)) != DMERR_OK) |
15
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
158 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
159 dmErrorMsg("Error opening input file '%s', %d: %s\n", |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
160 optInFilename, result, dmErrorStr(result)); |
15
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
161 return 1; |
0 | 162 } |
163 | |
164 // Read module file | |
1199
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
165 dmMsg(1, "Reading file: %s\n", optInFilename); |
0 | 166 #ifdef JSS_SUP_XM |
797
f066e9dccf29
Oops, fix some inverted booleans.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
167 result = jssLoadXM(inFile, &mod, TRUE); |
0 | 168 #endif |
169 #ifdef JSS_SUP_JSSMOD | |
1199
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
170 dmfreset(inFile); |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
171 if (result != DMERR_OK) |
15
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
172 { |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
730
diff
changeset
|
173 dmMsg(1, "* Trying JSSMOD ...\n"); |
797
f066e9dccf29
Oops, fix some inverted booleans.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
174 result = jssLoadJSSMOD(inFile, &mod, TRUE); |
1199
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
175 dmfreset(inFile); |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
176 if (result == DMERR_OK) |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
177 result = jssLoadJSSMOD(inFile, &mod, FALSE); |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
178 } |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
179 else |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
180 { |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
181 dmMsg(2, "* Trying XM...\n"); |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
182 result = jssLoadXM(inFile, &mod, FALSE); |
15
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
183 } |
0 | 184 #endif |
15
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
185 dmf_close(inFile); |
1199
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
186 |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
187 // Check for errors, we still might have some data tho |
15
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
188 if (result != DMERR_OK) |
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
189 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
190 dmErrorMsg("Error loading module file, %d: %s\n", |
15
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
191 result, dmErrorStr(result)); |
1199
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
192 } |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
193 |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
194 // Check if we have anything |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
195 if (mod == NULL) |
15
feec43a3497c
Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
196 return 3; |
0 | 197 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
198 // Try to convert it |
68 | 199 if ((result = jssConvertModuleForPlaying(mod)) != DMERR_OK) |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
200 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
201 dmErrorMsg("Could not convert module for playing, %d: %s\n", |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
202 result, dmErrorStr(result)); |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
203 return 3; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
204 } |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
39
diff
changeset
|
205 |
0 | 206 // Open mixer |
68 | 207 dev = jvmInit(optOutFormat, optOutChannels, optOutFreq, JMIX_AUTO); |
208 if (dev == NULL) | |
39 | 209 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
210 dmErrorMsg("jvmInit() returned NULL\n"); |
0 | 211 return 4; |
212 } | |
213 | |
68 | 214 sampSize = jvmGetSampleSize(dev); |
83
6b42aed2745b
Cleanups and correct the dmf_create_stdio() issue here as well.
Matti Hamalainen <ccr@tnsp.org>
parents:
68
diff
changeset
|
215 if ((mb = dmMalloc(bufLen * sampSize)) == NULL) |
39 | 216 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
217 dmErrorMsg("Could not allocate mixing buffer\n"); |
0 | 218 return 5; |
219 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
220 |
0 | 221 dmMsg(1, "Using fmt=%d, bits=%d, channels=%d, freq=%d [%d / sample]\n", |
68 | 222 optOutFormat, jvmGetSampleRes(dev), optOutChannels, optOutFreq, |
0 | 223 sampSize); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
224 |
0 | 225 // Initialize player |
68 | 226 if ((plr = jmpInit(dev)) == NULL) |
227 { | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
228 dmErrorMsg("jmpInit() returned NULL.\n"); |
0 | 229 return 6; |
230 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
231 |
0 | 232 // Set callback |
68 | 233 jvmSetCallback(dev, jmpExec, plr); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
234 |
0 | 235 // Initialize playing |
68 | 236 jmpSetModule(plr, mod); |
37 | 237 if (optStartOrder >= 0) |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
238 { |
0 | 239 dmMsg(1, "Starting from song order #%d\n", optStartOrder); |
240 } else | |
241 optStartOrder = 0; | |
37 | 242 |
68 | 243 jmpPlayOrder(plr, optStartOrder); |
185
1f8f4d7cb33b
Increase default global volume.
Matti Hamalainen <ccr@tnsp.org>
parents:
83
diff
changeset
|
244 jvmSetGlobalVol(dev, 150); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
245 |
68 | 246 if (optMuteOChannels > 0 && optMuteOChannels <= mod->nchannels) |
37 | 247 { |
0 | 248 int i; |
68 | 249 for (i = 0; i < mod->nchannels; i++) |
250 jvmMute(dev, i, TRUE); | |
251 jvmMute(dev, optMuteOChannels - 1, FALSE); | |
0 | 252 } |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
253 |
0 | 254 // Open output file |
300 | 255 if ((outFile = fopen(optOutFilename, "wb")) == NULL) |
37 | 256 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
257 dmErrorMsg("Error opening output file '%s'. (%s)\n", |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
258 optInFilename, strerror(errno)); |
0 | 259 return 7; |
260 } | |
261 | |
262 // Write initial header | |
206
9b6c0ed66960
Use the routines factored into dmwav module.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
263 dmWriteWAVHeader(outFile, jvmGetSampleRes(dev), optOutFreq, optOutChannels, 1024); |
0 | 264 |
265 // Render audio data and output to file | |
266 if (optUsePlayTime) | |
267 dmMsg(1, "Rendering module (%d seconds) ...\n", optPlayTime); | |
268 else | |
269 dmMsg(1, "Rendering module ...\n"); | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
270 |
0 | 271 optPlayTime *= optOutFreq; |
272 dataTotal = 0; | |
273 dataWritten = 1; | |
68 | 274 while (plr->isPlaying && dataWritten > 0) |
0 | 275 { |
276 size_t writeLen = bufLen; | |
277 if (optUsePlayTime && (writeLen + dataTotal) > optPlayTime) | |
278 writeLen = optPlayTime - dataTotal; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
279 |
0 | 280 if (writeLen > 0) |
281 { | |
68 | 282 jvmRenderAudio(dev, mb, writeLen); |
0 | 283 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) |
284 jssEncodeSample16((Uint16 *)mb, writeLen * optOutChannels, jsampSwapEndianess); | |
285 #endif | |
286 dataWritten = fwrite(mb, sampSize, writeLen, outFile); | |
287 if (dataWritten < writeLen) | |
288 { | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
289 dmErrorMsg("Error writing data!\n"); |
0 | 290 fclose(outFile); |
291 return 8; | |
292 } | |
293 dataTotal += dataWritten; | |
294 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
295 |
0 | 296 if (optUsePlayTime && dataTotal >= optPlayTime) |
297 break; | |
298 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
299 |
0 | 300 // Write the correct header |
301 if (fseek(outFile, 0L, SEEK_SET) != 0) | |
302 { | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
303 dmErrorMsg("Error rewinding to header position!\n"); |
0 | 304 return 9; |
305 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
306 |
206
9b6c0ed66960
Use the routines factored into dmwav module.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
307 dmWriteWAVHeader(outFile, jvmGetSampleRes(dev), optOutFreq, optOutChannels, dataTotal); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1199
diff
changeset
|
308 |
0 | 309 // Done! |
310 fclose(outFile); | |
68 | 311 |
312 jmpClose(plr); | |
313 jvmClose(dev); | |
314 jssFreeModule(mod); | |
315 jssClose(); | |
316 | |
0 | 317 dmMsg(1, "OK.\n"); |
318 return 0; | |
319 } |