oga's tools
修订版 | 90cf1107f65fe1edce7dd6cdc7f40614d1815247 (tree) |
---|---|
时间 | 2021-05-08 18:34:21 |
作者 | hyperoga <hyperoga@gmai...> |
Commiter | hyperoga |
Merge branch 'master' of http://pf.osdn.jp/gitroot/h/hy/hyperoga/ogatool
@@ -13,6 +13,8 @@ | ||
13 | 13 | * 07/12/02 V0.27 support -m (merge wavs) |
14 | 14 | * 11/01/29 V0.28 fix display bug |
15 | 15 | * 12/03/19 V0.29 fix -ex degrade (調査中 ex. -ex 00:05-21:50) |
16 | + * 21/05/02 V0.30 support -cs cut silent part | |
17 | + * 21/05/03 V0.31 fix LIST chunk bug | |
16 | 18 | * |
17 | 19 | * |
18 | 20 | * お勧め: wavcut -s -lv 20 -ln 15 |
@@ -48,7 +50,7 @@ | ||
48 | 50 | #define strncasecmp strnicmp |
49 | 51 | #endif /* _WIN32 */ |
50 | 52 | |
51 | -#define VER "0.28" | |
53 | +#define VER "0.31" | |
52 | 54 | #define dprintf if (vf) printf |
53 | 55 | #define dprintf2 if (vf >= 2) printf |
54 | 56 | #define sgn(x) (x==0)?0:((x>0)?1:-1) |
@@ -66,6 +68,7 @@ int nf = 0; /* -no normalize */ | ||
66 | 68 | int volf = 0; /* -vol volume V0.25-A */ |
67 | 69 | int rvf = 0; /* -rv reduce voice V0.24-A */ |
68 | 70 | int mf = 0; /* -m merge wavfiles V0.27-A */ |
71 | +int csf = 0; /* -cs cut silent part V0.30-A */ | |
69 | 72 | int peak_level = 0; /* peak level for -no */ |
70 | 73 | int max_level = 0; /* max level for -no */ |
71 | 74 | long pre_datlen = 0; /* heders total length to wav data */ |
@@ -272,6 +275,7 @@ int ReadWavData(FILE *fp) | ||
272 | 275 | /* |
273 | 276 | * Write wav headers |
274 | 277 | * |
278 | + * note: not write fact,LIST chunk | |
275 | 279 | */ |
276 | 280 | int WriteWavHeaders(FILE *wfp, |
277 | 281 | struct riff_hdr *rhdr, |
@@ -287,8 +291,8 @@ int WriteWavHeaders(FILE *wfp, | ||
287 | 291 | fwrite(rhdr, sizeof(struct riff_hdr), 1, wfp); |
288 | 292 | |
289 | 293 | for (i = 0; i<cnkcnt; i++) { |
290 | - if (strncmp(cnkhdr[i].id, "fact", 4)) { | |
291 | - /* excpt fact chunk (fmt, data...) */ | |
294 | + if (strncmp(cnkhdr[i].id, "fact", 4) && strncmp(cnkhdr[i].id, "LIST", 4)) { /* V0.31-C */ | |
295 | + /* write excpt fact,LIST chunk (fmt, data...) */ | |
292 | 296 | fwrite(&cnkhdr[i], sizeof(struct chunk_hdr), 1, wfp); /* chunk header */ |
293 | 297 | if (!strncmp(cnkhdr[i].id, "fmt ", 4)) { |
294 | 298 | fwrite(cnkfmt, cnkhdr[i].len, 1, wfp); /* fmt body */ |
@@ -444,7 +448,7 @@ int WavAnalyze(FILE *fp) | ||
444 | 448 | } |
445 | 449 | } |
446 | 450 | |
447 | - if (sf || (ntment && outf)) { | |
451 | + if (sf || csf || (ntment && outf)) { /* V0.30-A */ | |
448 | 452 | /* ### Open Output File */ |
449 | 453 | sprintf(fname, "%s_%03d.wav", in_fname, file_cnt++); |
450 | 454 | printf("## Writing %s ...\n", fname); |
@@ -470,8 +474,12 @@ int WavAnalyze(FILE *fp) | ||
470 | 474 | buf16 = (short *)buf; /* V0.21-A */ |
471 | 475 | |
472 | 476 | if (wfp) { |
473 | - fwrite(buf, 1, gUnit, wfp); | |
474 | - data_size += len; /* data chunk size for write */ | |
477 | + if (csf && contf) { /* V0.30-A */ | |
478 | + /* -cs指定でblank中は書き込みスキップ */ | |
479 | + } else { | |
480 | + fwrite(buf, 1, gUnit, wfp); | |
481 | + data_size += len; /* data chunk size for write */ | |
482 | + } | |
475 | 483 | } |
476 | 484 | |
477 | 485 | if (df) { |
@@ -554,7 +562,9 @@ int WavAnalyze(FILE *fp) | ||
554 | 562 | *ckfmt->dwAvgBytesPerSec*60) |
555 | 563 | /ckfmt->dwAvgBytesPerSec)); |
556 | 564 | |
557 | - data_size = 0; /* reset data chunk size */ | |
565 | + if (csf == 0) { /* V0.30-A */ | |
566 | + data_size = 0; /* reset data chunk size */ | |
567 | + } | |
558 | 568 | if (sf) { |
559 | 569 | sprintf(fname, "%s_%03d.wav", in_fname, file_cnt++); |
560 | 570 | printf("## Writing %s ...\n", fname); |
@@ -1365,13 +1375,14 @@ void usage() | ||
1365 | 1375 | { |
1366 | 1376 | printf("wavcut Ver %s\n", VER); |
1367 | 1377 | printf("usage: wavcut [-d]\n"); |
1368 | - printf(" { [-s] [-lv <cut_level(%d)>] [-ln <blank_len>(%d)>]\n", th_val, bl_sec); | |
1369 | - printf(" | -ex mm:ss-mm:ss[,mm:ss-ss,...]\n"); | |
1378 | + printf(" { [{-s|-cs}] [-lv <cut_level(%d)>] [-ln <blank_len>(%d)>]\n", th_val, bl_sec); | |
1379 | + printf(" | -ex mm:ss-mm:ss[,mm:ss-mm:ss,...]\n"); | |
1370 | 1380 | printf(" | {-no | -vol <%%>}\n"); |
1371 | 1381 | printf(" | -rv }\n"); |
1372 | 1382 | printf(" [<wav_file>]\n"); |
1373 | 1383 | printf(" -d : display data\n"); |
1374 | 1384 | printf(" -s : split wav data\n"); |
1385 | + printf(" -cs : cut silent part\n"); | |
1375 | 1386 | printf(" -lv : blank level. default:%d (x0.1%%)\n", th_val); |
1376 | 1387 | printf(" -ln : time to recognize blank. default:%d (x0.1sec)\n", bl_sec); |
1377 | 1388 | printf(" -ex : extract wav part\n"); |
@@ -1379,7 +1390,7 @@ void usage() | ||
1379 | 1390 | printf(" -vol: set volume\n"); |
1380 | 1391 | printf(" -rv : reduce voice part\n"); |
1381 | 1392 | printf("usage: wavcut -m <wav_file> <wav_file> ...\n"); /* V0.27-A */ |
1382 | - printf(" -m : merge wav files\n"); /* V0.27-A */ | |
1393 | + printf(" -m : merge wav files (not available)\n"); /* V0.27-A */ | |
1383 | 1394 | exit(1); |
1384 | 1395 | } |
1385 | 1396 |
@@ -1409,12 +1420,23 @@ int main(int a, char *b[]) | ||
1409 | 1420 | continue; |
1410 | 1421 | } |
1411 | 1422 | if (!strncmp(b[i],"-s",2)) { |
1412 | - if (ntment) { | |
1423 | + if (ntment || csf) { /* V0.30-C */ | |
1413 | 1424 | usage(); |
1414 | 1425 | } |
1415 | 1426 | sf = 1; /* Split Wav Data */ |
1416 | 1427 | continue; |
1417 | 1428 | } |
1429 | + | |
1430 | + /* V0.30-A start */ | |
1431 | + if (!strncmp(b[i],"-cs",2)) { | |
1432 | + if (ntment || sf) { | |
1433 | + usage(); | |
1434 | + } | |
1435 | + csf = 1; /* Cut Silent Part */ | |
1436 | + continue; | |
1437 | + } | |
1438 | + /* V0.30-A end */ | |
1439 | + | |
1418 | 1440 | if (!strcmp(b[i],"-m")) { |
1419 | 1441 | mf = 1; /* Merge Wav Files */ |
1420 | 1442 | continue; |
@@ -1441,7 +1463,7 @@ int main(int a, char *b[]) | ||
1441 | 1463 | /* V0.25-A end */ |
1442 | 1464 | |
1443 | 1465 | if (i+1 < a && !strncmp(b[i],"-ex",3)) { |
1444 | - if (sf) { | |
1466 | + if (sf || csf) { /* V0.30-C */ | |
1445 | 1467 | usage(); |
1446 | 1468 | } |
1447 | 1469 | ntment = GetTimes(b[++i], &start_dsec, &end_dsec); /* Extract wav */ |
@@ -1463,7 +1485,7 @@ int main(int a, char *b[]) | ||
1463 | 1485 | } |
1464 | 1486 | |
1465 | 1487 | /* V0.27-A start */ |
1466 | - if (mf && (volf || nf || sf || ntment || rvf)) { | |
1488 | + if (mf && (volf || nf || sf || csf || ntment || rvf)) { /* V0.30-C */ | |
1467 | 1489 | usage(); |
1468 | 1490 | } |
1469 | 1491 |