IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Wavegain an album from STDIN?
xorsyst
post Jun 29 2012, 15:35
Post #1





Group: Members
Posts: 14
Joined: 1-October 09
Member No.: 73611



I've got a bit of a weird desire this time smile.gif

What I want to be able to do is wavegain an album's worth of tracks, but all without creating temporary files. Let me explain...

I have some source files, possibly in a variety of formats. I convert them all to wav, and run wavegain in album mode to calculate track and album gain values. I then delete the temporary files.

I'd like to be able to avoid the temporary files. Either by using stdin, and somehow including a "new track starts now" flag between the tracks, or perhaps by having wavegain be able to take a list of commands to run to receive the track data on stdin.

Any thoughts if this is possible?

X
Go to the top of the page
+Quote Post
tuffy
post Jun 29 2012, 17:53
Post #2





Group: Members
Posts: 111
Joined: 20-August 07
Member No.: 46367



Calculating ReplayGain requires all of the wav file's audio. Applying ReplayGain requires the calculated gain values and all of the wav file's audio. So since you'll need two passes of that audio data, that means either a temporary file on disk, storing it all in memory, or piping the data twice.
Go to the top of the page
+Quote Post
xorsyst
post Oct 3 2012, 17:31
Post #3





Group: Members
Posts: 14
Joined: 1-October 09
Member No.: 73611



QUOTE (tuffy @ Jun 29 2012, 16:53) *
Calculating ReplayGain requires all of the wav file's audio. Applying ReplayGain requires the calculated gain values and all of the wav file's audio. So since you'll need two passes of that audio data, that means either a temporary file on disk, storing it all in memory, or piping the data twice.


I'm only interested in calculating gain, not applying it, so I only need a single pass of audio. Any ideas anyone?
Go to the top of the page
+Quote Post
robert
post Oct 3 2012, 18:09
Post #4


LAME developer


Group: Developer
Posts: 783
Joined: 22-September 01
Member No.: 5



QUOTE (xorsyst @ Oct 3 2012, 18:31) *
I'm only interested in calculating gain, not applying it, so I only need a single pass of audio. Any ideas anyone?

In my "mk_mp3 shell script" I'm using wavegain like this:
CODE
ALBUM_GAIN=`wavegain -x -a "${_cd}"/ 2>/dev/null`

Go to the top of the page
+Quote Post
xorsyst
post Oct 5 2012, 12:51
Post #5





Group: Members
Posts: 14
Joined: 1-October 09
Member No.: 73611



QUOTE (robert @ Oct 3 2012, 17:09) *
QUOTE (xorsyst @ Oct 3 2012, 18:31) *
I'm only interested in calculating gain, not applying it, so I only need a single pass of audio. Any ideas anyone?

In my "mk_mp3 shell script" I'm using wavegain like this:
CODE
ALBUM_GAIN=`wavegain -x -a "${_cd}"/ 2>/dev/null`



That looks good, but isn't that working on .wav files? My issue is that I will have the audio coming from the result of several different conversion tools potentially.
Go to the top of the page
+Quote Post
robert
post Oct 5 2012, 13:09
Post #6


LAME developer


Group: Developer
Posts: 783
Joined: 22-September 01
Member No.: 5



Can't test it right now, but eventually you can let wavegain read from stdin, '-' as input file.
What you need is, command line decoders, that decode your files to stdout, ie "flac -d -c test.flac | wavegain -c -"
Go to the top of the page
+Quote Post
xorsyst
post Oct 5 2012, 14:09
Post #7





Group: Members
Posts: 14
Joined: 1-October 09
Member No.: 73611



QUOTE (robert @ Oct 5 2012, 12:09) *
Can't test it right now, but eventually you can let wavegain read from stdin, '-' as input file.
What you need is, command line decoders, that decode your files to stdout, ie "flac -d -c test.flac | wavegain -c -"


Yes, that works great for a single track at a time. My problem is I want to album gain several tracks from stdin, and I don't seem to be able to work out a way to do that.

Thanks,
x
Go to the top of the page
+Quote Post
xorsyst
post Oct 31 2012, 10:14
Post #8





Group: Members
Posts: 14
Joined: 1-October 09
Member No.: 73611



QUOTE (xorsyst @ Jun 29 2012, 14:35) *
I've got a bit of a weird desire this time :)

What I want to be able to do is wavegain an album's worth of tracks, but all without creating temporary files. Let me explain...

I have some source files, possibly in a variety of formats. I convert them all to wav, and run wavegain in album mode to calculate track and album gain values. I then delete the temporary files.

I'd like to be able to avoid the temporary files. Either by using stdin, and somehow including a "new track starts now" flag between the tracks, or perhaps by having wavegain be able to take a list of commands to run to receive the track data on stdin.

Any thoughts if this is possible?

X


I've solved this myself now. I finally managed to get wavegain to build on mingw on windows, and then I made a couple of changes.
1. I turned off ENABLE_RECURSIVE in config.h - it didn't work with my change, and I never use that anyway
2. I changed wavegain.c get_gain function, from

