0

As the question states I'm trying to append a file to the end of a WAV file as a form of steganography(I know it's not the most secretive but it's for practice). Here is the code I have

File soundFile = new File("test.wav");
                AudioInputStream input = AudioSystem.getAudioInputStream(soundFile);

                InputStream inputOther = new BufferedInputStream(new FileInputStream("test.jpg"));

                AudioInputStream appendTime = new AudioInputStream(new SequenceInputStream(inputOther, input, input.getFormat(), input.getFrameLength()));

But the AudioInputStream "appendTime" doesn't work. Is there another way to append a file to a WAV file or can I fix this one?

Zach
  • 640
  • 1
  • 8
  • 20
  • 1
    What is the concrete problem? Do you get an compile or runtime error? Or is there a problem with the generated file? It could be, that when you get the code running, and the file is generated, you have to edit the file-header: see `ChunkSize` ... https://de.wikipedia.org/wiki/RIFF_WAVE – Meiko Rachimow Mar 31 '16 at 00:28
  • Specifically my SequenceInputStream states that I'm using incorrect parameters but the error message is long – Zach Mar 31 '16 at 00:30
  • @Meiko is there a method in the api to access the header? – Zach Mar 31 '16 at 00:33
  • A WAV file knows how long it is so you can't just append stuff on the end and have it work correctly. You need to do some low level stuff, at the very least editing the header in several places. http://soundfile.sapp.org/doc/WaveFormat/ But the best thing to do here is put the data in a custom subchunk because putting arbitrary numbers in the audio data is a very bad idea for your speakers and/or ears. You should spend time learning the WAV/RIFF file format(s). – Radiodef Mar 31 '16 at 00:34
  • could help http://stackoverflow.com/questions/5810164/how-can-i-write-wav-file-from-byte-array-in-java – Meiko Rachimow Mar 31 '16 at 00:41
  • You're getting a compiler error because you have a parenthesis in the wrong place. You're passing the AudioFormat and stuff to the SequenceInputStream constructor. – Radiodef Mar 31 '16 at 00:43

0 Answers0