sndfile-waveform channel parameter bug
Closed this issue · 7 comments
Hey,
as in v. 1.04, the -c parameter doesn't work properly (on stereo file):
-c 0 = mixdown to mono = ok
-c 1 = waveform for channel 1 = ok
-c -1 = invalid channel (should create one .png file with both channels, right?)
-c 2 = invalid channel (should create waveform for channel 2)
Hope I can help,
all the best
vince
@x42 Looking at the code, it looks like a render->channel
value of less than 0
is supposed to do something but I can't figure out what. Any clues?
35540ef is wrong render->channel == -1
means "render all channels, each in its own graph, vertically separated.
>=0
only display one graph; with 0
: sum all channels (mono downmix), >0
: render channel 1 (left), 2(right) etc. up to (and including) info->channels
PS. Line 959 (35540ef) should read
if (render->channel < -1 || render->channel > info.channels)
@erikd , @x42
Hey Erik, hey Robin,
I compiled it yesterday and made some tests. Now it is possible to render each channel separately, but the "mixing channels" and "render all channels" don't work. Here the results:
sndfile-waveform -b -c 1 file.wav file.png -> okay (renders channel 1)
sndfile-waveform -b -c 2 file.wav file.png -> okay (renders channel 2)
sndfile-waveform -b -c 0 file.wav file.png -> Error: channel parameter must be in range [-1, 2]
sndfile-waveform -b -c -1 file.wav file.png -> Error: channel parameter must be in range [-1, 2]
Hope I can help!
All the best,
Vince
Yes that is expected. Either git revert 35540ef, or fix the condition render->channel
can be -1, 0 or > 0. I don't know why Erik did make that commit.
diff --git a/src/waveform.c b/src/waveform.c
index 9adfd96..1a339e7 100644
--- a/src/waveform.c
+++ b/src/waveform.c
@@ -956,7 +956,7 @@ render_sndfile (RENDER * render)
exit (EXIT_FAILURE) ;
} ;
- if (render->channel < 1 || render->channel > info.channels)
+ if (render->channel < -1 || render->channel > info.channels)
{ printf ("Error: channel parameter must be in range [%d, %d]\n", -1, info.channels) ;
sf_close (infile) ;
exit (EXIT_FAILURE) ;
now it works as expected, thank you!
Thanks. Closing this.