Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Wavegain problems in Linux (Read 18299 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Wavegain problems in Linux

Reply #25
I analyzed several albums with the new 1.2.6 beta.

The Good: I no longer get the error message when analysis is complete.  Glad about that.

The Bad: The files are showing up out of order again.  This must be something native to my system since no one else has reported it.  When the files get processed out of order, it happens regardless of which version of Wavegain I use, even really old ones.  By the same token, when they get processed in the correct order it works regardless of which version of Wavegain I use.  Any ideas?


Wavegain problems in Linux

Reply #26
Quote
I analyzed several albums wirth the new 1.2.6 beta.

The Good: I no longer get the error message when analysis is complete.  Glad about that.

The Bad: The files are showing up out of order again.  This must be something native to my system since no one else has reported it.  When the files get processed out of order, it happens regardless of which version of Wavegain I use, even really old ones.  By the same token, when they get processed in the correct order it works regardless of which version of Wavegain I use.  Any ideas?
[a href="index.php?act=findpost&pid=341402"][{POST_SNAPBACK}][/a]

I'm glad about the resolution of the first point. 

As to the second point, the files are added to the list for processing in the order that they are presented by the OS, so that is not part of any of the processing being performed by WaveGain. I haven't checked, but does the order in which they are sorted within the directory have any impact on this?

Wavegain problems in Linux

Reply #27
Quote
As to the second point, the files are added to the list for processing in the order that they are presented by the OS, so that is not part of any of the processing being performed by WaveGain. I haven't checked, but does the order in which they are sorted within the directory have any impact on this?
Normally I have Windows Explorer sort files by name, but I do occasionally sort by time, size, or last time modified if I'm looking for something quick, but I didn't think the way my files were sorted in Explorer would have anything to do with Wavegain.  Even so, I checked, and they're listed by name.  However, when I do a directory listing at a DOS prompt, the files show up in the same random order as they do in the Wavegain log file.

I can build computers from the ground up, format and partition hard drives, and edit the registry with impunity, but most stuff is over my head.  How the heck do I get the files to show numerically/alphabetically in DOS?

Wavegain problems in Linux

Reply #28
Follow up: I've determined that my problem is an 8.3 file name issue, so as you said, nothing to do with Wavegain.

Back to the topic at hand - I'm hoping some other people will try out the 1.2.6 beta to see if there are any bugs.  Analysis works fine here.

John, are the Album DC Offset & more recent algorithm you added to the 1.2.6 beta the enhancements you alluded to in another post, or do you have something else yet you're planning on adding?

Wavegain problems in Linux

Reply #29
That's all that's planned for this release.

Wavegain problems in Linux

Reply #30
Hi John,


please try your new beta with this command:

WaveGain -r -y -q <allfiles>


Take two files minimum and see what happens to the second, third, ...
... expected to get album DC-Offset correction with radio Gain correction.

Nevertheless it would be nice having an option to completely switch off
DC-Offset correction.

Thanks!!!

Wavegain problems in Linux

Reply #31
Quote
Hi John,


please try your new beta with this command:

WaveGain -r -y -q <allfiles>


Take two files minimum and see what happens to the second, third, ...
... expected to get album DC-Offset correction with radio Gain correction.

Nevertheless it would be nice having an option to completely switch off
DC-Offset correction.

Thanks!!!
[a href="index.php?act=findpost&pid=341664"][{POST_SNAPBACK}][/a]

Ooops!!!!  Thanks for the notification. This is now fixed in beta2, and I've added an option to switch DC Offset correction off  , although I confess I don't really understand why you'd want to do that.

Wavegain problems in Linux

Reply #32
john - i'm not sure you realize this, but you are referring to a win32 binary-only beta in a linux thread...

i'm not seeing the sources for >1.2.5 at all


thanx john,
mike

Wavegain problems in Linux

Reply #33
Quote
Ooops!!!!   Thanks for the notification. This is now fixed in beta2, and I've added an option to switch DC Offset correction off  , although I confess I don't really understand why you'd want to do that.
[a href="index.php?act=findpost&pid=341722"][{POST_SNAPBACK}][/a]


No problem,

that's what betas are for. Beta2 is working flawless so far. Big thanks for implementing requested option(s).
This little tool is just great!!!

Wavegain problems in Linux

Reply #34
Quote
john - i'm not sure you realize this, but you are referring to a win32 binary-only beta in a linux thread...

i'm not seeing the sources for >1.2.5 at all


thanx john,
mike
[a href="index.php?act=findpost&pid=341818"][{POST_SNAPBACK}][/a]

Good point, Mike!!  I'll take it elsewhere from now on. Regarding the source, I wasn't proposing to post that until I was reasonably certain it was final. However, I can post it now if you wish.

Wavegain problems in Linux

Reply #35
Quote
john - i'm not sure you realize this, but you are referring to a win32 binary-only beta in a linux thread...

i'm not seeing the sources for >1.2.5 at all


thanx john,
mike
[a href="index.php?act=findpost&pid=341818"][{POST_SNAPBACK}][/a]

Mike, I've added the 1.2.6b3 sources, which would appear to be OK, to Rarewares but it might be a good idea to make sure there aren't any linux issues before release!!

Wavegain problems in Linux

Reply #36
  thanx, john!

Wavegain problems in Linux

Reply #37
@john33

The current version has still some subtle issues. Here is a patch which fixes these and some portability issues. (You really should copnsider developing in Linux using valgrind or at least use a similar tool in Windows - but I don't know of any free one...)

The patch
Code: [Select]
diff -urd wv126o/audio.c wavegain-1.2.6/audio.c
--- wv126o/audio.c    2005-11-05 15:25:26.000000000 +0100
+++ wavegain-1.2.6/audio.c    2005-11-17 10:38:47.965415424 +0100
@@ -30,7 +30,11 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
+#ifdef _WIN32
#include <io.h>
+#else
+#include <sys/io.h>
+#endif
#include <fcntl.h>
#include <malloc.h>
#include <math.h>
@@ -416,6 +420,8 @@
 if (format.format == 1) {
     samplesize = format.samplesize/8;
     opt->read_samples = wav_read;
+  /* works with current enum */
+  opt->format = samplesize;
 }
 else if (format.format == 3) {
     samplesize = 4;
Nur in wavegain-1.2.6: CMakeLists.txt.
diff -urd wv126o/main.c wavegain-1.2.6/main.c
--- wv126o/main.c    2005-11-15 18:08:24.000000000 +0100
+++ wavegain-1.2.6/main.c    2005-11-17 10:39:36.812989464 +0100
@@ -66,8 +66,7 @@
 node = calloc(1, sizeof(*node));

 if (node != NULL) {
-//  node->filename = strdup(file);
-  node->filename = _strdup(file);
+  node->filename = strdup(file);

     if (node->filename != NULL) {
   node->track_peak = NO_PEAK;
Nur in wavegain-1.2.6: Makefile.
diff -urd wv126o/misc.h wavegain-1.2.6/misc.h
--- wv126o/misc.h    2004-03-05 13:02:24.000000000 +0100
+++ wavegain-1.2.6/misc.h    2005-11-17 10:35:13.575007720 +0100
@@ -4,6 +4,9 @@
#if  defined _WIN32 && !defined __MINGW32__                 // Microsoft and Intel call it __int64
typedef signed   __int64    Int64_t;
typedef unsigned __int64    Uint64_t;
+#define chdir _chdir
+#define strdup _strdup
+#define getcwd _getcwd
#else
typedef signed   long long  Int64_t;
typedef unsigned long long  Uint64_t;
diff -urd wv126o/recurse.c wavegain-1.2.6/recurse.c
--- wv126o/recurse.c    2005-11-12 12:29:32.000000000 +0100
+++ wavegain-1.2.6/recurse.c    2005-11-17 10:40:18.380670216 +0100
@@ -430,8 +430,7 @@
 char* old_path;
 int result = -1;

-//    old_path = getcwd(NULL, 1024);
-    old_path = _getcwd(NULL, 1024);
+    old_path = getcwd(NULL, 1024);

 if (old_path == NULL) {
     file_error(_("Couldn't get name of current directory: "));
@@ -453,8 +452,7 @@

 strcat(full_path, path);

-//    if (chdir(path) == 0) {
-    if (_chdir(path) == 0) {
+    if (chdir(path) == 0) {
     DIRECTORY* directory;
     FILE_LIST* file_list = NULL;

@@ -500,8 +498,7 @@

     free_list(file_list);

-//  if ((result == 0) && (chdir(old_path) != 0)) {
-  if ((result == 0) && (_chdir(old_path) != 0)) {
+  if ((result == 0) && (chdir(old_path) != 0)) {
   file_error(_("Couldn't go back to folder '%s': "), old_path);
   result = 0;
     }
@@ -528,8 +525,7 @@
 */
int process_argument(const char* path, SETTINGS* settings)
{
-//    char* buffer = strdup(path);
-    char* buffer = _strdup(path);
+    char* buffer = strdup(path);
 char* my_path;
 int my_path_len;
 int dir;
diff -urd wv126o/wavegain.c wavegain-1.2.6/wavegain.c
--- wv126o/wavegain.c    2005-11-15 22:03:58.000000000 +0100
+++ wavegain-1.2.6/wavegain.c    2005-11-17 10:47:53.851428136 +0100
@@ -21,12 +21,15 @@
#include <math.h>
#include <string.h>
#include <ctype.h>
+#ifdef _WIN32
#include <io.h>
+#else
+#include <sys/io.h>
+#endif
#include <fcntl.h>
#include <malloc.h>
#include "gain_analysis.h"
#include "i18n.h"
-#include "config.h"
#include "getopt.h"
#include "misc.h"
#include "audio.h"
@@ -559,8 +562,8 @@
     for (i = 0; i < wg_opts->channels; i++)
   if (pcm[i]) free(pcm[i]);
     if (pcm) free(pcm);
-  close_audio_file(infile, aufile, wg_opts);
     format->close_func(wg_opts->readdata);
+  close_audio_file(infile, aufile, wg_opts);
     fclose(infile);

     if (!settings->std_out) {



What it fixes:

Code: [Select]
diff -urd wv126o/audio.c wavegain-1.2.6/audio.c
--- wv126o/audio.c    2005-11-05 15:25:26.000000000 +0100
+++ wavegain-1.2.6/audio.c    2005-11-17 10:38:47.965415424 +0100
@@ -416,6 +420,8 @@
 if (format.format == 1) {
     samplesize = format.samplesize/8;
     opt->read_samples = wav_read;
+  /* works with current enum */
+  opt->format = samplesize;
 }
 else if (format.format == 3) {
     samplesize = 4;


You should really check the wav_open and aiff_open functon whether they set ALL values of opt. Currently it is not the case and above was the one I tracked. Otherwise you read uninitialised values leading to non-deterministic (and crashing-prone) behaviour. I think above is what was intended.

Code: [Select]
--- wv126o/wavegain.c    2005-11-15 22:03:58.000000000 +0100
+++ wavegain-1.2.6/wavegain.c    2005-11-17 10:47:53.851428136 +0100
@@ -21,12 +21,15 @@

#include "gain_analysis.h"
#include "i18n.h"
-#include "config.h"
#include "getopt.h"
#include "misc.h"
#include "audio.h"


It was really a bad idea to include config.h w/o the HAVE_CONFIG_H define check only here. This breaks in a subtle way if you look at the settings struct... (In one object ENABLE_RECURSION is defined, in the other not -> havoc.)

So either put config.h in *every* file or leave it like this. Just pass HAVE_CONFIG_H to your compiler, which would be the best thing and everything should run nicely.

Code: [Select]
@@ -559,8 +562,8 @@
     for (i = 0; i < wg_opts->channels; i++)
   if (pcm[i]) free(pcm[i]);
     if (pcm) free(pcm);
-  close_audio_file(infile, aufile, wg_opts);
     format->close_func(wg_opts->readdata);
+  close_audio_file(infile, aufile, wg_opts);
     fclose(infile);

     if (!settings->std_out) {


Here the order is important otherwise wg_opts will be freed and you later try to access an invalid pointer.

The rest are portability patches, which should make wavegain compilable on unix and windows w/o further defines, please check if this is the case.

This is the updated CMakeLists.tst file:
Code: [Select]
# cmake project file by Prakash Punnoor 
PROJECT(Wavegain)

ADD_DEFINITIONS(-DHAVE_CONFIG_H)

ADD_EXECUTABLE(wavegain
              audio.c
              dither.c
              gain_analysis.c
              getopt1.c
              getopt.c
              main.c
              misc.c
              recurse.c
              wavegain.c
)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-lm ")

INSTALL_TARGETS(/bin wavegain)


Again I have not checked every possible input and path in wavegain, just analysed and applied it to a pcm wav.

BTW, the issues are not linux only. Most of the time you just won't see the problems in Windows and linux as the program seems to behave normaly (but not always) - so these bugs are hard to track w/o a help of a tool like valgrind...

Wavegain problems in Linux

Reply #38
Thanks for the input. I'm sure someone will correct me if I'm wrong, but isn't the use of '_strdup', etc., ie., with the underscore, more a C99 compiler compatability issue rather than a portability issue?

Wavegain problems in Linux

Reply #39
Quote
Thanks for the input. I'm sure someone will correct me if I'm wrong, but isn't the use of '_strdup', etc., ie., with the underscore, more a C99 compiler compatability issue rather than a portability issue?
[a href="index.php?act=findpost&pid=342527"][{POST_SNAPBACK}][/a]


I don't know much about it (esp about C99), but afaik functions with preceding underscores are built-ins, so usually a language won't have these kinds of functions.

 

Wavegain problems in Linux

Reply #40
1.2.6beta4 source now at Rarewares incorporating the above, and a couple of other, code improvements. (Also a win32 binary for anyone interested.  )