Added playback marker for single phrase play
This commit is contained in:
@@ -65,7 +65,7 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
Sentence selectedSentence = null;
|
Sentence selectedSentence = null;
|
||||||
|
|
||||||
JPanel sampleControl;
|
JPanel sampleControl;
|
||||||
Waveform sampleWaveform;
|
public Waveform sampleWaveform;
|
||||||
JScrollBar sampleScroll;
|
JScrollBar sampleScroll;
|
||||||
|
|
||||||
JSpinner postSentenceGap;
|
JSpinner postSentenceGap;
|
||||||
@@ -388,9 +388,12 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
|
|
||||||
controlsTop.add(locked);
|
controlsTop.add(locked);
|
||||||
|
|
||||||
|
controlsTop.add(Box.createHorizontalGlue());
|
||||||
controlsTop.add(new JLabel("Post gap:"));
|
controlsTop.add(new JLabel("Post gap:"));
|
||||||
controlsTop.add(postSentenceGap);
|
controlsTop.add(postSentenceGap);
|
||||||
controlsTop.add(new JLabel("ms"));
|
controlsTop.add(new JLabel("ms"));
|
||||||
|
controlsTop.add(Box.createHorizontalGlue());
|
||||||
|
|
||||||
|
|
||||||
JButton zoomIn = new JButton(Icons.zoomIn);
|
JButton zoomIn = new JButton(Icons.zoomIn);
|
||||||
zoomIn.setToolTipText("Zoom In");
|
zoomIn.setToolTipText("Zoom In");
|
||||||
@@ -1654,6 +1657,9 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
play = null;
|
play = null;
|
||||||
}
|
}
|
||||||
playing = null;
|
playing = null;
|
||||||
|
if (selectedSentence != null) {
|
||||||
|
selectedSentence.stopPlaying();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alertNoRoomNoise() {
|
public void alertNoRoomNoise() {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
boolean locked;
|
boolean locked;
|
||||||
|
|
||||||
boolean recording;
|
boolean recording;
|
||||||
|
boolean playing;
|
||||||
|
|
||||||
boolean inSample;
|
boolean inSample;
|
||||||
|
|
||||||
@@ -555,10 +556,13 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
|
|
||||||
eq.skip(pos);
|
eq.skip(pos);
|
||||||
|
|
||||||
while (pos < crossEndOffset * frameSize) {
|
playing = true;
|
||||||
|
while ((pos < crossEndOffset * frameSize) && playing) {
|
||||||
int nr = eq.read(buffer);
|
int nr = eq.read(buffer);
|
||||||
pos += nr;
|
pos += nr;
|
||||||
|
|
||||||
|
AudiobookRecorder.window.sampleWaveform.setPlayMarker(pos / frameSize);
|
||||||
|
|
||||||
play.write(buffer, 0, nr);
|
play.write(buffer, 0, nr);
|
||||||
};
|
};
|
||||||
play.drain();
|
play.drain();
|
||||||
@@ -568,6 +572,10 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stopPlaying() {
|
||||||
|
playing = false;
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] getRawAudioData() {
|
public byte[] getRawAudioData() {
|
||||||
File f = getFile();
|
File f = getFile();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
|||||||
int leftMarkerSaved = 0;
|
int leftMarkerSaved = 0;
|
||||||
int rightMarkerSaved = 0;
|
int rightMarkerSaved = 0;
|
||||||
|
|
||||||
|
int playMarker = 0;
|
||||||
|
|
||||||
int leftAltMarker = 0;
|
int leftAltMarker = 0;
|
||||||
int rightAltMarker = 0;
|
int rightAltMarker = 0;
|
||||||
|
|
||||||
@@ -126,6 +128,10 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
|||||||
g.drawLine((leftMarker - offset)/step, 0, (leftMarker - offset)/step, h);
|
g.drawLine((leftMarker - offset)/step, 0, (leftMarker - offset)/step, h);
|
||||||
g.drawLine((rightMarker - offset)/step, 0, (rightMarker - offset)/step, h);
|
g.drawLine((rightMarker - offset)/step, 0, (rightMarker - offset)/step, h);
|
||||||
|
|
||||||
|
g.setColor(new Color(0, 255, 255));
|
||||||
|
for (int i = 0; i < h; i += 2) {
|
||||||
|
g.drawLine((playMarker - offset) / step, i, (playMarker - offset) / step, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +174,7 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
|||||||
|
|
||||||
public void setData(int[] s) {
|
public void setData(int[] s) {
|
||||||
samples = s;
|
samples = s;
|
||||||
|
playMarker = 0;
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,4 +278,8 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
|
|||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPlayMarker(int m) {
|
||||||
|
playMarker = m;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user