Combination 2 + WAV files into one WAV file

Hello

I try to combine at least 2 WAV files (my example uses 3) in a single file. I've tried several examples (http://www.jsresources.org/examples/AudioConcat.html and http://stackoverflow.com/questions/653861/join-two-wav-files-from-java), but both have the same problem: the output file is an exact copy of the last file that has been joined.

Here is the code for the simplest of 2 examples that I modified to suit my needs.
        File outputFile = new File("concat.wav");
        for (int i = 0; i < files.length - 1; i++) {
            try {
                AudioInputStream clip1 = AudioSystem.getAudioInputStream(files);
AudioInputStream clip2 = AudioSystem.getAudioInputStream(files[i + 1]);

AudioInputStream appendedFiles =
new AudioInputStream(
new SequenceInputStream(clip1, clip2),
clip1.getFormat(),
clip1.getFrameLength() + clip2.getFrameLength());

AudioSystem.write(appendedFiles,
AudioFileFormat.Type.WAVE,
outputFile);

files[i + 1] = outputFile;//first file read in next loop, will contain joined file so far

} catch (Exception e) {
e.printStackTrace();
}
}
return outputFile;


I am unsure as where the problem lies, so would be grateful for anyone to point out the (no doubt obvious) mistake i've made :p

I see no problem with your actual code in terms of JavaSound, but...

The first run through, you'd be concating 'file1.wav' and 'file2.wav' in a file called "concat.wav". The second time, you'd be concating 'concat.wav' and 'file3.wav' in a file called "concat.wav"...

On the second iteration, "concat.wav" will be put on it until the sequence input stream releases it... What happens as soon as he did read-lock read. At this time, the read lock is released and you can get a lock in writing on this subject, but you have already spilled all concat.wav data in the compartment bits... so the only thing that happens to go there now is "file3.wav".

So, don't try to read and write to the same file at the same time...

Tags: Java

