Results 1 to 8 of 8
- 04-25-2011, 07:58 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
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"); } } } }
-
import the class Read
- 04-25-2011, 08:36 PM #3
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
thanks alot
- 04-25-2011, 08:45 PM #4
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
Any idea why it is not writing the audio file out for me?
Thanks again.
-
No idea, unless you tell me the expected output vs unexpected (actual) output or compiler error messages if you got any?
- 04-26-2011, 05:34 AM #6
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
- 04-26-2011, 08:55 AM #7
Member
- Join Date
- Apr 2011
- Posts
- 9
- Rep Power
- 0
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.
-
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:
equates to false (i.e. the file does exist) and therefore showMessageDialog() does not happen, instead this happens:Java Code:if(!(readFile.exists()))
and the loop is broken and there is no outputJava Code:choice1 = true
Similar Threads
-
Excel file read error
By Asvin in forum New To JavaReplies: 10Last Post: 04-28-2011, 10:01 PM -
read input file into array
By randoms:) in forum New To JavaReplies: 3Last Post: 04-23-2011, 08:52 AM -
Help needed: read array from file and then use it
By ChicagoAve in forum New To JavaReplies: 11Last Post: 02-18-2011, 01:02 PM -
JTextField Array Read Error
By relax1 in forum New To JavaReplies: 6Last Post: 12-17-2010, 09:30 PM -
Read File into 2d array
By almjodla in forum New To JavaReplies: 8Last Post: 03-23-2010, 02:55 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks