diff --git a/src/Tests/TestCommandCounterAndStatistic.java b/src/Tests/TestCommandCounterAndStatistic.java index 2cb2c4d..9d1af0e 100644 --- a/src/Tests/TestCommandCounterAndStatistic.java +++ b/src/Tests/TestCommandCounterAndStatistic.java @@ -11,28 +11,28 @@ public class TestCommandCounterAndStatistic implements CommandsListener { private int correctCommandCounter = 0; private int commandCounter = 0; - @Override + public void onStartTraining() { correctCommandCounter += 1; commandCounter+=1; } - @Override + public void onPoseType(String name) { commandCounter+=1; } - @Override + public void onCapturePose() { commandCounter+=1; } - @Override + public void onCompleteTraining() { commandCounter+=1; } - @Override + public void noCommand() { commandCounter+=1; } diff --git a/src/com/company/RecordingThread/RecordingThread.java b/src/com/company/RecordingThread/RecordingThread.java index 08a4d98..3020e1e 100644 --- a/src/com/company/RecordingThread/RecordingThread.java +++ b/src/com/company/RecordingThread/RecordingThread.java @@ -103,12 +103,6 @@ public void run() { microphone.setAudioFile(tempAudioFile); microphone.captureAudioToFile(microphone.getAudioFile()); - /*double dTms = 32; - int bytes = microphone.getNumOfBytes(dTms/1000); - int freq = microphone.getFrequency(bytes); - int vol = microphone.getAudioVolume((int) dTms); - System.out.println(freq + " " + vol);*/ - Thread.sleep(checkVolumeSampleTime * 3); double magnitude = microphone.magnitude(120, 122); diff --git a/src/com/company/microphone/MicrophoneAnalyzer.java b/src/com/company/microphone/MicrophoneAnalyzer.java index 99e5b8e..b3ba8a3 100644 --- a/src/com/company/microphone/MicrophoneAnalyzer.java +++ b/src/com/company/microphone/MicrophoneAnalyzer.java @@ -3,7 +3,10 @@ import com.darkprograms.speech.util.Complex; import com.darkprograms.speech.util.FFT; +import java.io.IOException; + import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioInputStream; /******************************************************************************************** @@ -156,12 +159,16 @@ public int getFrequency(byte[] bytes){ public double magnitude (int minFreq, int maxFreq) { int numOfBytes = 2048; + + AudioInputStream stream = new AudioInputStream(getTargetDataLine()); - if(getTargetDataLine() == null){ - return -1; - } byte[] data = new byte[numOfBytes+1];//One byte is lost during conversion - this.getTargetDataLine().read(data, 0, numOfBytes); + try { + stream.read(data, 0, numOfBytes); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } double[] audioData = this.bytesToDoubleArray(data); diff --git a/src/com/company/testInterfaceCommandsListener.java b/src/com/company/testInterfaceCommandsListener.java index 6fa7440..e619741 100644 --- a/src/com/company/testInterfaceCommandsListener.java +++ b/src/com/company/testInterfaceCommandsListener.java @@ -30,7 +30,7 @@ public void onCompleteTraining() { System.out.println("**************"); } - @Override + public void noCommand() { System.out.println("**************"); System.out.println("No Command");