Results 1 to 8 of 8
  1. #1
    tinaman is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default Getting error when trying to read file into float array

    Hi,
    I am getting the following error when trying to get my program to run. I want the filename that the user inputs to go into the float array at the end.
    Any ideas ...or help in any way?
    Thanks


    musicIdea.java:69: cannot find symbol
    symbol : variable Read
    location: musicIdea
    float [] data = Read.audio(fileName1);
    ^
    1 error

    Java Code:
    import jm.util.*;
    import javax.swing.*;
    import java.io.*;
    import java.io.IOException;
    public class musicidea 
    {
    	public static void main(String [] args)throws IOException
    	{
    	String fileName1 = "", fileName2 = "";	
    	String message1 = "Please input the name of the file you wish to manipulate";
    	String message2 = "Input name you will give to file when manipulated";
    	String PatternFile = "[a-z0-9]{1,32}.aiff",menuChoicePattern = "[0-9]{1}";
    	String advice1 = "This file type does not exist, please insert again in .aiff format";
    	String advice2 = "Filename supplied does not exist, please retry";
    	String advice3 = "Number choice not correct, please choose a number 1-4 or exit";
    	String menuOptions  = "1 Normalise\n" + 
    	                      "2 Looping\n" +
    	                      "3 Insert Silence\n" + 
    	                      "4 Envelope\n" + 
    	                      "0 Exit\n\n" +
    	                      "Enter your selection:";
    	File readFile;
    	boolean choice1 = false, choice2 = false, choice3 = false;	
    	while(!choice1)
    		{
    			fileName1 = JOptionPane.showInputDialog(null,message1);
    			if(fileName1!=null)
    				{
    				if (!(fileName1.matches(PatternFile)))
    				JOptionPane.showMessageDialog(null,advice1);
    				else
    					{
    					readFile = new File(fileName1);
    					if(!(readFile.exists()))
    					JOptionPane.showMessageDialog(null,advice2);
    					else
    						{
    						choice1 = true;
    						}
    					}
    				}
    		}
    		while(!choice2)
    			{
    				fileName2 = JOptionPane.showInputDialog(null,message2);
    				if(fileName2!=null)
    				{
    					if (!(fileName2.matches(PatternFile)))
    					JOptionPane.showMessageDialog(null,advice1);
    					else
    						{
    						choice2 = true;
    						}
    				}
    			}
    		
    		while(!choice3)
    			{
    				int fileNo;
    				fileNo = Integer.parseInt(JOptionPane.showInputDialog(null,menuOptions));
    				if(fileNo < 0 || fileNo > 4)
    				JOptionPane.showMessageDialog(null, advice3);
    				else
    						{
    						choice3 = true;
    						}
    						if(fileNo < 2)
    						{
    						float [] data = Read.audio(fileName1);
    						//reverse order of samples
    						float [] reversed = new float[data.length];
    						for (int i = 0; i < data.length; i++)
    						reversed[data.length - i - 1] = data[i];
    						Write.audio(reversed, "ReversedAudio.aiff");
    						}
    			}
    	}
    }

  2. #2
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    import the class Read

  3. #3
    tinaman is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    thanks alot

  4. #4
    tinaman is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    Any idea why it is not writing the audio file out for me?
    Thanks again.

  5. #5
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    No idea, unless you tell me the expected output vs unexpected (actual) output or compiler error messages if you got any?

  6. #6
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Quote Originally Posted by jonyjony420 View Post
    My friend is crazy he will do flips off the top of a 10 foot swingset!
    I wish it was you who did the flips, and I wish you fell on your head.

  7. #7
    tinaman is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

    Default

    Well basically I think I must have it set up wrong somewhere for reading in and out the files.
    I am asking the end user to give me the file name(filename1). Then I ask them what they want to name the file for output(filename2) but it never returns the output for me. No error message on that so far just no returned file. Not sure if it is even reading in the file correctly.

  8. #8
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    What is your output? i.e. there are no System.out.print's

    you have a showMessageDialog() command but its in an if-else statement so it seems as though this code:
    Java Code:
    if(!(readFile.exists()))
    equates to false (i.e. the file does exist) and therefore showMessageDialog() does not happen, instead this happens:
    Java Code:
    choice1 = true
    and the loop is broken and there is no output

Similar Threads

  1. Excel file read error
    By Asvin in forum New To Java
    Replies: 10
    Last Post: 04-28-2011, 10:01 PM
  2. read input file into array
    By randoms:) in forum New To Java
    Replies: 3
    Last Post: 04-23-2011, 08:52 AM
  3. Help needed: read array from file and then use it
    By ChicagoAve in forum New To Java
    Replies: 11
    Last Post: 02-18-2011, 01:02 PM
  4. JTextField Array Read Error
    By relax1 in forum New To Java
    Replies: 6
    Last Post: 12-17-2010, 09:30 PM
  5. Read File into 2d array
    By almjodla in forum New To Java
    Replies: 8
    Last Post: 03-23-2010, 02:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •