Combining 2+ WAV Files into a single WAV file

Hello there,
I am trying to combine at least 2 WAV files (my example uses 3) into a single file. I have 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 to have been joined.
Here is the code for the simpler of the 2 examples which I have altered to meet 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 don't see any problem with your actual code in terms of JavaSound, but...
The first run through, you'd be concating "file1.wav" and "file2.wav" to a file called "concat.wav". The second time through, you'd be concating "concat.wav" and "file3.wav" to a file called "concat.wav"...
On the second iteration, "concat.wav" will have a read-lock put on it until such time as the sequence input stream releases it... which will occur as soon as it's done reading it. At that point, the read lock is released and you can obtain a write-lock on it, but, you've already dumped all of the data from concat.wav into the bit bucket...so the only thing that gets to go in there now is "file3.wav".
So, don't try to read from and write to the same file at the same time...

Similar Messages

  • How do you combine 2 mono tracks into a single stereo track?

    Question here:
    How do I combine 2 mono tracks into a single stereo track in Logic?
    I recorded using my left and right out of my keyboard to a hard-disk recorder (Korg d888). The files are made as two separate wav files. Is there way to combine these in Logic so I can treat it as one stereo track?
    I have several files to do and am hoping Logic has something like a "combine tracks to stereo track" tool or something.

    Solo both tracks and bounce them with no effects and faders at 0 dB.

  • Is there a way to combine their query results into a single function

    say I have a bunch of functions that return a query:
    <cffunction name="getDeals" access="remote"
    returntype="query">
    <cffunction name="getDeals2" access="remote"
    returntype="query">
    is there a way to combine their query results into a single
    function that returns a struct of the various results?

    Umm, it's probably more suited to an array - effectively
    making it into a list of queries. You'd then loop the array and
    output each.
    I use a similar approach when creating system messages to the
    user. Most of my functions that are called do their bit, then at
    the end call another function I call "messages". This function
    grabs whatever my function sends and appends it to a messages
    array.
    This way enables me to output a long list of messages -
    because I could be calling several functions at the same time. If I
    just output a message from each function, each one would overwrite
    the other. So I'd get one message at a time.
    Immediately after it's output, I then destroy the message
    array so that old messages aren't kept inside of it.
    Mikey.

  • How to combine 2 spool id into a single PDF file

    Hi,
    I need to combine 2 or more spool id into a single PDF file.
    i.e the downloaded PDF file should contain the data of all the specified spoll ids
    Thank U
    Narendra

    Hi,
    Use FM "RSPO_RETURN_ABAP_SPOOLJOB" to get the spool into internal table.
    Append the internal table with data of another spool & then pass the internal table to the FM mentioned in above reply.
    Best regards,
    Prashant

  • How can I combine multiple icloud calendars into a single published calendar?

    I have several calendars in Ical where I map my activities and schedules. Like many I need several calendars to categorise events.
    Now, I'd like others to see when I'm free and when I'm unavailable. For this, I'd need to find a way to copy multiple Icloud calendars into a single one for publishing - and the published calendar would also have to sync to any update I make in the original calendar.
    Any way to make this happen? Any third party app? Tried a couple - they were outdated and / or cumbersome.
    If only there was a "smart calendar" tool in Ical …

    It worked - up to the crucial point: after combining icloud calendars into one "on the machine" calendar, the latter is ready for going public. But of course - this public calendar will only contain the .ics files and will not sync for updates from the icloud calendars.
    And that's what I want.
    If this problem is not possible to solve with the software available in the Mac - is there any known third party solution for this?
    (Apple: "smart calendars" please!)

  • Combining two mono clips into a single mono clip

    I have two mono clips (two different takes of the same vocal part) that I want to combine into a single mono clip in Multitrack.  I tried the Bounce feature, but it produced a stereo file (which I don't want) and I think there isn't a mono option in Bounce.  So then I tried Mixdown to New File, and that produced a stereo file too.   So, what's the way to get the mono file I want, and which is better for the job - Bounce, or Mixdown?

    I recently filed two bug reports around bouncing tracks.  I noted that bounces were always created to match the Master track channelization, not the source track, and that they appeared to be passing through the Master when they should be the raw track output. 

  • Combining multiple pdf pages into a single document

    I realize this is probably an inappropriate request -- probably? almost certainly -- for this forum, but perhaps someone can refer me to another source for a solution.
    I would like to combine several pages individually scanned to pdf format into a single pdf document. How do I do that? (I have only Adobe Reader. I do not have any applications for creating and editing pdf pages.)
    Hope you'll forgive the inappropriate request, and thanks to anyone who can refer me to a more appropriate source.
    Sincerely,
    Eric Weir

    I would like to combine several pages individually scanned to pdf format into a single pdf document. How do I do that?
    You already have the application installed -- Preview. Whether the source files are single page or multipage documents, whether they are all on size/orientation or come in multiple dimensions/orientations, simply ...
    1) Open each in a separate Preview window,
    2) Open the "sidebar" for each window,
    3) Drag one or more icon pages from any of the source Preview sidebar windows to your target Preview sidebar window,
    4) Arrange the order of the pages in the target sidebar window as desired, and
    5) Save resulting document under a new name using the "Save As..." File menu option.
    ADDED: Oops! Too slow. Someone else beat me to it...

  • Can you combine multiple itunes accounts into a single one?

    I set up separate itunes accounts for my (2) sons (8 & 10) because one had an iPod and the other had an iTouch. 
    They just got an iPad for X-mas (that they'll share) ... I want to set up the iCloud and create a "joint" account. 
    Is it possible to combine their multiple itunes acounts into a single account?

    This is all i know but all you can do is just creat a new one for them both and send all the stuff to the one think u can do that i hope it helps

  • Combine 2 internal tables into a single internal table

    Hi
    I need to replace the following join statement by splitting it into 2 select statements and then combine them into a single internal table
    SELECT  vbak~waerk
    vbapvbeln vbapposnr vbapnetwr vbapbrgew
    vbap~erdat                         "IM152805
    INTO CORRESPONDING FIELDS OF TABLE l_t_orders
    FROM vbak INNER JOIN vbap ON vbakvbeln = vbapvbeln
    FOR ALL entries IN t_mchb
    WHERE vbap~vbeln = t_mchb-vbeln
    AND vbap~posnr = t_mchb-posnr.
    Need to replace the above with separate select statements and then combine the result into a single internal table...
    could anyone please help me...
    thanks in advance

    Hi,
    Check the code below,
    select vbeln waerk
    from vbak into table it_vbak for all entries in t_mchb  where vbeln = t_mchb-vbeln.
    select posnr
         netwr
         brgew
         erdat "IM152805
    INTO TABLE it_vbap
    for all entries in t_mchb
    where vbeln = t_mchb-vbeln
    and posnr = t_mchb-posnr.
    loop at it_vbap into wa_vbap.
    read table it_vbak into wa_vbak where vbeln = wa_vbap-vbeln.
    if sy-subrc = 0.
    l_t_orders-waerk = wa_vbak-waerk.
    l_t_orders-vbeln = wa_vbap-vbeln.
    l_t_orders-posnr = wa_vbap-posnr
    l_t_orders-netwr   = wa_vbap-netwr.
    l_t_orders-brgew   = wa_vbap-brgew.
    l_t_orders-erdat   = wa_vbap-erdat.
    append l_t_orders.
    endif.
    endloop.
    Reward if it is helpful.
    Regards,
    Bhanu

  • How to combine  two user prompts into 1 single prompt from two Webi Queries

    Hi All,
    I developed a single webi report from two different queries on top of 2 BW OLAP universe .
    Here I have one user input prompt for each query so I want to combine them into one single user input promt which  should pass the user input value to both the Webi queries feeding data to the  single webi report.
    I found that the webi doc has auto checked merge dimensions enabled but it is not providing combined resluts from both the queries .
    Any inputs are greatlt appreciated.
    Thanks

    Stratos
    Firstly ,I appreciate your responses for my two questions.
    Both the prompts I am using are from the masterdata and they are similar.data types.I think the transactional data is not available in BW for one of the prompt ,hence I am not getting consistent data.
    Anyway will do further investigation in finding similarities and let you know.
    Thanks a lot

  • How to combine Submit and Commit into a single operation?

    JDev 11.1.1.6
    Is there a simple way to combine Submit and Commit or Create and Commit or Delete and Commit into a single operation without creating a custom Operation class?
    Thanks,
    PeeVee

    Have a button and in the action listener event..you should drag and drop both create & commit onto your page so that it will have the required bindings in the pagedef.
    OperationBinding createOperationBinding = ADFUtils.getOperationBindingForMethod("Create");
    createOperationBinding.execute();
    OperationBinding commitOperationBinding = ADFUtils.getOperationBindingForMethod("Commit");
    commitOperationBinding.execute();

  • How to combine 20 identical shots into a single composite image

    I want to shoot a moving water scene with a tripod mounted Canon DLSR and take +/- 20 images from the exact location and then combine them into a single composite shot in photoshop CS6.  How do I go about this?

    It sounds like you want to do image stacking. See Photoshop Help | Image Stacks (Photoshop Extended).

  • Combine several pdf docs into one single pdf doc

    I need to combine several pdf's into one pdf. How can I do this?

    Or with non-Adobe programs that you may find by Googling...

  • Combining two Apple IDs into a single account

    I couldn't find what other forum to post this question in. Please direct me to one if there is one. Thanks.
    I've accidentally created two Apple IDs and registered various hardware on each. I want to combine the two accounts into one.
    How can I do that?

    Hello,
    Unfortunately, you cannot do that.
    We just don't have that option here. My recommendation would be to use whichever account you prefer the most.
    If you have points of concern to you on the other account, then use it.
    You can adjust either account to your own preferences. So, the only difference between one and the other will be the user name and registration date that is attached to it (which cannot be changed) and the number of posts and awarded points for questions you have answered.
    I wish I could give you the answer you are wanting. But, unfortunately that just is not an option.
    Edit:
    I just found that someone else has been discussing something similar here:
    http://discussions.apple.com/thread.jspa?threadID=668526&tstart=0
    You may find that discussion useful as well when considering the limitations and other factors that are affected.
    I hope this helps.
    Message was edited by: mhunter

  • Can I combine or merge songs into a single album?

    When I view my albums in iTunes, many are fragmented into several albums. This is especially true for albums that contain songs by several artists, like "Saturday Night Fever" but also for albums by the same artist like "Future Shock" by Herbie Hancock. the track "Rockit" appears as the single entry (track 1) for one album, and tracks 2-6 appear as a second album.
    I've tried dragging and cut/pasting and can't seem to get the songs onto one album. This is especially frustrating for albums like "Saturday Night Fever" where it appears in iTunes as almost a dozen albums with one track each.
    Message was edited by: lbeck

    This shouldn't have been that complicated, but I had to stumble across the tick box for "is compilation"
    * I have "edit/preferences.../advanced/group compilations when browsing" box checked but the individual tracks in a compilation still show up as separate albums. Didn't help
    * Got joy only after fincing and checkint the compilations box in the GEt Info/Info box for each song in the compilation
    Thanks for getting me on the right road. The iTunes HELP files were no help

  • Palm Desktop - combining 2 user views into 1 single view

    I know the Palm Desktop was designed to allow multiple users to synchronize with one copy of Palm Desktop, each with discrete username areas.  On the Palm Desktop, is there any way to combine the individual views of 2 users calendars into 1 view in order to see 1 combined calendar with both sets of appointments?
    Post relates to: Treo 755p (Sprint)

    Hi, and welcome to the Palm Community Forums.
    You can do that with the use of a third-party application called SyncUs.  It allows multiple Palm OS devices with distince Hotsync IDs to share whichever databases you wish to share.  I've never tried it, but it seems to get good reviews.
    Post relates to: None
    smkranz
    I am a volunteer, and not an HP employee.
    Palm OS ∙ webOS ∙ Android

Maybe you are looking for