diff --git a/src/uk/co/majenko/audiobookrecorder/AudiobookRecorder.java b/src/uk/co/majenko/audiobookrecorder/AudiobookRecorder.java index fdccf6a..520dcbc 100644 --- a/src/uk/co/majenko/audiobookrecorder/AudiobookRecorder.java +++ b/src/uk/co/majenko/audiobookrecorder/AudiobookRecorder.java @@ -1365,6 +1365,7 @@ public class AudiobookRecorder extends JFrame { if (s.startRecording()) { recording = (Sentence)selectedNode; + System.err.println("Starting flash"); centralPanel.setFlash(true); } } @@ -1414,6 +1415,7 @@ public class AudiobookRecorder extends JFrame { if (s.startRecording()) { recording = s; + System.err.println("Starting flash"); centralPanel.setFlash(true); } } @@ -1464,6 +1466,7 @@ public class AudiobookRecorder extends JFrame { if (s.startRecording()) { recording = s; + System.err.println("Starting flash"); centralPanel.setFlash(true); } } @@ -1513,6 +1516,7 @@ public class AudiobookRecorder extends JFrame { if (s.startRecording()) { recording = s; + System.err.println("Starting flash"); centralPanel.setFlash(true); } } @@ -1562,23 +1566,29 @@ public class AudiobookRecorder extends JFrame { if (s.startRecording()) { recording = s; + System.err.println("Starting flash"); centralPanel.setFlash(true); } } public void stopRecording() { + System.err.println("Record stop requested"); if (recording == null) return; recording.stopRecording(); + System.err.println("Reloading model"); bookTreeModel.reload(book); bookTree.expandPath(new TreePath(((DefaultMutableTreeNode)recording.getParent()).getPath())); bookTree.setSelectionPath(new TreePath(recording.getPath())); bookTree.scrollPathToVisible(new TreePath(recording.getPath())); + System.err.println("Stopping flash"); centralPanel.setFlash(false); recording = null; + System.err.println("Saving book"); saveBookStructure(); + System.err.println("Stop request complete"); } public void deleteLastRecording() { diff --git a/src/uk/co/majenko/audiobookrecorder/Sentence.java b/src/uk/co/majenko/audiobookrecorder/Sentence.java index d636d3f..7b940cb 100644 --- a/src/uk/co/majenko/audiobookrecorder/Sentence.java +++ b/src/uk/co/majenko/audiobookrecorder/Sentence.java @@ -94,7 +94,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable { try { running = true; recording = true; - byte[] buf = new byte[AudiobookRecorder.window.microphone.getBufferSize()]; + byte[] buf = new byte[1024]; //AudiobookRecorder.window.microphone.getBufferSize()]; FileOutputStream fos = new FileOutputStream(tempFile); int len = 0; AudiobookRecorder.window.microphone.flush(); @@ -155,24 +155,31 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable { } public boolean startRecording() { + System.err.println("Starting record"); if (AudiobookRecorder.window.microphone == null) { JOptionPane.showMessageDialog(AudiobookRecorder.window, "Microphone not started. Start the microphone first.", "Error", JOptionPane.ERROR_MESSAGE); return false; } + System.err.println("Removing object from cache"); CacheManager.removeFromCache(this); + System.err.println("Creating record thread"); recordingThread = new RecordingThread(getTempFile(), getFile(), Options.getAudioFormat()); + System.err.println("Starting record thread"); Thread rc = new Thread(recordingThread); rc.setDaemon(true); rc.start(); + System.err.println("Recording started"); return true; } public void stopRecording() { + System.err.println("Stopping recording..."); recordingThread.stopRecording(); + System.err.println("Waiting for stop to complete..."); while (recordingThread.isRunning()) { try { Thread.sleep(10); @@ -181,11 +188,14 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable { } } + System.err.println("Removing object from cache..."); + CacheManager.removeFromCache(this); audioData = null; processedAudio = null; + System.err.println("Running trim and recognition..."); if (!id.equals("room-noise")) { String tm = Options.get("audio.recording.trim"); if (tm.equals("peak")) { @@ -197,6 +207,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable { recognise(); } } + System.err.println("Recording stop complete"); } public static final int FFTBuckets = 1024;