Similar Questions

  • Combine the two projects into one

    I know it is a very popular question and I read many answers excellent previous answers.  The two most popular procedures seem to be simple copy - paste and use clips of compounds with copy / paste.  CPF has improved this process over the years and I ask the question again to get the benefit of current thinking.   I have an iMac (mid-2011) OS X 10.11.4 and FCP worm 10.2.2.  I have two separate events within the same library.  There is a completed project, with all the transitions, effects and music, located within each discipline.    Current ideas on how to combine these two projects into one would be greatly appreciated.

    Thank you.

    Copy and paste is the only method I know.

    Open the project in the timeline first.

    Open the second project in the timeline panel. Only one project appears at the same time.

    Select an item in the timeline and press command + A to select all, then control + C to copy.

    Use the project navigation arrows to return the first project:

    Move the playhead to where copied clips must be glued and press command + V.

    Al

  • I currently have a creative cloud with an e-mail account, however I have a behance with an e-mail account that I have had for many years (even Adobe and Behance made before part of the same group). Can I combine these two accounts into one?

    I currently have a creative cloud with an e-mail account, however I have a behance with an e-mail account that I have had for many years (even Adobe and Behance made before part of the same group). Can I combine these two accounts into one? I want to use the account that I pay cloud Creative if I can use the new portfolio feature.

    Thank you.

    This is an open forum, not Adobe support... below to connect with Adobe personnel to help

    While the forums are open 24/7 you can't contact Adobe support at any time

    Chat support: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

  • How to combine two different accounts into one?

    We have an account at work that has a subscription of cloud on that and I also have a separate for work as I can access only. How am I supposed to combine the two is multi-user account? My account has expired so I need re-new anyway with the other one.

    Help, please!

    Since this is an open forum, not Adobe support... you must contact Adobe personnel to help

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

    For a computer to work, you may need a TEAM account

    - https://creative.adobe.com/plans?plan=team team plans

    -http://www.adobe.com/creativecloud/buy/business.html

    -https://helpx.adobe.com/contact/creative-cloud-teams.html using the team

    -manage your account http://forums.adobe.com/thread/1460939?tstart=0 team

  • combining the three queries into one

    Hello everyone, I have the following queries in a format similar to below and I would like to combine it with one... I know I could use an if statement but is it possible to do in pure sql
    select t.p1,
           t.p2,
           t.p3,
           t.p4
    from tbl_one t
    where t.p4 like (p4_parameter)
    order by t.p1
    
    select t.p1,
           t.p2,
           t.p3,
           t.p4
    from tbl_one t
    where upper(t.p1) like upper ((p1_parameter) || '%');
    
    select t.p1,
           t.p2,
           t.p3,
           t.p4
    from tbl_one t
    where t.p1 != 0;

    combine all three queries with GOLD seats...

    select t.p1,
           t.p2,
           t.p3,
           t.p4
    from tbl_one t
    where t.p4 like (p4_parameter)
    and upper(t.p1) like upper ((p1_parameter) || '%')
    and t.p1 != 0;
    

    and as suggested madhu, while displaying u should take care of type of data as well...

    If you want to compare t.p1! = 0
    you need to replace

    t.P1! = 0 to t.p1! = '0'

    or if you want
    t.P1! = 0 compared to not null
    the

    t.P1 is not null

    Concerning

    UMI

  • Combination of several lines into one

    Hello

    I have a table like this

    ID | name
    1 aWord
    1 Anotherword
    2 Gisela


    I would like a result of the query, where two rows (or a lot as it is in the table, with this id) to put in a string separated by commas, like this "aWord, Anotherword" ID = 1. Preferably, I would like to avoid using cursors...

    Any help on this is appreciated.

    Thank you

    /David N

    Like this...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select deptno, ltrim(sys_connect_by_path(ename,','),',') as enames
      2  from (
      3        select deptno, ename, row_number() over (partition by deptno order by ename) rn from emp
      4       )
      5  where connect_by_isleaf = 1
      6  connect by deptno = prior deptno
      7         and rn = prior rn + 1
      8  start with rn = 1
      9* order by deptno
    SQL> /
    
        DEPTNO ENAMES
    ---------- --------------------------------------------------
            10 CLARK,KING,MILLER
            20 ADAMS,FORD,JONES,SCOTT,SMITH
            30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
    
    Or to ensure names are distinct...
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  select deptno, ltrim(sys_connect_by_path(ename,','),',') as enames
      2  from (
      3        select distinct deptno, ename, dense_rank() over (partition by deptno order by ename) rn
      4        from emp
      5       )
      6  where connect_by_isleaf = 1
      7  connect by deptno = prior deptno
      8         and rn = prior rn + 1
      9  start with rn = 1
     10* order by deptno
    SQL> /
    
        DEPTNO ENAMES
    ---------- --------------------------------------------------
            10 CLARK,KING,MILLER
            20 ADAMS,FORD,JONES,SCOTT,SMITH
            30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
    
    SQL>
    
  • Resize/merge/combine two hard drives into one?

    Hi there, I was wondering if someone could help me. I created a new Member Server in Windows 2008 R2 with an original C: drive of 20 GB. Later, I had to install a program requiring 30 GB of space thus created a second disk on E: with 30 GB allocated to it. Unfortunately, the default program installation on the C: drive and ended up running out of free disk to continue. Given that both drives are separate disks but always virtual in nature is there a way to merge them into a single drive C: with a total of 50 GB of capacity?

    I didn't know that the machine should be stopped to extend the drive. To extend is greyed out when stopping the VM, it's where I fell on my problem.

  • How to combine documents on the new Adobe Reader software? It seems to have updated and it does not combine files into one.

    How to combine documents on the new Adobe Reader software? It seems to have updated and it does not combine files into one.

    Se, Reader cannot do this. You can do it with a subscription to services pack pdf or the full version of Adobe Acrobat.

  • How to combine multiple PDFs into one file

    How to combine multiple PDFs into one file

    Hi Marketing Haskin,

    The link mentioned by Mandeep requires you to have the Acrobat software.

    However if you purchased export them to PDF / service Acrobat.com you can select 'Combine files' on the right side and then click on the button 'Select files' to select the files you want to combine.

  • can I combine PDF files into one PDF file with acrobat standard dc?

    Can I combine two PDF files into a single pdf with acrobat standard dc?

    This restriction applies only when you combine files using the CreatePDF online service, not when you use Acrobat.

  • Combining the NACHA several files into one

    Gurus, we will implement the new file format NACHA for our payroll service. Payroll running a DOS command to concatenate several files into one .mf. Is there a way to Oracle to achieve the same?

    Database server
    ----------------------------------------
    RDBMS: 11.2.0.3.0
    Oracle Applications: 11.5.10.2


    Thanks, Naveen Gagadam.

    Published by: mascot of Oracle on May 30, 2013 10:26

    Vignesh Hi, I just went through our Installer and there are Consolidation defined for each payroll that we use. I think it is better the purpose of having a consolidation set. Could you tell me how to consolidate several salary mass as a whole or alternatively can add several wage masses on the fly (as parameters) for each race NACHA?

    Thanks, Naveen.

  • Merge several video files into one (fastest option)

    Hello everyone.

    I was wondering if there is an easy way to join several video files using a first/Media Encoder (or another tool?)

    I mean other than import in a project, by adding them all in a timeline and making everything again.

    "Why not do just that? ... you ask.

    The thing is - it's a delay of 24 hours. Yes that's right - this is a project where something was filmed for 24 hours. And there are 6 clips STROKE (every 4 hours) which should be combined into one

    This makes it all... it takes 5 solid hours even on my MacPro.

    Any ideas?

    All the best.

    Emanuel

    I mean other than import in a project, by adding them all in a timeline and making everything again.

    It's the only way it can be done with Adobe software.

  • Merge two documents in files to PDF, into one?

    Merge two documents in files to PDF, into one?

    Hi antoniof33712361,

    You can subscribe to the Adobe PDF package & use it will be Adobe Acrobat Reader DC to combine PDF files https://cloud.acrobat.com/combinepdf or you can purchase/subscription application Download Adobe Acrobat Acrobat products | Standard, Pro | DC, XI, X this feature.

    Kind regards
    Nicos

  • How can I connect three different files into one? Thank you.

    I need to download copies, but I need to combine into one file

    Hello

    Here is the link for the steps on how to merge several PDF' into one.

    Acrobat help. Combine files

    As shown above, you would need Acrobat for that.

    Concerning

    Sukrit diallo

  • Y at - it a safe application for concatenating several files into one .rtf?

    Y at - it a safe application for concatenating several files into one .rtf?

    Why do you do this?

    Is it arril (3D image files) or .rtf (Rich Text Format) files?

  • gather several PDF files into one

    Hello world

    I want to collect several PDF files into one form of report. What can I use as tools and hwo if possible.

    Kind regards

    I did a little cleaning in the example indicated by smercurio_fc.  You can apply this Vi (concatenate PDF LV2009.vi) in your Vi or use it as a standalone Vi.

