What is an alternate class for AudioInputStream in java (Android)?

About a year ago, I started creating an Android app. Now, when I try to run it, I get an exception from the AudioInputStream class. After a short research that I did with GOOGLE, I found out that android no longer supports this class ... Is this their alternative?

This is the code I wrote:

private void merge2WavFiles(String wavFile1, String wavFile2, String newWavFilePath) { try { File wave1 = new File(wavFile1); if(!wave1.exists()) throw new Exception(wave1.getPath() + " - File Not Found"); AudioInputStream clip1 = AudioSystem.getAudioInputStream(wave1); AudioInputStream clip2 = AudioSystem.getAudioInputStream(new File(wavFile2)); AudioInputStream emptyClip = AudioSystem.getAudioInputStream(new File(emptyWavPath)); AudioInputStream appendedFiles = new AudioInputStream( new SequenceInputStream(clip1, emptyClip), clip1.getFormat(), clip1.getFrameLength() + 100 ); clip1 = appendedFiles; appendedFiles = new AudioInputStream( new SequenceInputStream(clip1, clip2), clip1.getFormat(), clip1.getFrameLength() + clip2.getFrameLength() ); AudioSystem.write(appendedFiles, AudioFileFormat.Type.WAVE, new File(newWavFilePath)); } catch (Exception e) { e.printStackTrace(); } } 
+4
source share
1 answer

I also have similar problems with yours when developing frequency generation methods installed on android, so I multiplied a lot everywhere in the android and java se 1.7 docs link APIs. But there are no easily replaceable alternatives to the AudioInputStream class or even the AudioSystem class found in your code. If you want to use your heritage, you may have to review and reorganize several items. In my cases, I used InputStream and ByteArrayInputStream (java.io) for this, and AudioRecord and AudioManager (android.media) will control some actions for recording and systematic management. Please note that AudioFormat in android and java7 differ in their internal characteristics. If I remove my problems when manipulating audio, I will attach you a sample code.

+1
source

All Articles