Merging and saving audio capture + file from disk

Hi,
I need to combine an audio file (read from disk) with an audio capture from a microphone and save the combined audio to a file.
I created processors for both, merged the data sources and created a processor from the merged data source.
If I use that as an input to a player, it seems to play OK : I hear the combination of the audio file and the microphone over the speakers (albeit with a delay of the microphone input).
But when I try to save this merged processor's data source (I tried 2 different ways based on samples I found) I get the following exceptions respectively
writeToFile
javax.media.NoDataSinkException: Cannot find a DataSink for: com.sun.media.multiplexer.RawBufferMux$RawBufferDataSource@121cc40
     at javax.media.Manager.createDataSink(Manager.java:1894)
     at soundTest.MergeTest4.writeToFile(MergeTest4.java:108)
     at soundTest.MergeTest4.runTest(MergeTest4.java:70)
     at soundTest.MergeTest4.main(MergeTest4.java:207)
writeToFile2:
Unable to handle format: LINEAR, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed
Unable to handle format: LINEAR, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 176400.0 frame rate, FrameSize=32 bits
Failed to realize: com.sun.media.ProcessEngine@691f36
Error: Unable to realize com.sun.media.ProcessEngine@691f36
javax.media.CannotRealizeException
     at javax.media.Manager.blockingCall(Manager.java:2005)
     at javax.media.Manager.createRealizedProcessor(Manager.java:914)
     at soundTest.MergeTest4.saveFile(MergeTest4.java:83)
     at soundTest.MergeTest4.runTest(MergeTest4.java:71)
     at soundTest.MergeTest4.main(MergeTest4.java:208
Here's the code (apologies for heavy use of static and poor error handling)
public class MergeTest4 {
       private static final Format AUDIO_FORMAT = new AudioFormat(AudioFormat.LINEAR);
       private static final int TIME_OUT = 2000;
     private static void runTest() throws Exception {
       DataSource ds1 = getCaptureDataSource();
       DataSource ds2 = Manager.createDataSource(new URL("file:///c:/temp/test.wav"));
       Processor processor1 = Manager.createProcessor(ds1);          
       Processor processor2 = Manager.createProcessor(ds2);  
       configureAndStart(processor1);
       configureAndStart(processor2);
       DataSource[] sources = { processor1.getDataOutput(), processor2.getDataOutput()};
       DataSource mergedDS = Manager.createMergingDataSource(sources);
       Processor mergedProcessor = Manager.createProcessor(mergedDS);    
       configureAndStart(mergedProcessor);
        //This works
        Player player = Manager.createRealizedPlayer(mergedProcessor.getDataOutput());
         player.start();          
         //This does not work
         //  writeToFile(mergedProcessor);
         //  writeToFile2(mergedProcessor);
    private static void writeToFile2(Processor processor) throws Exception {
          ProcessorModel outputPM = new ProcessorModel(processor.getDataOutput(),
                new Format[]{ new AudioFormat(AudioFormat.LINEAR)},
                new FileTypeDescriptor(FileTypeDescriptor.WAVE)
        MediaLocator dest = new MediaLocator("file://./rec.wav");
        Processor outputProcessor = Manager.createRealizedProcessor(outputPM);
        DataSource newDS = outputProcessor.getDataOutput();
        newDS.connect();
        newDS.start();
        DataSink dataSink = Manager.createDataSink(newDS, dest);
        dataSink.open();
        dataSink.start();
      //  dataSink.addDataSinkListener(this);
        outputProcessor.start();
     private static void writeToFile(Processor processor) throws Exception {
          StateHelper sh = new StateHelper(processor);
          if (!sh.realize(10000)) {
               System.exit(-1);
           processor.setContentDescriptor(new FileTypeDescriptor(FileTypeDescriptor.WAVE));
           MediaLocator dest = new MediaLocator("file://c:/temp/foo.wav");
           DataSink filewriter = Manager.createDataSink(processor.getDataOutput(), dest);
           filewriter.open();
           StreamWriterControl swc = (StreamWriterControl) processor.getControl("javax.media.control.StreamWriterControl");
           //set limit to 5MB
           if (swc != null) {
               swc.setStreamSizeLimit(5000000);
           try {
               filewriter.start();
           } catch (IOException e) {
               System.exit(-1);
           // Capture for 20 seconds
           sh.playToEndOfMedia(20000);
           sh.close();
           filewriter.close();
     private static DataSource getCaptureDataSource() {
          try {
               Vector captureDevices = CaptureDeviceManager.getDeviceList(AUDIO_FORMAT);
                CaptureDeviceInfo audiocaptureDevice=null;
                if (captureDevices.size() > 0) {
                     audiocaptureDevice = (CaptureDeviceInfo) captureDevices.get(0);
                } else {
                     System.out.println("Can't find suitable audio capture device.");
                    return null;
                return Manager.createDataSource(audiocaptureDevice.getLocator());
          } catch (Exception ex) {
               ex.printStackTrace();
          return null;
     private static void start(Player player) {
          player.start();
          waitForState(player, Processor.Realized);
     private static void configure(Processor p) {
          p.configure();
          waitForState(p, Processor.Configured);
     private static void configureAndStart(Processor p) {
          p.configure();
          waitForState(p, Processor.Configured);
          start(p);
     private static void waitForState(Player player, int state) {
         if (player.getState() == state) {
             return;
         long startTime = new Date().getTime();
         final Object waitListener = new Object();
         ControllerListener cl = new ControllerListener() {
             @Override
             public void controllerUpdate(ControllerEvent ce) {
                 synchronized (waitListener) {
                     waitListener.notifyAll();
         try {
             player.addControllerListener(cl);
             synchronized (waitListener) {
                 while (player.getState() != state && new Date().getTime() - startTime < TIME_OUT) {
                     try {
                         waitListener.wait(500);
                     } catch (InterruptedException ex) {
                         ex.printStackTrace();
         } finally {
             player.removeControllerListener(cl);
     Any idea what needs to be changed for this to work?
Thanks
Philippe

Drew
Now that you've got as far as doing GUIs, you must learn to read the API. Here/s a link.
Is it something like: out.textBox.text() ??
Not quite. In fact, not at all. The syntax implies that out has a member textBox which in turn has a method text. That's pretty far removed from reality, isn't it?
From the code you posted, you apparently know that out.println(...) takes a String parameter. Now go look up the API and find a method of JTextField that returns a String, that Returns the text contained in this TextComponent.
^Hint: it's a method inherited from JTextComponent^
Get the text from the JTextField and pass it as a parameter to out.println. That's all there is to it.
luck, db
Blasted multiposter didn't have the decency to indicate here that the immediate problem was resolved, just went ahead and started a [new thread|http://forum.java.sun.com/thread.jspa?threadID=5282987].
One for the little black book.
Edited by: Darryl.Burke

Similar Messages

  • Converting "FLAC" and other Audio Format files from Vuze to iTunes

    Good afternoon. I have a Mac Book computerthat I purchased about two years ago.  I have ITunes loaded on mycomputer. I use Vuze as a software program to download music and video toITunes.  However, it appears that iTunes will not concert "FLAC"and other formats of audio from Vuze. Can anyone recommend what free softwaresoftware program is preferable to use to convert the "FLAC" and otheraudio formats from Vuze to use in iTunes?  Thank you in advance for anyassistance you can provide concerning this issue.

    I have used xACT in the past, and I now use Max for all my FLAC conversion needs. If you need to tag the FLAC files before conversion, Tag is basic but good.
    For conversion inside iTunes you might want to check out Quick Convert from Doug's AppleScripts.

  • My mac disk is full and i cant transfer files from Mac to USB. saying the format is not good, how can i change the format and what happened to the files i have on USB?

    my mac disk is full and i cant transfer files from Mac to USB. saying the format is not good, how can i change the format and what happened to the files i have on USB?

    Once something similar happened to me. The external drives I had set up for FCP to use for some reason were not mounted, and FCP put all its render files on the main drive and I couldn't find them anywhere.
    Go to applications, and control-click (and hold down) on your FCP icon; you should get a pop up menu that says "show package contents". Select that, select the "contents" folder, then the "mac OS" folder. See if your quicktime file is in there, or if you've got render files in the "render" folder or audio render files in the "audio render" folder that don't belong there.
    That's where FCP sticks stuff when your documents FCP project folders are not available or when external drives you've selected aren't available.

  • Capturing files from DVD-discs

    Hi
    I'm having problems capturing files from an existing DVD ”.VOB”-files. The video is OK - but the audio is missing.
    What can I do???
    Minibikini

    VOB files are specially formatted muxed (multiplexed) MPEG-2 files. Try using MPEG Streamclip (freeware) to demux and convert the DVD's VOB files into whatever format matched your FCP Sequence settings.
    -DH

  • Cannot delete file from disk after emailling that file like attachment

    After i send some file from disk in Mail like attachment i cannot delete that file from disk unless i quit Mail. Like Mail is still using a file. Of course, that mail is in Sent mail, not in outbox.

    This deeper than that. I created another account on the same iMac and it works in Harmony with my other devices and Documents in the cloud. I can only imagine the icloud account is somehow corrupted (I am on my macbook not iMac at the moment). There have been no updates to the Calendar, Contacts or Documents since early January on that account. I have spent 1hr on the phone with support and they were baffled as well. Only thing I can gove as insight to the problem is this, I was on the Mac Mini which was backed up on Time Machine. about 4 or 5 months ago I had to completley restore the Mac Mini becasue of the never ending circle on the load screen. The Backup failed to work it kept loading the issue and 4 or 5 times the circle of death kept coming up I would subsequently wipe the Mini and go further back in the back up until I go a copy that worked.  I then loaded the Time Mache back up into my NEW iMac and wnet from there. It took about a month for this problem I am detailing above to start happening. It maybe a corrupt file loaded from the backup into the new iMac causing this problem. Best answer I can think of on my own???

  • I recently bought two iMac quad core i5 processor speed 2.5 Ghz. Every time I use Air Drop and I send a file from one iMac to the other, a black curtain drops and I am asked to restart the computer!!! What can I do?

    I recently bought two iMac quad core i5 processor speed 2.5 Ghz. Every time I use Air Drop and I send a file from one iMac to the other, a black curtain drops and I am asked to restart the computer!!! What can I do?

    That's a kernel panic and indicates some sort of problem either with the computer's hardware or software. Visit The XLab FAQs and read the FAQ on diagnosing kernel panics. It would help to post the panic log: Mac OS X- How to log a kernel panic.
    Meanwhile, try booting the computers into Safe Mode then restarting normally. If this is simply a disk repair or cache file problem then this may fix it.
    You can also try creating a new admin account on each computer then booting into the new account. This would help determine if the problem is related to a bad file in the user accounts.

  • Bug? iTunes 10 doesn't remove files from Disk sometimes

    Hi all.
    I think i figured out a bug in iTunes (10).
    Sometimes, when i select a file from library and press cmd+backspace to delete a file from disk to put it in trash, iTunes won't put the selected file into the Trash. Sometimes it does, sometimes it doesnt. Its going to be removed in the Library but its still on Filesystem so i can add it once again, and try it 2-3 times till its finally gets deleted.
    Any ideas?!
    EDIT:
    found another thread with same problem
    http://discussions.apple.com/thread.jspa?messageID=12530336&#12530336
    Message was edited by: koDiacc
    Message was edited by: koDiacc

    OK ... help myself with asking a friend ...
    Search for a few (approx. 20) files manually then iTunes found the rest itself!

  • Read sound file from disk in Java

    Write a simple application that reads a sound file from disk (use a Clip). Play the sound backwards by arranging the byte arrays/frames in the reverse order.
    Please I need an explanation of every step.
    Get some Duke Dollars for your help.

    Hi,
    When execute this code, I see this: "[Ljava.io.File;@111f71".   
    How I can see the name of the File, and How I can run a program with one by one from the files reader in a parameter ???
      Thank's.
       Hervey P.                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can I login and retrieve my user file from the trash?

    I was trying to find out where all my HD had gone, which a did using ‘What Size’.
    I found what looked like an old backup file so I put the file in the trash.
    It turns out that the file was my user file. So now I can’t login to as the user.
    How can I login and retrieve my user file from the trash?

    The Digital Editions forum is here, in case this is what you are talking about:
    http://forums.adobe.com/community/adobe_digital_editions
    If you are not, I apologize for the misunderstanding.

  • I  have a new Mac Pro computer and have migrated my files from my older computer to the new computer. In trying to open a Lightroom catalog on an external hard drive  I keep on getting the message "lightroom cannot use the catalog named " " because it is

    I  have a new Mac Pro computer and have migrated my files from my older computer to the new computer. In trying to open a Lightroom catalog on an external hard drive  I keep on getting the message "lightroom cannot use the catalog named " " because it is  not writable and cannot be opened. I have fixed all the "permissions" and yet it will still not open. How do I fix this?

    Hello Forum Members,
    I figured it out. You have to select  the actual logo of the Lightroom catalog and then click on  "get info" and allow what ever your new user name to "read and write". That worked!
    Henri Silberman

  • I had a computer crash and completed a Fresh install of Win7 and  restore of all files from Carbonite.  I have managed to get LR 5 running in LR.  However, I am not sure I have all of my previous catalogs. How can I find my catalogs to assure that I have

    I had a computer crash and completed a Fresh install of Win7 and  restore of all files from Carbonite.  I have managed to get LR 5 running in LR.  However, I am not sure I have all of my previous catalogs. How can I find my catalogs to assure that I have a complete inventory of all my catalogs.

    <moved from Downloading, Installing, Setting Up to Photoshop Lightroom>

  • Using Acrobat X and creating a PDF File from EXCEL 2010, I notice that the Pagination restarts at 1 for each Worksheet included in the PDF.

    I use Acrobat X Standard and created a PDF file from two or more worksheets using EXCEL 2010.
    The resulting PDF file restarts the PAGE # (In header/footer settings of Excel) at 1 for each worksheet.
    However, a colleague of mine who has Acrobat X Pro version, using EXCEL 2010 and same exact file does the same task, he gets a file that starts at page 1 and second worksheet continues the page # from the last page of the First worksheet.
    We both are using the ACROBAT menu (not the print to Adobe printer) to create the file so that we can get Bookmarks included in the resulting file for each worksheet.
    We cannot figure out any option in Acrobat's preferences that controls the pagination on either of these versions of Acrobat.
    So is this just a feature that works one way in Standard version and another way in the Pro version, and the user has no control over it?

    This is so sad. I read your comments and I said, "Huh?" Haha!
    I tried the indexed color option and it did make the final file smaller. Around 600KB. But there's probably another way to make it even smaller like the gazillion-paged pdf file that I mentioned that was only about 300KB.
    And by saying a layout program, does that mean like Adobe InDesign? Does that mean that I should just make my graphics in Photoshop and then import using another program and finish the file there?
    What other layout programs can I use?
    Thank you so much!

  • I just received my new Mac Mini and want to migrate files from my Time Machine. I assume the old OS is on Time machine and I don't want it to supersede the new Yosemite OS. Do I have to Do anything special?

    I just received my new Mac Mini and want to migrate files from my Time Machine. I assume the old OS is on Time machine and I don't want it to supersede the new Yosemite OS. Do I have to Do anything special?

    Using Migrations Assistant will only move the data and other things over, it will not bring over a previous version of the Os since the 2014 model can run anything earlier than Yosemite.

  • Can Anyone help with syncing my contacts are getting duplicated and there is a file from my computer and they are not the same it is driving me carazy can anyone help?

    Can Anyone help with syncing my contacts are getting duplicated and there is a file from my computer and they are not the same it is driving me carazy can anyone help?

    Are you in DSL? Do you know if your modem is bridged?
    "Sometimes your knight in shining armor is just a retard in tin foil.."-ARCHANGEL_06

  • How to compile and run a .java file from another java program

    hello,
    can any one tell me how to compile and run a *.java* file from another java program which is not in same directory?

    Well a smarter way of implementing this is by using a solution provided by Java Itself.
    If you are using J2SE 6.0+ there is an in built solution provided along with JDK itself and inorder to go ahead with solution the below are set of API which you;d be using it for compiling Java Programs (Files)
    http://java.sun.com/javase/6/docs/api/javax/tools/package-summary.html
    How do i do that ??
    Check out the below articles which would help you of how to do that
    http://www.ibm.com/developerworks/java/library/j-jcomp/index.html
    http://www.javabeat.net/javabeat/java6/articles/java_6_0_compiler_api_1.php
    http://books.google.com/books?id=WVbpv8SQpkEC&pg=PA155&lpg=PA155&dq=%22javax+tools%22+compiling+java+file&source=web&ots=XOt0siYe-f&sig=HH27ovuwvJgklIf8omTykUmy-eM
    Now once we are done with compilation.In order to run a Specific class all you ought to do is create an object and its specific methods of a specified class included in the CLASSPATH which you can manage it easily by usage little bit reflections.
    Hope that might help :)
    REGARDS,
    RaHuL

Maybe you are looking for

  • Problem executing function

    Hi All, I have a problem executing a function in oracle 10g. I am getting an error while executing .... Here is a function along with the error i am getting: create or replace FUNCTION UnpackArray Source IN VARCHAR2 DEFAULT NULL, Delimiter IN CHAR DE

  • How can I install Adobe Acrobat without installing the browser extensions?

    Hello All, I am a computer Technician at a high school and we have very strict browser requirements for different services. We need to use Adobe Acrobat to convert PDF's, and other tasks, and we need to use Chrome to open Adobe Reader files. The issu

  • Dual Monitor issue - Open file to 2nd monitor?

    I have a dual monitor setup in Windows 7 and like to work with all the tool panels and PS main window on the left monitor and the photo open full screen on the right. I have tried saving the workspace with the image open full screen on the right moni

  • RCA for Oracle RAC Performance Issue

    Hi DBAs, I have setup a 2 node Oracle RAC 10.2.0.3 on Linux 4.5 (64 bit) with 16 GB memory and 4 dual core CPUs each. The database is serving a web application but unfortunately the system is at its knees. The performance is terrible. The storage is

  • Oracle Forms requires JRE 1.4.2_06, how do I uninstill newer versions

    Hi, The Oracle Forms that we use require JRE 1.4.2_06, they will not run in the most recent version of the JRE. How am I supposed to uninstall the newer versions? I went into the control panel and uninstalled them through there and rebooted, but the