oga's tools
修訂 | bc86193640f178cfb95b2749b60c51e97deb7b2a (tree) |
---|---|
時間 | 2021-05-03 09:11:08 |
作者 | oga <hyperoga@gmai...> |
Commiter | oga |
2021/05/03 V0.30 support -cs cut silent part
@@ -13,6 +13,7 @@ | ||
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 | |
16 | 17 | * |
17 | 18 | * |
18 | 19 | * お勧め: wavcut -s -lv 20 -ln 15 |
@@ -48,7 +49,7 @@ | ||
48 | 49 | #define strncasecmp strnicmp |
49 | 50 | #endif /* _WIN32 */ |
50 | 51 | |
51 | -#define VER "0.28" | |
52 | +#define VER "0.30" | |
52 | 53 | #define dprintf if (vf) printf |
53 | 54 | #define dprintf2 if (vf >= 2) printf |
54 | 55 | #define sgn(x) (x==0)?0:((x>0)?1:-1) |
@@ -66,6 +67,7 @@ int nf = 0; /* -no normalize */ | ||
66 | 67 | int volf = 0; /* -vol volume V0.25-A */ |
67 | 68 | int rvf = 0; /* -rv reduce voice V0.24-A */ |
68 | 69 | int mf = 0; /* -m merge wavfiles V0.27-A */ |
70 | +int csf = 0; /* -cs cut silent part V0.30-A */ | |
69 | 71 | int peak_level = 0; /* peak level for -no */ |
70 | 72 | int max_level = 0; /* max level for -no */ |
71 | 73 | long pre_datlen = 0; /* heders total length to wav data */ |
@@ -444,7 +446,7 @@ int WavAnalyze(FILE *fp) | ||
444 | 446 | } |
445 | 447 | } |
446 | 448 | |
447 | - if (sf || (ntment && outf)) { | |
449 | + if (sf || csf || (ntment && outf)) { /* V0.30-A */ | |
448 | 450 | /* ### Open Output File */ |
449 | 451 | sprintf(fname, "%s_%03d.wav", in_fname, file_cnt++); |
450 | 452 | printf("## Writing %s ...\n", fname); |
@@ -470,8 +472,12 @@ int WavAnalyze(FILE *fp) | ||
470 | 472 | buf16 = (short *)buf; /* V0.21-A */ |
471 | 473 | |
472 | 474 | if (wfp) { |
473 | - fwrite(buf, 1, gUnit, wfp); | |
474 | - data_size += len; /* data chunk size for write */ | |
475 | + if (csf && contf) { /* V0.30-A */ | |
476 | + /* -cs指定でblank中は書き込みスキップ */ | |
477 | + } else { | |
478 | + fwrite(buf, 1, gUnit, wfp); | |
479 | + data_size += len; /* data chunk size for write */ | |
480 | + } | |
475 | 481 | } |
476 | 482 | |
477 | 483 | if (df) { |
@@ -554,7 +560,9 @@ int WavAnalyze(FILE *fp) | ||
554 | 560 | *ckfmt->dwAvgBytesPerSec*60) |
555 | 561 | /ckfmt->dwAvgBytesPerSec)); |
556 | 562 | |
557 | - data_size = 0; /* reset data chunk size */ | |
563 | + if (csf == 0) { /* V0.30-A */ | |
564 | + data_size = 0; /* reset data chunk size */ | |
565 | + } | |
558 | 566 | if (sf) { |
559 | 567 | sprintf(fname, "%s_%03d.wav", in_fname, file_cnt++); |
560 | 568 | printf("## Writing %s ...\n", fname); |
@@ -1365,13 +1373,14 @@ void usage() | ||
1365 | 1373 | { |
1366 | 1374 | printf("wavcut Ver %s\n", VER); |
1367 | 1375 | printf("usage: wavcut [-d]\n"); |
1368 | - printf(" { [-s] [-lv <cut_level(%d)>] [-ln <blank_len>(%d)>]\n", th_val, bl_sec); | |
1376 | + printf(" { [{-s|-cs}] [-lv <cut_level(%d)>] [-ln <blank_len>(%d)>]\n", th_val, bl_sec); | |
1369 | 1377 | printf(" | -ex mm:ss-mm:ss[,mm:ss-ss,...]\n"); |
1370 | 1378 | printf(" | {-no | -vol <%%>}\n"); |
1371 | 1379 | printf(" | -rv }\n"); |
1372 | 1380 | printf(" [<wav_file>]\n"); |
1373 | 1381 | printf(" -d : display data\n"); |
1374 | 1382 | printf(" -s : split wav data\n"); |
1383 | + printf(" -cs : cut silent part\n"); | |
1375 | 1384 | printf(" -lv : blank level. default:%d (x0.1%%)\n", th_val); |
1376 | 1385 | printf(" -ln : time to recognize blank. default:%d (x0.1sec)\n", bl_sec); |
1377 | 1386 | printf(" -ex : extract wav part\n"); |
@@ -1379,7 +1388,7 @@ void usage() | ||
1379 | 1388 | printf(" -vol: set volume\n"); |
1380 | 1389 | printf(" -rv : reduce voice part\n"); |
1381 | 1390 | printf("usage: wavcut -m <wav_file> <wav_file> ...\n"); /* V0.27-A */ |
1382 | - printf(" -m : merge wav files\n"); /* V0.27-A */ | |
1391 | + printf(" -m : merge wav files (not available)\n"); /* V0.27-A */ | |
1383 | 1392 | exit(1); |
1384 | 1393 | } |
1385 | 1394 |
@@ -1409,12 +1418,23 @@ int main(int a, char *b[]) | ||
1409 | 1418 | continue; |
1410 | 1419 | } |
1411 | 1420 | if (!strncmp(b[i],"-s",2)) { |
1412 | - if (ntment) { | |
1421 | + if (ntment || csf) { /* V0.30-C */ | |
1413 | 1422 | usage(); |
1414 | 1423 | } |
1415 | 1424 | sf = 1; /* Split Wav Data */ |
1416 | 1425 | continue; |
1417 | 1426 | } |
1427 | + | |
1428 | + /* V0.30-A start */ | |
1429 | + if (!strncmp(b[i],"-cs",2)) { | |
1430 | + if (ntment || sf) { | |
1431 | + usage(); | |
1432 | + } | |
1433 | + csf = 1; /* Cut Silent Part */ | |
1434 | + continue; | |
1435 | + } | |
1436 | + /* V0.30-A end */ | |
1437 | + | |
1418 | 1438 | if (!strcmp(b[i],"-m")) { |
1419 | 1439 | mf = 1; /* Merge Wav Files */ |
1420 | 1440 | continue; |
@@ -1441,7 +1461,7 @@ int main(int a, char *b[]) | ||
1441 | 1461 | /* V0.25-A end */ |
1442 | 1462 | |
1443 | 1463 | if (i+1 < a && !strncmp(b[i],"-ex",3)) { |
1444 | - if (sf) { | |
1464 | + if (sf || csf) { /* V0.30-C */ | |
1445 | 1465 | usage(); |
1446 | 1466 | } |
1447 | 1467 | ntment = GetTimes(b[++i], &start_dsec, &end_dsec); /* Extract wav */ |
@@ -1463,7 +1483,7 @@ int main(int a, char *b[]) | ||
1463 | 1483 | } |
1464 | 1484 | |
1465 | 1485 | /* V0.27-A start */ |
1466 | - if (mf && (volf || nf || sf || ntment || rvf)) { | |
1486 | + if (mf && (volf || nf || sf || csf || ntment || rvf)) { /* V0.30-C */ | |
1467 | 1487 | usage(); |
1468 | 1488 | } |
1469 | 1489 |