[Audio processing] WAV audio file merge

Source: Internet
Author: User

 PackageCom.audioprocessingbox.myfunc;ImportJava.io.File;Importjava.io.IOException;Importjavax.sound.sampled.UnsupportedAudioFileException;ImportCom.audioprocessingbox.utils.WavFile;Importcom.audioprocessingbox.utils.WavFileException; Public classAppcombfiles {Private Static Final LongSamplerate = 16000;  Public Static voidMain (string[] arg)throwsunsupportedaudiofileexception {Try {            int[] Postbuffer =New int[0], Newbuffer =New int[0], buffer;            Wavfile Wavfile;  for(inti = 103; I < 111; i++) {Wavfile= Wavfile.openwavfile (NewFile ("/users/karl/work/database/speaker/certainspeaker/" + i + ". wav")); if(Samplerate! =wavfile.getsamplerate ()) {                    Throw NewIllegalArgumentException ("The different than Recognito ' +" Defi Ned Sample rate: ["+ wavfile.getsamplerate () +"] "); }                //Read wav data into int array                intNframes = (int) Wavfile.getnumframes (); Buffer=New int[Nframes];                Wavfile.readframes (buffer, nframes);                Wavfile.close (); //Combine an int arrayNewbuffer =New int[Postbuffer.length +Buffer.length]; System.arraycopy (Postbuffer,0, Newbuffer, 0, postbuffer.length); System.arraycopy (Buffer,0, Newbuffer, Postbuffer.length, buffer.length); Postbuffer=New int[Postbuffer.length +Buffer.length]; Postbuffer=Newbuffer; } wavfile saveFile= Wavfile.newwavfile (NewFile ("/users/karl/work/javawork/combine.wav"), 1, Postbuffer.length, 16, samplerate);            Savefile.writeframes (Postbuffer, postbuffer.length);            Savefile.close (); System.out.println (Postbuffer.length/samplerate); } Catch(IOException e) {//TODO auto-generated Catch blockE.printstacktrace (); } Catch(wavfileexception e) {//TODO auto-generated Catch blockE.printstacktrace (); }    }}

[Audio processing] WAV audio file merge

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.