Maybe you are looking for

  • Internet stall during sleep

    After upgrading to Mac OS Sierra I find internet connection stops outside when he sleeps and when the screen is triggered and a website accessed in Safari, it is impossible to find as the WiFi is still trying to reconnect. It reconnects after 5-10 se

  • How to import a collection of folders and subfolders containing webloc links in Safari

    Safari 9.1.2 OS 10.11.6 El Capitan I made the mistake to export my bookmarks in Safari on my desk archives. I have to manage the Archives of links with previous versions I have, over time, the Safari had lost some of the links. Now I can't import fil

  • Satellite A300 - Questions about the second HARD drive Bay

    To the underside of the laptop, there is an empty Bay for a second HDD internal.It is in the lower left corner (the first internal hard drive is on the lower side right) and the Bay has a sata connector.The plastic cover of the empty Bay extended col

  • Difference between FFT LabVIEW and Matlab FFT

    Anyone know why there is a lag in the absolute levels of the results of the function in LabVIEW and Matlab FFT? See the VI attached for an example of my code to LV. Also attached is the plot generated in Matlab, which seems to be compensated by ~ 37d

  • Aspire the XC-605 video card update

    Hi all I recently bought an Aspire XC-605 and I need help, so I hope you guys can help out me. It comes with an integrated only video card. I wanted to update the graphs so I bought a card Asus HD 6450 Silent PCIe. I installed the card and booted the