Skip to content

Commit

Permalink
Controllable volume boost
Browse files Browse the repository at this point in the history
  • Loading branch information
zeldin committed Jan 27, 2020
1 parent 23d693b commit 7feca94
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
9 changes: 8 additions & 1 deletion docs/m64conv.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ NAME
SYNOPSIS
========

`mc64conv` [`-f` _fps_] [`-r` _rate_] [`-m`] [`-n`] [`-d` _size_] [`-p`] [`-j` _number_] _videofile_ [_audiofile_] `>` _destination_
`mc64conv` [`-f` _fps_] [`-r` _rate_] [`-v` _volume_] [`-m`] [`-n`] [`-d` _size_] [`-p`] [`-j` _number_] _videofile_ [_audiofile_] `>` _destination_


DESCRIPTION
Expand Down Expand Up @@ -41,6 +41,13 @@ Options
all audio data fitting within the header block (file size is unaffected
by audio). The default target audio sample rate is 16000 Hz.

`-v` _volume_

Volume gain

If specified, the input volume will be multiplied by this number.
Output values are clipped to the maximum value.

`-m`

Enable multicolor mode
Expand Down
15 changes: 12 additions & 3 deletions tools/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,14 @@ static void convert(FILE *vframes, FILE *aframes, FILE *player, int mc,

static void usage(const char *pname)
{
fprintf(stderr, "Usage: %s [-f fps] [-r rate] [-m] [-n] [-d size] [-p]"
fprintf(stderr, "Usage: %s [-f fps] [-r rate] [-v volume] [-m] [-n] [-d size] [-p]"
#if USE_THREADS
" [-j number]"
#endif
"\n"
" -f fps Set video fps\n"
" -r rate Set audio sample rate\n"
" -v volume Multiply audio volume\n"
" -m Enable multicolor\n"
" -n Target NTSC (60 Hz) C64:s\n"
" -d size Dither with size pixel large dots\n"
Expand Down Expand Up @@ -452,6 +453,7 @@ int main(int argc, char *argv[])
int opt, mc = 0, ntsc = 0, dither = 0, preview = 0;
double fps = 50;
double srate = 16000;
double volume = 1.0;
char *endp, *cmdline;
#if USE_THREADS
int parallel = 1;
Expand All @@ -462,7 +464,7 @@ int main(int argc, char *argv[])
FILE *player = NULL;

while ((opt = getopt(argc, argv,
"f:r:mnd:p"
"f:r:v:mnd:p"
#if USE_THREADS
"j:"
#endif
Expand All @@ -482,6 +484,13 @@ int main(int argc, char *argv[])
return 1;
}
break;
case 'v':
volume = strtod(optarg, &endp);
if (!*optarg || *endp) {
fprintf(stderr, "Invalid number: %s\n", optarg);
return 1;
}
break;
case 'm':
mc = 1;
break;
Expand Down Expand Up @@ -541,7 +550,7 @@ int main(int argc, char *argv[])
cmdline_append("ffmpeg -nostats -hide_banner");
cmdline_append("-i");
cmdline_append_quoted(argv[optind+1 >= argc? optind : optind+1]);
cmdline_append("-f u8 -af volume=10dB,aformat=sample_fmts=u8:sample_rates=%.8g:channel_layouts=mono -", srate);
cmdline_append("-f u8 -af volume=%.8g,aformat=sample_fmts=u8:sample_rates=%.8g:channel_layouts=mono -", volume, srate);
cmdline = cmdline_finish();

aframes = popen(cmdline, "r");
Expand Down

0 comments on commit 7feca94

Please sign in to comment.