• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得windowscocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

oga's tools


Commit MetaInfo

修订版90cf1107f65fe1edce7dd6cdc7f40614d1815247 (tree)
时间2021-05-08 18:34:21
作者hyperoga <hyperoga@gmai...>
Commiterhyperoga

Log Message

更改概述

差异

--- a/wavcut.c
+++ b/wavcut.c
@@ -13,6 +13,8 @@
1313 * 07/12/02 V0.27 support -m (merge wavs)
1414 * 11/01/29 V0.28 fix display bug
1515 * 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
1618 *
1719 *
1820 * お勧め: wavcut -s -lv 20 -ln 15
@@ -48,7 +50,7 @@
4850 #define strncasecmp strnicmp
4951 #endif /* _WIN32 */
5052
51-#define VER "0.28"
53+#define VER "0.31"
5254 #define dprintf if (vf) printf
5355 #define dprintf2 if (vf >= 2) printf
5456 #define sgn(x) (x==0)?0:((x>0)?1:-1)
@@ -66,6 +68,7 @@ int nf = 0; /* -no normalize */
6668 int volf = 0; /* -vol volume V0.25-A */
6769 int rvf = 0; /* -rv reduce voice V0.24-A */
6870 int mf = 0; /* -m merge wavfiles V0.27-A */
71+int csf = 0; /* -cs cut silent part V0.30-A */
6972 int peak_level = 0; /* peak level for -no */
7073 int max_level = 0; /* max level for -no */
7174 long pre_datlen = 0; /* heders total length to wav data */
@@ -272,6 +275,7 @@ int ReadWavData(FILE *fp)
272275 /*
273276 * Write wav headers
274277 *
278+ * note: not write fact,LIST chunk
275279 */
276280 int WriteWavHeaders(FILE *wfp,
277281 struct riff_hdr *rhdr,
@@ -287,8 +291,8 @@ int WriteWavHeaders(FILE *wfp,
287291 fwrite(rhdr, sizeof(struct riff_hdr), 1, wfp);
288292
289293 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...) */
292296 fwrite(&cnkhdr[i], sizeof(struct chunk_hdr), 1, wfp); /* chunk header */
293297 if (!strncmp(cnkhdr[i].id, "fmt ", 4)) {
294298 fwrite(cnkfmt, cnkhdr[i].len, 1, wfp); /* fmt body */
@@ -444,7 +448,7 @@ int WavAnalyze(FILE *fp)
444448 }
445449 }
446450
447- if (sf || (ntment && outf)) {
451+ if (sf || csf || (ntment && outf)) { /* V0.30-A */
448452 /* ### Open Output File */
449453 sprintf(fname, "%s_%03d.wav", in_fname, file_cnt++);
450454 printf("## Writing %s ...\n", fname);
@@ -470,8 +474,12 @@ int WavAnalyze(FILE *fp)
470474 buf16 = (short *)buf; /* V0.21-A */
471475
472476 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+ }
475483 }
476484
477485 if (df) {
@@ -554,7 +562,9 @@ int WavAnalyze(FILE *fp)
554562 *ckfmt->dwAvgBytesPerSec*60)
555563 /ckfmt->dwAvgBytesPerSec));
556564
557- data_size = 0; /* reset data chunk size */
565+ if (csf == 0) { /* V0.30-A */
566+ data_size = 0; /* reset data chunk size */
567+ }
558568 if (sf) {
559569 sprintf(fname, "%s_%03d.wav", in_fname, file_cnt++);
560570 printf("## Writing %s ...\n", fname);
@@ -1365,13 +1375,14 @@ void usage()
13651375 {
13661376 printf("wavcut Ver %s\n", VER);
13671377 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");
13701380 printf(" | {-no | -vol <%%>}\n");
13711381 printf(" | -rv }\n");
13721382 printf(" [<wav_file>]\n");
13731383 printf(" -d : display data\n");
13741384 printf(" -s : split wav data\n");
1385+ printf(" -cs : cut silent part\n");
13751386 printf(" -lv : blank level. default:%d (x0.1%%)\n", th_val);
13761387 printf(" -ln : time to recognize blank. default:%d (x0.1sec)\n", bl_sec);
13771388 printf(" -ex : extract wav part\n");
@@ -1379,7 +1390,7 @@ void usage()
13791390 printf(" -vol: set volume\n");
13801391 printf(" -rv : reduce voice part\n");
13811392 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 */
13831394 exit(1);
13841395 }
13851396
@@ -1409,12 +1420,23 @@ int main(int a, char *b[])
14091420 continue;
14101421 }
14111422 if (!strncmp(b[i],"-s",2)) {
1412- if (ntment) {
1423+ if (ntment || csf) { /* V0.30-C */
14131424 usage();
14141425 }
14151426 sf = 1; /* Split Wav Data */
14161427 continue;
14171428 }
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+
14181440 if (!strcmp(b[i],"-m")) {
14191441 mf = 1; /* Merge Wav Files */
14201442 continue;
@@ -1441,7 +1463,7 @@ int main(int a, char *b[])
14411463 /* V0.25-A end */
14421464
14431465 if (i+1 < a && !strncmp(b[i],"-ex",3)) {
1444- if (sf) {
1466+ if (sf || csf) { /* V0.30-C */
14451467 usage();
14461468 }
14471469 ntment = GetTimes(b[++i], &start_dsec, &end_dsec); /* Extract wav */
@@ -1463,7 +1485,7 @@ int main(int a, char *b[])
14631485 }
14641486
14651487 /* V0.27-A start */
1466- if (mf && (volf || nf || sf || ntment || rvf)) {
1488+ if (mf && (volf || nf || sf || csf || ntment || rvf)) { /* V0.30-C */
14671489 usage();
14681490 }
14691491