A
Alex Ochoa
Hi, I wrote a Java program that takes a stereo .wav file and turns it
into a mono .wav file by appropriately deleting the information on one
channel (it ask you which one you want to keep). I don't think the
details of the sound editing matter. I'm not interested in simply
converting the .wav files from stereo to mono (I have retail programs
that do that already), but I want to solve my problem just to be a
better programmer.
The point is that I load an input stream and operate on it (loading
other streams in between to change the format of the info I'm reading)
and then write to the original file. I ran the program on a 52-byte
..wav file and IT WORKED, but on the other files (around 30 KB each) the
program hangs. Moreover, I compiled it placing
System.out.println("everything is fine here") and variations to see how
far down the code the program would stop, and I saw that with long
enough files (30 KB) the program would stop after exactly 513
iterations of a while loop in it. I only had one 1 KB file I could
work with and for this one it would finish all the necesary while
iterations (because they were less than 513), but the program would
later hang when trying to write the final stream to the .wav file.
I can put the code here if you want, it's not too long, but probably
long enough for a forum. What I was wondering is if anybody knows a
priori how to fix this (in case it is a known and general issue with
programs that do a lot of operations) or is this a problem specific to
my code, which might look good but actually isn't.
Your help will be greatly appreciated.
into a mono .wav file by appropriately deleting the information on one
channel (it ask you which one you want to keep). I don't think the
details of the sound editing matter. I'm not interested in simply
converting the .wav files from stereo to mono (I have retail programs
that do that already), but I want to solve my problem just to be a
better programmer.
The point is that I load an input stream and operate on it (loading
other streams in between to change the format of the info I'm reading)
and then write to the original file. I ran the program on a 52-byte
..wav file and IT WORKED, but on the other files (around 30 KB each) the
program hangs. Moreover, I compiled it placing
System.out.println("everything is fine here") and variations to see how
far down the code the program would stop, and I saw that with long
enough files (30 KB) the program would stop after exactly 513
iterations of a while loop in it. I only had one 1 KB file I could
work with and for this one it would finish all the necesary while
iterations (because they were less than 513), but the program would
later hang when trying to write the final stream to the .wav file.
I can put the code here if you want, it's not too long, but probably
long enough for a forum. What I was wondering is if anybody knows a
priori how to fix this (in case it is a known and general issue with
programs that do a lot of operations) or is this a problem specific to
my code, which might look good but actually isn't.
Your help will be greatly appreciated.