Added playback marker for single phrase play

This commit is contained in:
2018-09-30 02:00:16 +01:00
parent d8cd72809c
commit 38e7434730
3 changed files with 27 additions and 2 deletions

View File

@@ -65,7 +65,7 @@ public class AudiobookRecorder extends JFrame {
Sentence selectedSentence = null;
JPanel sampleControl;
Waveform sampleWaveform;
public Waveform sampleWaveform;
JScrollBar sampleScroll;
JSpinner postSentenceGap;
@@ -388,9 +388,12 @@ public class AudiobookRecorder extends JFrame {
controlsTop.add(locked);
controlsTop.add(Box.createHorizontalGlue());
controlsTop.add(new JLabel("Post gap:"));
controlsTop.add(postSentenceGap);
controlsTop.add(new JLabel("ms"));
controlsTop.add(Box.createHorizontalGlue());
JButton zoomIn = new JButton(Icons.zoomIn);
zoomIn.setToolTipText("Zoom In");
@@ -1654,6 +1657,9 @@ public class AudiobookRecorder extends JFrame {
play = null;
}
playing = null;
if (selectedSentence != null) {
selectedSentence.stopPlaying();
}
}
public void alertNoRoomNoise() {

View File

@@ -30,6 +30,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
boolean locked;
boolean recording;
boolean playing;
boolean inSample;
@@ -555,10 +556,13 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
eq.skip(pos);
while (pos < crossEndOffset * frameSize) {
playing = true;
while ((pos < crossEndOffset * frameSize) && playing) {
int nr = eq.read(buffer);
pos += nr;
AudiobookRecorder.window.sampleWaveform.setPlayMarker(pos / frameSize);
play.write(buffer, 0, nr);
};
play.drain();
@@ -568,6 +572,10 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
}
}
public void stopPlaying() {
playing = false;
}
public byte[] getRawAudioData() {
File f = getFile();
try {

View File

@@ -16,6 +16,8 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
int leftMarkerSaved = 0;
int rightMarkerSaved = 0;
int playMarker = 0;
int leftAltMarker = 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((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) {
samples = s;
playMarker = 0;
repaint();
}
@@ -271,4 +278,8 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
repaint();
}
public void setPlayMarker(int m) {
playMarker = m;
repaint();
}
}