I am a Java newbie, so please bear with me and help.
I aim to first play then record sound.
I use netbeans IDE 6.8. Here is the code:
import java
The captureAudio()
is not declared static thus it is an instance method and it cannot be called without an object in main()
which is static.
Sine I see you have createed in the run methid new instance of Reg1 thus it is fine then to call the method captureAudio()
for this object. Plus there is no need for the inner private void Reg1()
method which BTW you were never calling. I propose that you change main to something like this.
public static void main(String args[])
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
Reg1 reg1 = new Reg1();
KeyListener s;
try
{
AudioInputStream audio = AudioSystem.getAudioInputStream(new File("name.wav"));
Clip clip = AudioSystem.getClip();
clip.open(audio);
clip.start();
}catch(UnsupportedAudioFileException uae)
{
System.out.println(uae);
}catch(IOException ioe)
{
System.out.println(ioe);
}catch(LineUnavailableException lua)
{
System.out.println(lua);
}
reg1.captureAudio();
}
});
}