What is the alternative class of audioinputstream in Java (Android)?
About a year ago, I started building an Android application
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.getFrameLength() + clip2.getFrameLength() ); AudioSystem.write(appendedFiles,AudioFileFormat.Type.WAVE,new File(newWavFilePath)); } catch (Exception e) { e.printStackTrace(); } }
Solution
I also encountered similar problems when developing the frequency generation method on Android, so I can see it everywhere in the Android reference and the API of Java se 1.7 docs However, there is no easy exchange alternative to the audioinputstream class, and the audiosystem class cannot even be found in the code If you want to use your legacy, you may need to modify and refactor several projects In my example, I use InputStream and bytearrayinputstream (Java. IO). Some actions of recording and system will be managed by audiorecord and AudioManager (Android. Media) Note that audioformat in Android and Java 7 is different from its internal features If I clear my problem in audio operation, I will attach a sample code for you