Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

Commit a31e9f3

Browse files
authored
Merge pull request #50 from pedrolcl/verbosity
Selectable verbosity level
2 parents e54fecb + 8cce611 commit a31e9f3

File tree

3 files changed

+44
-25
lines changed

3 files changed

+44
-25
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ You can use the program to listen MIDI files or to create audio files (like MP3
5757

5858
~~~
5959
$ ./sonivoxrender -h
60-
Usage: ./sonivoxrender [-h|--help] [-v|--version] [-d|--dls file.dls] [-r|--reverb 0..4] [-w|--wet 0..32767] [-n|--dry 0..32767] [-c|--chorus 0..4] [-l|--level 0..32767] [-g|--gain 0..100] file.mid ...
60+
Usage: ./sonivoxrender [-h|--help] [-v|--version] [-d|--dls file.dls] [-r|--reverb 0..4] [-w|--wet 0..32767] [-n|--dry 0..32767] [-c|--chorus 0..4] [-l|--level 0..32767] [-g|--gain 0..100] [-V|--Verbosity 0..5] file.mid ...
6161
Render standard MIDI files into raw PCM audio.
6262
Options:
6363
-h, --help this help message.
@@ -69,6 +69,7 @@ Options:
6969
-c, --chorus n chorus preset: 0=no, 1..4=presets.
7070
-l, --level n chorus level: 0..32767.
7171
-g, --gain n master gain: 0..100.
72+
-V, --Verbosity n Verbosity: 0=no, 1=fatals, 2=errors, 3=warnings, 4=infos, 5=details.
7273
~~~
7374

7475
The following examples assume the default option USE_44KHZ=ON:

example/sonivoxrender.1.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# SYNOPSIS
99

10-
| **sonivoxrender** [**-h|-\-help**] [**-v|-\-version**] [**-d|-\-dls** _file.dls_] [**-r|-\-reverb** _0..4_] [**-w|-\-wet** _0..32767_] [**-n|-\-dry** _0..32767_] [**-c|-\-chorus** _0..4_] [**-l|-\-level** _0..32767_] [**-g|-\-gain** _0..100_] _midi_file_
10+
| **sonivoxrender** [**-h|-\-help**] [**-v|-\-version**] [**-d|-\-dls** _file.dls_] [**-r|-\-reverb** _0..4_] [**-w|-\-wet** _0..32767_] [**-n|-\-dry** _0..32767_] [**-c|-\-chorus** _0..4_] [**-l|-\-level** _0..32767_] [**-g|-\-gain** _0..100_] [**-V|-\-Verbosity** _0..5_] _midi_file_
1111

1212
# DESCRIPTION
1313

@@ -52,6 +52,10 @@ It reads .MID (Standard MIDI Files) file format, and writes an audio stream to t
5252

5353
: Master gain between 0 and 100, default is 90 (10 dB below maximum).
5454

55+
-V, -\-Verbosity _verbosity_
56+
57+
: Verbosity level between 0 and 5, where 0=no, 1..5=severity levels.
58+
5559
## Arguments
5660

5761
_midi_file_

example/sonivoxrender.c

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ EAS_I32 reverb_dry = 0;
3636
EAS_I32 chorus_type = 0;
3737
EAS_I32 chorus_level = 32767;
3838
EAS_DATA_HANDLE mEASDataHandle = NULL;
39+
int verbosity =
40+
#ifdef NDEBUG
41+
_EAS_SEVERITY_WARNING;
42+
#else
43+
_EAS_SEVERITY_INFO;
44+
#endif
3945
const S_EAS_LIB_CONFIG *mEASConfig = NULL;
4046
char sLibrary_version[16];
4147

@@ -95,11 +101,7 @@ int initializeLibrary(void)
95101
#endif
96102

97103
EAS_SetDebugFile(stderr, 1);
98-
#ifdef NDEBUG
99-
EAS_SetDebugLevel(_EAS_SEVERITY_WARNING);
100-
#else
101-
EAS_SetDebugLevel(_EAS_SEVERITY_INFO);
102-
#endif
104+
EAS_SetDebugLevel(verbosity);
103105

104106
EAS_RESULT result = EAS_Init(&mEASDataHandle);
105107
if (result != EAS_SUCCESS) {
@@ -352,34 +354,39 @@ int main (int argc, char **argv)
352354
{"chorus", required_argument, 0, 'c'},
353355
{"level", required_argument, 0, 'l'},
354356
{"gain", required_argument, 0, 'g'},
357+
{"Verbosity", required_argument, 0, 'V'},
355358
{0, 0, 0, 0}};
356359

357360
while (1) {
358-
c = getopt_long(argc, argv, "hvd:r:w:n:c:l:g:", long_options, &option_index);
361+
c = getopt_long(argc, argv, "hvd:r:w:n:c:l:g:V:", long_options, &option_index);
359362

360363
if (c == -1) {
361364
break;
362365
}
363366

364367
switch (c) {
365368
case 'h':
366-
fprintf(stderr,
367-
"Usage: %s [-h|--help] [-v|--version] [-d|--dls file.dls] [-r|--reverb 0..4] "
368-
"[-w|--wet 0..32767] [-n|--dry 0..32767] "
369-
"[-c|--chorus 0..4] [-l|--level 0..32767] [-g|--gain 0..100] file.mid ...\n"
370-
"Render standard MIDI files into raw PCM audio.\n"
371-
"Options:\n"
372-
"\t-h, --help\t\tthis help message.\n"
373-
"\t-v, --version\t\tsonivox version.\n"
374-
"\t-d, --dls file.dls\tDLS soundfont.\n"
375-
"\t-r, --reverb n\t\treverb preset: 0=no, 1=large hall, 2=hall, 3=chamber, "
376-
"4=room.\n"
377-
"\t-w, --wet n\t\treverb wet: 0..32767.\n"
378-
"\t-n, --dry n\t\treverb dry: 0..32767.\n"
379-
"\t-c, --chorus n\t\tchorus preset: 0=no, 1..4=presets.\n"
380-
"\t-l, --level n\t\tchorus level: 0..32767.\n"
381-
"\t-g, --gain n\t\tmaster gain: 0..100.\n",
382-
argv[0]);
369+
fprintf(
370+
stderr,
371+
"Usage: %s [-h|--help] [-v|--version] [-d|--dls file.dls] [-r|--reverb 0..4] "
372+
"[-w|--wet 0..32767] [-n|--dry 0..32767] "
373+
"[-c|--chorus 0..4] [-l|--level 0..32767] [-g|--gain 0..100] [-V|--Verbosity "
374+
"0..5] file.mid ...\n"
375+
"Render standard MIDI files into raw PCM audio.\n"
376+
"Options:\n"
377+
"\t-h, --help\t\tthis help message.\n"
378+
"\t-v, --version\t\tsonivox version.\n"
379+
"\t-d, --dls file.dls\tDLS soundfont.\n"
380+
"\t-r, --reverb n\t\treverb preset: 0=no, 1=large hall, 2=hall, 3=chamber, "
381+
"4=room.\n"
382+
"\t-w, --wet n\t\treverb wet: 0..32767.\n"
383+
"\t-n, --dry n\t\treverb dry: 0..32767.\n"
384+
"\t-c, --chorus n\t\tchorus preset: 0=no, 1..4=presets.\n"
385+
"\t-l, --level n\t\tchorus level: 0..32767.\n"
386+
"\t-g, --gain n\t\tmaster gain: 0..100.\n"
387+
"\t-V, --Verbosity n\tVerbosity: 0=no, 1=fatals, 2=errors, 3=warnings, 4=infos, "
388+
"5=details\n",
389+
argv[0]);
383390
return EXIT_FAILURE;
384391
case 'v':
385392
fprintf(stderr, "version: %s\n", sLibrary_version);
@@ -429,6 +436,13 @@ int main (int argc, char **argv)
429436
return EXIT_FAILURE;
430437
}
431438
break;
439+
case 'V':
440+
verbosity = atoi(optarg);
441+
if ((verbosity < 0) || (verbosity > 5)) {
442+
fprintf(stderr, "invalid verbosity level: %d\n", verbosity);
443+
return EXIT_FAILURE;
444+
}
445+
break;
432446
case '?':
433447
fprintf(stderr, "unknown option %c\n", optopt);
434448
return EXIT_FAILURE;

0 commit comments

Comments
 (0)