2
import java.io.File; import java.util.Scanner; class DataManage{ public static void main(String[] args){ MusicControl musicControler; File clip; Scanner scan = new Scanner(System.in); int data; while(true){ data = scan.nextInt(); clip = new File(new StringBuffer().append("LaunchPad/music/").append(data).append(".wav").toString()); musicControler = new MusicControl(clip); musicControler.start(); } } } import java.io.File; import javax.sound.sampled.*; class MusicControl extends Thread{ private Clip clip; private File sound; private FloatControl volume; public MusicControl(File sound){ this.sound = sound; musicSetup(); } public void run(){ try{ clip.start(); Thread.sleep(clip.getMicrosecondLength()/1000); }catch(Exception e){ System.out.println(e); } } public void musicSetup(){ try{ clip = AudioSystem.getClip(); clip.open(AudioSystem.getAudioInputStream(sound)); }catch(Exception e){ System.out.println(e); } } } 

I'm trying to play a sound in my Raspberry pi2. This program works really well in Window7. However, it works strange in the Raspberry pi2. When I start the program, it works well until it counts 8. If it plays more than 8 times, it prints

javax.sound.sampled.LineUnavailaleException: line with format PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported. 

How can I fix it? Please give me a hand.

1 Answer 1

1

The error is in this method

public MusicControl(File Sound){ sound = Sound; musicSetup(); } 

You are defining a variable like File Sound which is 2 types and no name. You have to replace the Sound with a name for the variable.

Sign up to request clarification or add additional context in comments.

2 Comments

'Sound' is just a object name from DataManage class!
Sorry my bad.. i was just making a Test program.. so i didn't really care about that problem..^^

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.