Reading and saving wave files as .txt

I am a highschool senior working on a musical analysis problem. I am afraid my Java isn't all that great. The nitty-gritty is I need a squential representation of the ampiltudes of a sound file( .wav of course) at the frequency at which is was recorded. If I am not mistaken the advantage of the wave format is that it is just that a list of integers corresponding to the ampiltude of the sound file at the recording frequency. So my job is read the array of bytes in the sound file and write them to a .txt file so that I can run other programs which I have already gotten.
I am currently trying to work with the Javax.sound.sampled API.
My code sorta goes like this:
public class analyse
public analyse()
AudioInputStream stream = AudioSystem.getAudioInputStream(new File("audiofile"));
DataLine.Info info = new DataLine.Info(Clip.class, stream.getFormat(), ((int)stream.getFrameLength()*format.getFrameSize()));
Clip clip = (Clip) AudioSystem.getLine(info);
WriteArray();
readArray();
line.drain().stop();
public writeArray() {
int numRead = 0;
byte[] buf = new byte[line.getBufferSize()];
while ((numRead = stream.read(buf, 0, buf.length)) >= 0) {
int offset = 0;
while (offset < numRead) {
offset += line.write(buf, offset, numRead-offset);
I had a friend suggest something like that and That wa just the bare bones of the program. readArray() would of course take the array and, using an iterator, write it to a text file.
However, I've also come across this code while looking thru the API
AudioInputStream stream = AudioSystem.getAudioInputStream(new File("audiofile"));
stream.read(byte[] b, int 0, int stream.frameLength()*stream.frameSize());
this I actually understand better, but I cannot get it to work.
If anyone could help me with this, I would sorely appreciate it.

Do you have QuickTime Pro? What "audio file" types are you referring to - MP3, WAV?

Similar Messages

  • Opening and saving .mhtml files to txt or .csv

    Hello All,
    I need to accomplish the following and it's way beyond my immediate skill set.  I need ODI to do the following:
    1.     Receive an attachment in email and drop it in a folder (got this one)
    2.     The attachment is a report in ,mhtml format.  I need to get the content of the file, minus some of the header info, loaded into a table.  To handle this manually, the user opens the .mhtml file and saves it as a .csv file and deletes the unwanted header info. I'd like to find a way to handle this in ODI without user intervention.
    3.     Once the contents is in a loadable format, load the data to tables.
    My stumbling point is working with the .mhtml file.  Never done this before.  I'm sure there are options and some smart people have already figured this out.  I'm hoping someone will share their solution.
    Thanks in advance for the help!

    Ok, i did figure this out.  For those that are interested here is how I did it;
    $from = "8/31/2014 12:53:56 AM " #Get-Date –f "dd-MMMM-yyyy 00:01:00"
    $to = "8/31/2014 3:00:56 AM "#Get-Date –f "dd-MMMM-yyyy HH:mm:ss"
    $pg = Get-ProtectionGroup -DPMServerName backup01
    $ds = Get-Datasource -ProtectionGroup $pg[0]
    $so = New-SearchOption -SearchString "MASTER_.bak" -FromRecoveryPoint "$from" -ToRecoveryPoint "$to" -SearchDetail filesfolders -SearchType contains -Recursive -Location "T:\"
    $rp = Get-Recoverypoint -Datasource $ds[0]
    $ri = Get-RecoverableItem -Datasource $ds[0] -SearchOption $so
    #If you want to see what Items match the above search, just run $ri
    #Here is the part i was missing..getting the correct library.
    $lib = Get-DPMLibrary -DPMServerName backup01
    $rop = New-RecoveryOption -TargetServer SQL03 -RecoveryLocation CopyToFolder -FileSystem -AlternateLocation "T:\SQLsafe Backups\Offlined Backups\Master\" -RecoveryType Restore -OverwriteType overwrite -dpmlibrary $lib[2]
    Recover-RecoverableItem -RecoverableItem $ri -RecoveryOption $rop
    #This will just give you the status if you don't want to use the GUI
    Get-DPMJob -DPMServerName "backup01" -JobCategory RecoveryTape #-Status InProgress
    So the issue was getting the dpmlibrary then adding the reference to that library in the  recovery option (-dpmlibrary[x]
    Also, when using the -SearchType contains, you can be creative in matching the kinds of files you want it to find ie. -SearchString "*abc*MASTER_.bak"
    This script will recover all of the matching files to the specified location, though it does recreate the original file structure.
    Also, contrary to my title, i didn't end up having to iterate through a list for the restoration of a list of files.  There would still be a place for someone to do that easily enough by doing an exact match and feeding a list of the files, but for
    what i needed, it worked with the wildcard.

  • Problem on reading and writing from from a *.txt file

    I get Problem on reading and writing from from a *.txt file. The following is the read() method...
    The software said the DataInputStream is depreciated. Can anyone help me please?
    public void read()
        File file = new File("C://Documents and Settings//Charles//My Documents//Brunel//EE2065//Assignment and Lab//Assignment 4 and Lab 4//data.txt");
        FileInputStream in = null;
        String str = "";
        try
          in = new BufferedReader(file);
          //in = new FileInputStream(file);
          for(;;)
            str = new BufferedReader(in).readLine();
            //str = new DataInputStream(in).readLine();
            if(str == null)
              break;
            System.out.print(str);
        in.close();
        catch(IOException e)
            System.err.println("execution error: " +e);
      }

    Thank you for your reply. I have made some change. However, there is an incompetable type found error.
    in = new BufferedReader(new InputStreamReader(in));The following are all of the code.
    public void read()
        File file = new File("C://Documents and Settings//Charles//My Documents//Brunel//EE2065//Assignment and Lab//Assignment 4 and Lab 4//data.txt");
        FileInputStream in = null;
        //BufferedReader in = null;
        String str = "";
        try
          in = new BufferedReader(new InputStreamReader(in));
          //in = new FileInputStream(file);
          for(;;)
            BufferedReader Bstr = new BufferedReader(new InputStreamReader(in));
            //str = new BufferedReader(in).readLine();
            //str = new DataInputStream(in).readLine();
            if(str == null)
              break;
            System.out.print(str);
        in.close();
        catch(IOException e)
            System.err.println("execution error: " +e);

  • PPro not reading TC in wav files correctly-is there a fix

    PPro CC v7.2.2
    OSX 10.8.5
    Is Premiere not able to read embedded TC properly in wav files?
    I'm in 29.97fps-NDF seq...PPro seems confused and displays wav TC in source monitor as what seems to be a Drop Frame calculation.
    Example:
    Received audio from Protools Rig as wav audio file with embedded TC start at 00:59:45:00. Verified this in Avid. PPro displays in source as 00:59:48:17. This is not correct.
    Example 2:
    TC start at 01:10:01:20...PPro displays as 01:10:05:26
    I have several segments and stems that must be dropped into a seq at specific TC, which is embedded in the wav file...but PPro can't display properly.
    Using tools for TC recalculation is not always giving me the exact result...sometimes off by a frame. For a semi-long form seq, this "Frame off" can result in bigger sync issues.
    Is there a solution for this?

    Found solution. I remember dealing with a 30fps seq at some point in this Project and had switched my "Indeterminate Media Timebase" to 30fps. I checked the setting and sure enough it was still at 30fps. I changed to 29.97fps-NDF and reimported wav files...now reading TC correctly
    This is under Preferences>Media>Indeterminate Media Timebase
    This needs to be same as your seq Timebase and affects TC interpretation for wav files and I think image sequences as well.

  • File importer detected an inconsistency in the file stucture of (file name). Reading and writing this file's metadata (XMP) has been disabled.

    I have duplicated a project to work on another computer. The project opens fine but when I import new footage/audio files I get this message. "File importer detected an inconsistency in the file stucture of (file name). Reading and writing this file's metadata (XMP) has been disabled." Then I can't play my timeline and Premier Pro crashes.  I have to force quit and restart my computer to continue working. What does this error really mean? How do you rectify?
    Our workflow requires that we duplicate projects to make updates because we are frequently revising but need to keep original project unchanged and intact.

    I have a similar issue and message , but occurs when I import AVI clips from OnLocation CS4 to Premier Pro CS4.

  • File Read and Write using File Adapter in Bpel

    In Bpel Process i am using File Adapter ( Schema is Opaque) for read and write the file contents. i am able do successful deployment and read, write function in first time deployment, after that again i tired to run the application, its not going to write the content of file, its only writing the file with out data's or content in that file.
    Please help me...
    Saravanan

    Hi Eric
    In my domain.log file having the following details. In this file im unable to find out what the exact problem. Please look at this and help me.
    <2008-01-22 18:25:42,024> <INFO> <default.collaxa.cube.compiler> validating "C:\product\10.1.3.1\OracleAS_1\bpel\domains\default\tmp\.bpel_BPELProcess2_1.1_298e83988d77b6640c33dfeec11ed31b.tmp\BPELProcess2.bpel" ...
    <2008-01-22 18:25:49,850> <INFO> <default.collaxa.cube.engine.deployment> <CubeProcessFactory::generateProcessClass>
    Process "BPELProcess2" (revision "1.1") successfully compiled.
    <2008-01-22 18:25:49,914> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Loading JCAActivationAgent for {portType=Read_ptt}
    <2008-01-22 18:25:49,914> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::load - Locating Adapter Framework instance: OraBPEL
    <2008-01-22 18:25:49,930> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::load - Done loading JCAActivationAgent for processId='bpel://localhost/default/BPELProcess2~1.1/
    <2008-01-22 18:25:49,930> <INFO> <default.collaxa.cube.engine.deployment> Process "BPELProcess2" (revision "1.1") successfully loaded.
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::uninit Shutting down the JCA activation agent, processId='bpel://localhost/default/BPELProcess2~1.0/', activation properties={portType=Read_ptt}
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - performing endpointDeactivation for portType=Read_ptt, operation=Read
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> Endpoint De-activation called in adapter for endpoint : D:\MAXIMUS_Project_Softwares\jdevstudiobase10132\jdev\mywork\MyLabs\BPELProcess2\in
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::init - Initializing the JCA activation agent, processId='bpel://localhost/default/BPELProcess2~1.1/
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::initiateInboundJcaEndpoint - Creating and initializing inbound JCA endpoint for:
    process='bpel://localhost/default/BPELProcess2~1.1/'
    domain='default'
    WSDL location='rd.wsdl'
    portType='Read_ptt'
    operation='Read'
    activation properties={portType=Read_ptt}
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - endpointActivation for portType=Read_ptt, operation=Read
    <2008-01-22 18:26:02,730> <INFO> <default.collaxa.cube.activation> <File Adapter::Inbound> Endpoint Activation called in File Adapter for endpoint: D:\MAXIMUS_Project_Softwares\jdevstudiobase10132\jdev\mywork\MyLabs\BPELProcess2\in
    <2008-01-22 18:26:02,730> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - successfully completed endpointActivation for portType=Read_ptt, operation=Read
    <2008-01-22 18:26:02,890> <WARN> <default.collaxa.cube.activation> <File Adapter::Inbound> PollWork::run exiting, Worker thread will die
    <2008-01-22 18:26:04,171> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> Managed Connection Created
    <2008-01-22 18:26:04,171> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> Connection Created
    <2008-01-22 18:26:04,171> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> FileInteraction Created

  • How do I migrate files created in a Windows OS to a new external drive that is formatted as a MAC drive. I want to read and write these files back to the new drive.

    How do I migrate files from an external hard drive created in a Windows OS to a new MAC external drive? I want to read and write these files to the new drive.

    LKrzesowski wrote:
    How do I migrate files from an external hard drive created in a Windows OS to a new MAC external drive? I want to read and write these files to the new drive.
    If all you're trying to do is move the files from the Windows external to the Mac external, you can simply connect them both to the Mac and drag the files from the Windows drive to the Mac drive. If you want to move the files back and forth between them, you'll need to establish the format of the Windows external. Macs can read and write to FAT32 and exFAT (which can handle files larger than 4GB) formatted drives but can only read NTFS formatted drives without additional software. With the Windows drive connected, you can check its format with Disk Utility.

  • Receive mail with POP3 and saving to file using XI

    Hello! I'm new to XI, could you help me with this "simple" task: Receive mail with POP3 and saving to file.
    Thanks!

    Hi,
    you will need:
    Mail Sender Adapter
    http://help.sap.com/saphelp_nw04s/helpdata/en/23/c093409c663228e10000000a1550b0/frameset.htm
    and File Receiver Adapter
    http://help.sap.com/saphelp_nw04s/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm
    Regards
    Patrick

  • How to read and write to file on server

    can any body tell how to read or write to a file on server, like where do i keep the file and what does the path look like......on server
    stand alone i am reading and writing into file but when it comes to server i am confused how it works...i mean the path
    thank you

    The Path needs to be absolute:
    For example in Unix it would look like:
    /usr/paz/Test.txtIn Windows it would look like:
    C:/Paz/Test.txtHope this helps.
    Thanks and regards,
    Pazhanikanthan. P

  • How to read and write Xml file at client side using JavaScript !

    Hello,
    i am new to javascript.
    I have requirement to read and update XML file at client side.
    Will you please guide what could be the best way to read and update XMl file using javascript.
    Thanks,
    Zuned

    This is a Java forum,not a Javascript forum. Maybe you should ask here [http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s|http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s].

  • Read and List the Files from Remote Webserver Path

    Hi All,
    I have requirement where i need to Read and List the files from a Folder of Remote webserver path using JAVA.
    Remote webserver is within the network only...No Firewall and also Access is given to Read the folder. No Issues on this.
    Folder will just contain some PDF files...
    I just need to display the PDF file names available in the Folder..
    No need to read the PDF File...Only required to read the folder to list the file names in it.
    Looking forward some workaround to this.
    Thanks and Regards.

    I need to read the folder from a webserver path of different machine...
    File dir = new File( prop.getProperty("inputPath"));
    File[] files = dir.listFiles(fileFilter);     
    final String match=siteName;
         final String type=reportType;
         Calendar c1 = Calendar.getInstance();
         c1.add(Calendar.MONTH, - Integer.parseInt(prop.getProperty("filterMonths"))); //Filters reportes generated in last X months (X picked from config file)           
         final long filterDate = c1.getTime().getTime();           
         FileFilter fileFilter = new FileFilter() {
         public boolean accept(File file) {
         long fileLastModiDate = file.lastModified();      
         if((fileLastModiDate >= filterDate) && (file.getName().toLowerCase().startsWith(match)) && ( (type.equals("M") && file.getName().indexOf("WIP")==-1) || ((!type.equals("M") && file.getName().indexOf("WIP")!=-1)) ) ) {                        
              return true;
         }else {
              return false;
    Here it works fine if the input path is local machine..
    But i need to know how to give the input path as WEBSERVER PATH of different machine??

  • How to read and create TDM Files in a Java Applicatio​n?

    Hi,
    I want to read and write TDM-Files in a Java-Application.
    I found the TDMHeaderWriter for Java, that can write TDM-Files, but the reading part is still missing.
    Perhaps anyone knows an equivalent in Java to the TDM C DLL and the TDM C Header DLL?
    Thanks Verena

    Cool 
    Can you please give me feedback on this project if you have finished it?
    Matthias
    Matthias Alleweldt
    Project Engineer / Projektingenieur
    Twigeater?  

  • I'm trying to share folder between users on a single mac.  I put the folder in "shared," set permissions so other user can read and write, enabled file sharing, but can't find the folder on the second user's account.  Any help?

    I'm trying to share a folder between users on a single mac.  I want both users to be able to read and write so the folder stays current on both accounts.  I put the folder in "shared," set permissions on folder so other user can read and write, enabled file sharing, but can't find the folder on the second user's account.  Any help?

    Did you log out of one account and into the other or just used Fast user switching?
    Is the permissions set to anyone?
    When you move data to teh Shared folder is it copied or just moved?
    If copied then it's not a folder both can access, just a way station like a USB thumb drive that things are coped too and off of likely.
    You can run this #5 on each user account to reset the user permissions once they are taken back out of the Shared folder
    Step by Step to fix your Mac

  • Reading and Editing '.pdb' files in Mac OS X

    Does anyone know of a program that will read and edit '.pdb' files in Mac OS X? eReader Pro doesn't allowing editing. Thanks.

    Did you try PalmFileEdit?
    http://www.ecamm.com/mac/palmfileedit/

  • My daughter deleted camera shutter.caf and another wav file named camera

    when I open photobooth or any other app that used to use to built-in camera (i.e skype) I get msg saying no camera found. I looked in trash and found 2 files one called camera shutter.caf and another wav file names camera. I guess my daughter deleted these files by mistake:(
    I'm not sure how to restore the camera to work as before.
    i have a new imac

    nirush wrote:
    when I open photobooth or any other app that used to use to built-in camera (i.e skype) I get msg saying no camera found. I looked in trash and found 2 files one called camera shutter.caf and another wav file names camera. I guess my daughter deleted these files by mistake:(
    I'm not sure how to restore the camera to work as before.
    i have a new imac
    Welcome to Discussions, nirush
    (1) If you have made a backup of your Mac's hard drive, you can restore your Mac from the latest working backup. Time Machine is particularly simple to use for this sort of thing, but clones or other backup methods can work, too:
      http://docs.info.apple.com/article.html?path=Mac/10.6/en/9052.html
    (2) If your iMac is so new that you have not ever backed it up, now would be a good time to get an external drive so you can start a regular backup routine as soon as you get your Mac working again. Your retailer can help you select one that is good for your system and the way you use it.
    (3) Troubleshoot your iSight as suggested in http://support.apple.com/kb/HT2090
    If your Apple apps work when you troubleshoot and your only iSight problem in any user account is with Skype, you only need to reinstall the Skype app.
    However, if your iSight does not work with Apple apps either (examples: QuickTimeX and iMovie) in any user account you test, the easiest thing to do is to reinstalling the software that came with your iMac. After reinstalling your Apple software, iSight should work with the Apple apps. If you need help reinstalling your Apple software, see the User Guide manual that came with your iMac.
    If Skype still does not work after reinstalling the Apple software, you will need to reinstall Skype, too.
    Message was edited by: EZ Jim
    Mac Pro Quad Core (Early 2009) 2.93Ghz w/Mac OS X (10.6.4)  MacBook Pro (13 inch, Mid 2009) 2.26GHz (10.6.4)
    LED Cinema Display  G4 PowerBook  1.67GHz (10.4.11)  iBookSE 366MHz (10.3.9)  External iSight

Maybe you are looking for

  • Mouse wheel click doesn't open new tabs correctly?

    Since upgrading to FF4, whenever I mouse click a bookmark on my bookmark toolbar, it will open a blank new tab with the URL in the address line, but will not load the page. I have to select the URL in the address line and press enter, or press the gr

  • Imovie 9.0.9 still on Mac after upgrade

    I have updated my Mac to Mavericks and installed all the updates. I have iMovie but I also have an iMovie 9.0.9 folder with the old program in it (this is 1.32 Gb)  Can I delete this application and folder?

  • My scenario is file to Idoc and we are using multiple receivers.

    Whenever we executes the scenario, getting the error u201CATTRIBUTE_IDOC_METADATA u201Cin sxmb_moni  Any suggestions on how to do solve this?

  • Importing a Database

    Oracle SQL Developer Data Modeler. Version 3.3.0.747 I am trying to import a databaae into the Data Modeler. It seems to get stuck. The Generating Design prompt doesn't show any progress. So far it has been in the Generating Design mode fro more than

  • 30-inch Cinema display picture turns snowy

    After about 30:00 screen fills with tiny little dots. Think I Have traced to power supply? but want to be sure before buying one on the used or surplus market for $100.