if(!strcmp(filename, "-")) {
infile = stdin;
settings->apply_gain = 0;
wg_opts->std_in = 1;
#ifdef _WIN32
_setmode( _fileno(stdin), _O_BINARY );
#endif
}
else
infile = fopen(filename, "rb");


to

if(!strcmp(filename, "-")) {
infile = stdin;
settings->apply_gain = 0;
wg_opts->std_in = 1;
#ifdef _WIN32
_setmode( _fileno(stdin), _O_BINARY );
#endif
}
else if (filename[0] == '^') {
r = strrchr(filename + 1, '^');
if ® { r[0] = '\0'; };
fprintf(stderr, "Running \"%s\"\n", filename + 1);
infile = popen(filename + 1, "rb");
if ® { r[0] = '\\'; };
settings->apply_gain = 0;
wg_opts->std_in = 1;
}
else
infile = fopen(filename, "rb");


This allows you to specify multiple filenames on the command-line, which are actually commands to run to get the audio data, for example:
wavegain -a "^flac -d -c foo.flac" "^lame --decode bar.mp3 -"

The messing around with r is so that you can specify a fake filename for the input command, which gets reported if you use -e. I needed this. It works like:
wavegain -a "^flac -d -c foo.flac^foo.wav" "^lame --decode bar.mp3 -^bar.wav"

I hope this is useful to someone else!

X
Go to the top of the page
+Quote Post
pbelkner
post Oct 31 2012, 12:32
Post #9





Group: Members
Posts: 412
Joined: 13-June 10
Member No.: 81467



QUOTE (xorsyst @ Oct 31 2012, 10:14) *
wavegain -a "^flac -d -c foo.flac^foo.wav" "^lame --decode bar.mp3 -^bar.wav"

You may have considered using "r128gain" (http://r128gain.sourceforge.net/):

CODE
r128gain --rg foo.flac bar.mp3

"r128gain" comes with the ReplayGain algorithm taken 1:1 from "wavegain" encapsulated in "libreplaygain.dll" (win32) or "libreplaygain.so" (linux).

"r128gain" automatically uses the decoders from FFmpeg (http://ffmpeg.org/) for each supported format/codec (that's almost all).

In order to enable MP3 in "r128gain" you have to upgrade the FFmpeg DLLs from the sub-directory "r128gain-tools" with their counterparts taken from the latest build from Zeranoe: http://ffmpeg.zeranoe.com/builds/win32/shared/.
Go to the top of the page
+Quote Post
xorsyst
post Oct 31 2012, 13:28
Post #10





Group: Members
Posts: 14
Joined: 1-October 09
Member No.: 73611



QUOTE (pbelkner @ Oct 31 2012, 11:32) *
QUOTE (xorsyst @ Oct 31 2012, 10:14) *
wavegain -a "^flac -d -c foo.flac^foo.wav" "^lame --decode bar.mp3 -^bar.wav"

You may have considered using "r128gain" (http://r128gain.sourceforge.net/):


Interesting. Does it have the ability to only take as input a section of audio from one of the source files? My particular use case involves extracting individual tracks from single-file wavpack albums using getaudio
Go to the top of the page
+Quote Post
pbelkner
post Oct 31 2012, 14:53
Post #11





Group: Members
Posts: 412
Joined: 13-June 10
Member No.: 81467



QUOTE (xorsyst @ Oct 31 2012, 13:28) *
Does it have the ability to only take as input a section of audio from one of the source files? My particular use case involves extracting individual tracks from single-file wavpack albums using getaudio

I'm not certain what you mean. Are you talking about "a CUESHEET field in the APEv2 tag" as described in the wavpack documentation (http://www.wavpack.com/wavpack_doc.html)?
Go to the top of the page
+Quote Post
xorsyst
post Oct 31 2012, 15:11
Post #12





Group: Members
Posts: 14
Joined: 1-October 09
Member No.: 73611



QUOTE (pbelkner @ Oct 31 2012, 13:53) *
QUOTE (xorsyst @ Oct 31 2012, 13:28) *
Does it have the ability to only take as input a section of audio from one of the source files? My particular use case involves extracting individual tracks from single-file wavpack albums using getaudio

I'm not certain what you mean. Are you talking about "a CUESHEET field in the APEv2 tag" as described in the wavpack documentation (http://www.wavpack.com/wavpack_doc.html)?


Not quite - I have an external list of sections of a wavpack file (and/or other formats) that I want gain. There's a tool called getaudio (dunno where I got it from) that allows use like:
getaudio --begin 02:31:15 --end 04:01:00 inputfile.wv
Those begin/end times did originally come from a cuesheet, but aren't in that format any more.

Go to the top of the page
+Quote Post
pbelkner
post Oct 31 2012, 15:50
Post #13





Group: Members
Posts: 412
Joined: 13-June 10
Member No.: 81467



QUOTE (xorsyst @ Oct 31 2012, 15:11) *
I have an external list of sections of a wavpack file (and/or other formats) that I want gain. There's a tool called getaudio (dunno where I got it from) that allows use like:
getaudio --begin 02:31:15 --end 04:01:00 inputfile.wv
Those begin/end times did originally come from a cuesheet, but aren't in that format any more.

Unfortunately "r128gain" currently doesn't support something like this.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 17th April 2014 - 22:53