Saving a recording in  memory and in disk at the same time.

Hi, I record audio and a I want to save it in memory,then when the user presses a stop button I have to save the audio that is in buffer to a directory file. So far I to the first part that is save in memory. Here is some code I use:
{color:#0000ff}
class {color:#000000}recording{color} extends {color:#000000}Thread{color}*{*
* boolean {color:#339966}suspended{color};*
* public void* {color:#000000}run{color}*(){*
* try{*
* while*{color:#000000}(!{color}{color:#339966}*suspended*{color}{color}{color:#000000})
{color} File *{color:#339966}file{color}*={color:#0000ff}*new*{color} File*{color:#ff9900}("C:/prueba.wav"{color}*);
ByteArrayOutputStream {color:#339966}*dataCapturada*{color}={color:#0000ff}*new*{color} ByteArrayOutputStream();
byte *{color:#339966}bufferTemporal{color}*[]={color:#0000ff}*new* {color}byte[10000];
{color:#0000ff} int {color}numbytesleidos=*{color:#339966}targetDataLine{color}*.read(*{color:#339966}bufferTemporal,{color}*0,{color:#339966}*bufferTemporal.length*{color});
datacapturada.write*{color:#339966}(bufferTemporal{color}*,0,{color:#339966}*numbytesleidos*{color});
}{color:#0000ff}*catch*{color}(Exception e){e.printStackTrace()}
So far,this works perfectly, but i put this line of code to save in directory file after the line:datacapturada.write....
AudioSyste.write(*{color:#0000ff}new{color}* AudioInputStream({color:#339966}*targetDataLine),*{color}AudioFileFormat.Type.*{color:#339966}WAVE{color}*,*{color:#339966}file{color}*);
It saves file in the directory file,but doesnt save in memory. Why could this be??

Ok sorry, as you had seem in other forums, meaning JMF,I decided to record from microphone in WAVE format. This is done, but I also have to show the volume in a progress bar. So I take and example and it works, but this method that calculate volume needs an array of bytes, that is the array that I use for record in memory.So record in memory and show a progress bar volume works, but I also have to save in directory file. My idea is to save in memory and save in file directory at the same time, or save in memory and then when I press a stop button transfer the data saved in memory to the directory file.Here is all the code,assume that all declarations have been done:
public void capturarAudio() {
       try {        
            formatoAudio = obtenerFormatoAudio();
            DataLine.Info lineaDataInfo = new DataLine.Info(TargetDataLine.class,formatoAudio);
            linea = (TargetDataLine) AudioSystem.getLine(lineaDataInfo);
            linea.open(formatoAudio);
            linea.start();
            Thread hiloGrabacion=new Thread(new hiloGrabacion());
            hiloGrabacion.start();
       } catch (LineUnavailableException ex) {
            Logger.getLogger(InformDetail.class.getName()).log(Level.SEVERE, null, ex);
class hiloGrabacion extends Thread{
        byte bufferTemporal[] = new byte[10000];
        File archivo=new File("C:/Documents and Settings/java/multimedia/audio.wav");
        @Override
        public void run(){
            dataCapturada     = new ByteArrayOutputStream();
            detenerGrabacion  = false;
            try{
                while(!detenerGrabacion){
                    int numBytesLeidos=linea.read(bufferTemporal,0 , bufferTemporal.length);
                    if(numBytesLeidos>0){
                        dataCapturada.write(bufferTemporal, 0, numBytesLeidos);
                        mostrarVolumen(bufferTemporal,0,numBytesLeidos);
                        lblCronometro.setText(linea.getMicrosecondPosition()/1000000+"");
                AudioSystem.write(new AudioInputStream(linea), AudioFileFormat.Type.WAVE, archivo);
                dataCapturada.close();
            }catch(Exception e){
                e.printStackTrace();
    }

Similar Messages

  • Can I use the time capsule as backup and hard disk at the same time?

    Hi.
    I want to buy a time capsule.
    I wondered, if I can use the time capsule as backup (over time machine) and as a hard disk at the same time?
    If I buy the 2TB time capsule, I wanted to use 1TB for the backup and 1TB for hard disk.
    Is this possible?
    Best wishes
    Sophie

    It is not recommended.. the problem being anything stored on the TC only is not backed up and cannot be backed up by the TC itself or Time Machine. So what are you going to do about back.. the TC can and do die suddenly.. and the cost of recovery can be huge.
    See Q3 here for the semi-right way to do it if you must.
    http://pondini.org/TM/Time_Capsule.html
    You can plug a USB drive into the TC and use that for files.. but note, its speed is poor.. fine for wireless as wireless is even slower but you will really notice it if you expect the drive to be as fast as the internal.. it will be a fraction of the internal drive speed. 1/2 write and 1/3 read aprox.
    See http://www.anandtech.com/show/4577/airport-extreme-5th-gen-and-time-capsule-4th- gen-review-faster-wifi-/7

  • How can I record a microphone and software instrument at the same time in Garageband 10.0.1?  It seems I can record one or the other, but not both at the same time?

    I am trying to record a vocal mic and a keyboard (using a software instrument) at the same time using Garageband 10.0.1.  It seems that I can't record the mic input and the software instrument at the same time.  I can record the mic input by itself, and I can record the software instrument by itself (if I don't have a mic input track created), but I can't record them together.
    It seems like this should be an obvious thing to be able to do, but I can't figure out how to make it work.
    Can someone help?
    Thanks,
    Kurt

    Kurt1997 wrote:
    I am trying to record a vocal mic and a keyboard (using a software instrument) at the same time using Garageband 10.0.1.
    you need to "record enable" both tracks:
    http://www.bulletsandbones.com/GB/GBFAQ.html#multitrackrecordinggbv10
    This FAQ entry offers a Minute GarageBand video tutorial
    (Let the page FULLY load. The link to your answer is at the top of your screen)

  • RMAN backup to write on tape and disk in the same time

    Hi all,
    I want to take backup using RMAN and to have the backup file in a tape and a disk, i know i can allocate channel for tape, or disk. My question is can i use the both disk and tape in an rman backup one time. I mean i want to have rman writing backup file in a local disk and a tape in the same time to have redoundant backup at a tape and local disk.
    If some scripts is there, it will be welcome.
    Thanks
    Raitsarevo

    See Duplexing backup sets.

  • Recording and playing Audio at the same time

    Hi,
    Having problem with a MMAPI imp.
    The simplest way of doing it is to start one thread playing a audio file of any kind.. As it is playing start a other thread that start a audio recording.
    As soon as the audio recording is allowed to record (Security promt) the audio playback stops. And the playerListstner sends a END_OF_MEDIA event.
    So my question is: Is there a way of doing playback and recording at the same time or is this a limit on the phone or the MMAPI?
    This has been tested on Nokia N90 and SE W550i with same reults
    Cheers
    Kenth

    i also desperately need to record and play audio at the same time.. i have a term project, i am develeoping a karaoke player in j2me and it is supposed to capture the voice at the same time background song is played.. and it is also supposed to grade the singer according to the pitch of voice.. please help me about recording and playing audio at the same time...

  • Can i run remote memory profiling and remote debugging at the same time .

    can i run remote memory profiling and remote debugging at the same time .
    i am using jdev9.0.5 and oc4j9.0.4 standalone server.
    how to write the batch file to run both at the same time

    Thanks for your help!
    Another question. How do you turn off the ATT wireless transmitter? Also, there are more computers connected to the 2Wire network. I will have to set up a wireless pc to work with the Base Station after disconnecting the ATT transmitter. Easy answers for both, I hope?

  • Problem connecting Firewire device and external HD at the same time

    Hi. I'm attempting to record digital audio through a Presonus Firepod A/D interface via a Firewire 400 to 800 cable connected to one of the Firewire 800 ports on a mid-2010 Mac Pro running Snow Leopard.
    The problem is that if I have an external HD connected to one of the other Firewire 800 ports on the computer and powered on at the same time, the connection to the Presonus Firewire device is not recognized by the Mac Pro. Not only that, performance of the Mac Pro is affected adversely and System Profiler is unable to list any Firewire devices. If I turn the external HD off, the Presonus device is recognized and listed in System Profiler and the machine runs fine. I'm able to connect two external hard drives via separate Firewire 800 ports on the Mac Pro and both drives mount w/ no problem. It's only when I try to connect one of the external HDs and the Presonus audio device at the same time that the problem occurs.
    I used this same arrangement on a PowerMac G5 running Tiger w/ no problems whatsoever. If the 400 to 800 cable is bad, I would think it wouldn't work at all, but it does when only the Presonus Firepod is connected and powered on. Any ideas?

    Have done more research and apparently this is not an uncommon problem: overloading the Firewire bus when connecting an audio device along with an additional device like an external hard drive. As I understand it now, audio signal is a bandwidth hog and the solution is to get a Firewire PCIe card which will have its own independent Firewire bus and which I'll use exclusively for my audio device.

  • 10.3 and 8.1 at the same time

    I'm trying to run 10.3 and 8.1 at the same time and have had no luck so far.
    I have:
    installed 10.3 in a new directory, C:\bea103
    I'm running 8.1 in the default C:\bea
    changed the point base ports in 8.1
    changed the http/https ports in 8.1 to 8001/8002
    any ideas on what else I should do?
    I can start on or the other. When 10.3 is running 8.1 outputs the following to the console (Class paths have been chopped for length and the start command edited for legibility):
    JAVA Memory arguments: -Xms96m -Xmx256m
    WLS Start Mode=Development
    CLASSPATH=;<Cut for length>
    PATH=<Cut for length>
    * To start WebLogic Server, use a username and *
    * password assigned to an admin-level user. For *
    * server administration, use the WebLogic Server *
    * console at http:\\hostname:port\console *
    starting weblogic with Java version:
    Error [2] in bind() call!
    err:: No such file or directory
    Socket transport failed to init.
    Transport dt_socket failed to initialize, rc = -1.
    ERROR: No transports initialized
    Starting WLS with line:
    C:\bea\JROCKI~1\bin\java
         -jrockit
         -Xdebug
         -Xnoagent
         -Xrunjdwp:transport=dt_socket,address=8453,server=y,suspend=n
         -Djava.compiler=NONE
         -Xms96m
         -Xmx256m
         -Xverify:none
         -ea
         -da:com.bea...
         -da:javelin...
         -da:weblogic...
         -Dplatform.home=C:\bea\WEBLOG~1
         -Dwls.home=C:\bea\WEBLOG~1\server
         -Dwli.home=C:\bea\WEBLOG~1\integration
         -Dlog4j.configuration=file:C:\bea\WEBLOG~1\common\lib\workshopLogCfg.xml
         -Dweblogic.management.discover=true
         -Dweblogic.ProductionModeEnabled=
         -Dejbruntime.database=pointbase44
         -Dweblogic.security.SSL.ignoreHostnameVerify=false
         -Dwlw.iterativeDev=true
         -Dwlw.testConsole=true
         -Dwlw.logErrorsToConsole=true
         -Dweblogic.Name=portalServer
         -Djava.security.policy=C:\bea\WEBLOG~1\server\lib\weblogic.policy weblogic.Server
    Error [2] in bind() call!
    err:: No such file or directory
    Socket transport failed to init.
    Transport dt_socket failed to initialize, rc = -1.
    ERROR: No transports initialized
    Stopping the Weblogic Workshop debugger...
    === Debugging ===
    This window is necessary for debugging code using WebLogic Workshop
    Debugger Stopped.
    Stopping Pointbase server...
    Pointbase server stopped.
    Here is the console output when 8.1 is running and I try and start 10.3 (edited as above):
    JAVA Memory arguments: -Xms512m -Xmx1024m -XX:CompileThreshold=8000 -XX:PermSize=256m -XX:MaxPermSize=512m -XX:MaxPermSize=160m -XX:MaxPermSize=192m
    WLS Start Mode=Development
    CLASSPATH=;<Cut for length>
    PATH=<Cut for length>
    * To start WebLogic Server, use a username and *
    * password assigned to an admin-level user. For *
    * server administration, use the WebLogic Server *
    * console at http:\\hostname:port\console *
    starting weblogic with Java version:
    Cleaning up license and uid files
    Starting Autonomy with CONTENT_SEARCH_OPTION = full
    Autonomy Distributed Search Handler engine started.
    FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
    ERROR: transport error 202: bind failed: Address already in use
    ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
    JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
    Starting WLS with line:
    C:\bea103\JDK160~1\bin\java
         -client
         -Xdebug
         -Xnoagent
         -Xrunjdwp:transport=dt_socket,address=8453,server=y,suspend=n
         -Djava.compiler=NONE
         -Xms512m
         -Xmx1024m
         -XX:CompileThreshold=8000
         -XX:PermSize=256m
         -XX:MaxPermSize=512m
         -XX:MaxPermSize=160m
         -XX:MaxPermSize=192m
         -Xverify:none
         -da:org.apache.xmlbeans...
         -ea
         -da:com.bea...
         -da:javelin...
         -da:weblogic...
         -ea:com.bea.wli...
         -ea:com.bea.broker...
         -ea:com.bea.sbconsole...
         -Dplatform.home=C:\bea103\WLSERV~1.3
         -Dwls.home=C:\bea103\WLSERV~1.3\server
         -Dweblogic.home=C:\bea103\WLSERV~1.3\server
         -Xmx1024m
         -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0
         -Daldsp.home=C:\bea103\odsi_10.3
         -Djavax.xml.soap.MessageFactory=weblogic.xml.saaj.MessageFactoryImpl
         -Dweblogic.wsee.bind.suppressDeployErrorMessage=true
         -Dweblogic.wsee.skip.async.response=true
         -Dwcb.properties.url="file:///c|/bea103/user_projects/domains/WCB_Developer_Domain/app
         -parms/"
         -Dlog4j.configuration=file:C:\bea103\USER_P~1\domains\WCB_DE~1\apacheLog4jCfg.xml
         -Dweblogic.management.discover=true
         -Dwlw.iterativeDev=true
         -Dwlw.testConsole=true
         -Dwlw.logErrorsToConsole=true
         -Dweblogic.ext.dirs=C:\bea103\patch_wlw1030\profiles\default\sysext_manifest_classpath;C:\bea103\patch_wls1030\profiles\default\sysext_manifest_classpath;C:\bea103\patch_wlp1030\profiles\default\sysext_manifest_classpath;C:\bea103\patch_wli1030\profiles\default\sysext_manifest_classpath;C:\bea103\patch_cie670\profiles\default\sysext_manifest_classpath;C:\bea103\patch_alsb1030\profiles\default\sysext_manifest_classpath;C:\bea103\patch_aldsp1030\profiles\default\sysext_manifest_classpath;C:\bea103\wlportal_10.3\p13n\lib\system;C:\bea103\wlportal_10.3\light
         -portal\lib\system;C:\bea103\wlportal_10.3\light
         -portal\lib\system;C:\bea103\wlportal_10.3\light
         -portal\lib\system;C:\bea103\wlportal_10.3\portal\lib\system;C:\bea103\wlportal_10.3\info
         -mgmt\lib\system;C:\bea103\wlportal_10.3\analytics\lib\system;C:\bea103\wlportal_10.3\apps\lib\system;C:\bea103\wlportal_10.3\info
         -mgmt\deprecated\lib\system;C:\bea103\wlportal_10.3\content
         -mgmt\lib\system
         -Dweblogic.alternateTypesDirectory=C:\bea103\wlportal_10.3\portal\lib\security
         -Dweblogic.Name=AdminServer
         -Djava.security.policy=C:\bea103\WLSERV~1.3\server\lib\weblogic.policy weblogic.Server
    FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
    ERROR: transport error 202: bind failed: Address already in use
    ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
    JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
    Stopping PointBase server...
    PointBase server stopped.
    \Windows was unexpected at this time.
    So I'm stuck, can any one point me to some documentation or anything at all to get me moving forward on this?
    Thanks
    John

    Hi
    Did you change this 8453 to someother value for one of the domains. This looks like a Pointbase DB Debug Port. First change main pointbase db port and then change this debug port value also in setDomainEnv.cmd file.
    HTH
    Ravi Jegga

  • IMac can't running any two fire wire hard disks at the same time . which

    iMac can’t running any two fire wire hard disks at the same time . which two hard disks have extra power from power socket . If i just insert one of them .No problem . If connect two Hds at the same time. Leopard cant find it and the Hds seem no problem. the machine must be restarted and then use one . No problem . I have formated the HD many times .even if which format is Fat 32 or Mac issue persists .Boot from installation CD used the disk utility . Issue stills . If i used one fire wire HD that get power from power socket and used one fire wire device . Leopard was no problem during this time . Whether is this design problem or my machine hardware problem?My Mac has been changed the logic board by Apple service . Do you have similar case in here????
    Message was edited by: KennyG1983

    Hi KennyG1983-
    How are you connecting these drives?
    This may help: What to do if your computer won't recognize a FireWire or USB device
    Luck-
    -DaddyPaycheck

  • Mac Pro can't running two fire wire hard disks at the same time .

    Mac Pro can’t running any two fire wire hard disks at the same time . which two hard disks have extra power from power socket . If i just insert one of them .No problem . If connect two Hds at the same time. Leopard cant find it and the Hds seem no problem. the machine must be restarted and then use one . No problem . I have formated the HD many times .even if which format is Fat 32 or Mac issue persists .Boot from installation CD used the disk utility . Issue stills . If i used one fire wire HD that get power from power socket and used one fire wire device . Leopard was no problem during this time . Whether is this design problem or my machine hardware problem?My Mac has been changed the logic board by Apple service . Do you have similar case in here????

    I connect both hard disks that get power from power supply normally. Also have ever changed the format as GUID. Which always use the power cord . I felt confusion why the issue just happened connect both hard disks with extra power at the same time. If i used one hard disk connect to firewire port . Another firewire port connect other firewire device . No problem at all.

  • How to transform a layer object and a path at the same time?

    Hi all,
    I know I am going to kick myself when you tell me the answer to this!
    I would really like to know if there is any way I can manage to to transform both a layer object and a path at the same time....or if there is any workaround to achieve this.
    In a nutshell, say for example I spend a VERY long time creating an intricate path around a very detailed object, and then at the very end notice just how crooked and out of perspective it is, and would like to straighten it.
    Of course I could transform and correct the object, and then carefully transform the path - but it just won't be exact, and I will have to spend a long time adjusting the path and making SURE it is perfect.
    Isn't there any way I could get to transform them together?
    Usually of course I do all the correction to straighten and correct perspective beforehand, but in some instances after I am done creating the path I then notice that the image could have used further adjustments.
    I appreciate so very much any advice you may have:)
    Thank you kindly,
    Christine

    Okay...I found another way as well... suddenly it all started coming to me in the last few minutes:)
    Once the image is on it's own layer, then we can select the path and then make a vector mask by going to "Layer>Vector Mask>Current Path". Once the vector mask is created, simply click on the image icon on it's layer, then transform away to your heart's content, and the path is transformed along with it. Once finished, the path for the vector mask can be saved as usual. (Don't click on the vector mask icon when transforming the image, otherwise only the path will be transformed.)

  • HT1153 Can I sync my Apple Bluetooth keyboard with Mac G5 , iPhone5 and Apple TV at the same time ?

    Can I sync my Apple Bluetooth keyboard with Mac G5 , iPhone5 and Apple TV at the same time ?

    Thank's for the help, my only choice is to buy 2 more keyboards .
    Too bad that there is no memory to recall different channels of Bluetooth.

  • Export and import audio at the same time

    im trying to export audio from my macbook pro to a mixer then import it back in to webstream it

    i also desperately need to record and play audio at the same time.. i have a term project, i am develeoping a karaoke player in j2me and it is supposed to capture the voice at the same time background song is played.. and it is also supposed to grade the singer according to the pitch of voice.. please help me about recording and playing audio at the same time...

  • Hi there guys i got an ipod 4 generation last yr in August and it dosent turn on properly it shoes the apple and freezes ive even tried clicking off and home button at the same time but still no outcome pleas help thanks guys

    Hi there guys i got an ipod touch 4 generation last yr it turns on and shows the apple but then freezes ive even tried to click the home button and on button on the same time but it restarts and freezes at the apple any suggens to fix it guys please thanks heaps guys

    Try #2 and #3 in link below. If neither work, you most likely have a hardware issue.
    Basic troubleshooting steps  
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101
     In Memory of Steve Jobs 

  • HP Pavilion dv2000 headphones and speaker playing at the same time

    Good Day HP
    Sir/Ma'am,
     I have a HP Pavilion dv2000 laptop that run in Windows 7 Professional 64bit. I have problem with this because my internal speaker and headphone playing at the same time. And i notice that when i go to sound setting my headphone is not detected but it is still playing together with the speaker and only the internal speaker is only appearing at sound setting. I try to install RealTek that is compatible to my o.s but not working. Do i need to downgrade it to Xp or Vista to solve this problem or there are some solution for this problem. Please help me i'm not technician to fix this problem.
    And please forgive me for my bad english..
    Here are the system properties of my laptop.
    Windows 7 Professional Service Pack 1
    Processor : Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz
    Installed Memory (RAM) : 1.00 GB
    System Type: 64-bit operating system

    HP Pavilion dv2000 headphones and speaker playing at the same time
    germanok wrote:
    Good Day HP
    Sir/Ma'am,
     I have a HP Pavilion dv2000 laptop that run in Windows 7 Professional 64bit. I have problem with this because my internal speaker and headphone playing at the same time. And i notice that when i go to sound setting my headphone is not detected but it is still playing together with the speaker and only the internal speaker is only appearing at sound setting. I try to install RealTek that is compatible to my o.s but not working. Do i need to downgrade it to Xp or Vista to solve this problem or there are some solution for this problem. Please help me i'm not technician to fix this problem.
    And please forgive me for my bad english..
    Here are the system properties of my laptop.
    Windows 7 Professional Service Pack 1
    Processor : Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz
    Installed Memory (RAM) : 1.00 GB
    System Type: 64-bit operating system

Maybe you are looking for

  • 1609 songs get reset

    I don't want to reset my Ipod because of this new application, is there any way to avoid this, or copy all my songs to PC before reset it. Thanks. There's always up and down in life, we're in the shallow ground right now...

  • Change File Name on Save

    Hi all, I have an action recorded that helps me to resize and rename an original image several times.  The action works perfectly, but I have to have the save step as manual so I can enter the correct save name for each file after the action resizes

  • Help w/Hard Drives

    Don't know where else to post? If some one could point me in the right direction. Thanks! I have Video footage that I'm trying to transfer from (one) hard drive (LaCie) Fire Wire- brand to another hard Drive (Western Digital) brand/USB2. I keep getti

  • Page is distorted on edit

    on normal view my website displays well but on edit the page is distorted that Iis the parts of the pages move away from there normal position.Its like the css is not implemented.

  • Print script data in ocr format

    Hi, I wanted to print one line in script in OCR format. Wanted to know how to do this. Thanks in advance