Fixed exception on empty gainpoints after recording
This commit is contained in:
21
ExampleExportProfiles/librivox-noinit.abprof
Normal file
21
ExampleExportProfiles/librivox-noinit.abprof
Normal file
@@ -0,0 +1,21 @@
|
||||
<profile>
|
||||
<code>librivox-noinit</code>
|
||||
<name>LibriVox.org (Without initials)</name>
|
||||
<export>
|
||||
<bitrate>128000</bitrate>
|
||||
<channels>1</channels>
|
||||
<samples>44100</samples>
|
||||
<format>{chapter.name:lower}_{book.author.short:lower}_{file.bitrate.kb}kb</format>
|
||||
</export>
|
||||
<gaps>
|
||||
<pre-chapter>500</pre-chapter>
|
||||
<post-chapter>5000</post-chapter>
|
||||
<post-sentence>400</post-sentence>
|
||||
<followon>100</followon>
|
||||
<post-paragraph>1000</post-paragraph>
|
||||
<post-section>1200</post-section>
|
||||
</gaps>
|
||||
<audio>
|
||||
<rms>-19</rms>
|
||||
</audio>
|
||||
</profile>
|
||||
21
ExampleExportProfiles/librivox-spc.abprof
Normal file
21
ExampleExportProfiles/librivox-spc.abprof
Normal file
@@ -0,0 +1,21 @@
|
||||
<profile>
|
||||
<code>librivox-spc</code>
|
||||
<name>LibriVox.org Short Poetry Collection</name>
|
||||
<export>
|
||||
<bitrate>128000</bitrate>
|
||||
<channels>1</channels>
|
||||
<samples>44100</samples>
|
||||
<format>{book.title:lower}_{chapter.name:lower}_{narrator.initials:lower}_{file.bitrate.kb}kb</format>
|
||||
</export>
|
||||
<gaps>
|
||||
<pre-chapter>500</pre-chapter>
|
||||
<post-chapter>5000</post-chapter>
|
||||
<post-sentence>400</post-sentence>
|
||||
<followon>100</followon>
|
||||
<post-paragraph>1000</post-paragraph>
|
||||
<post-section>1200</post-section>
|
||||
</gaps>
|
||||
<audio>
|
||||
<rms>-19</rms>
|
||||
</audio>
|
||||
</profile>
|
||||
@@ -252,8 +252,11 @@ public class Book extends BookTreeNode {
|
||||
|
||||
public Chapter getChapter(int n) {
|
||||
Debug.trace();
|
||||
if (n == 0) return null;
|
||||
return (Chapter)getChildAt(n);
|
||||
Object o = getChildAt(n);
|
||||
if (o instanceof Chapter) {
|
||||
return (Chapter)o;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Chapter addChapter() {
|
||||
|
||||
@@ -100,7 +100,7 @@ public class Chapter extends BookTreeNode {
|
||||
|
||||
public int getSequenceNumber() {
|
||||
Book book = getBook();
|
||||
int i = 1;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
Chapter c = book.getChapter(i);
|
||||
if (c == null) {
|
||||
|
||||
@@ -106,7 +106,7 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
|
||||
double[] waveProfile = null;
|
||||
|
||||
TreeMap<Integer, Double> gainPoints = null;
|
||||
TreeMap<Integer, Double> gainPoints = new TreeMap<Integer, Double>();
|
||||
|
||||
RecordingThread recordingThread;
|
||||
|
||||
@@ -241,7 +241,6 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
autoTrimSample();
|
||||
}
|
||||
|
||||
gainPoints = new TreeMap<Integer, Double>();
|
||||
Element gp = Book.getNode(root, "gainpoints");
|
||||
if (gp != null) {
|
||||
NodeList points = gp.getElementsByTagName("gainpoint");
|
||||
@@ -1901,16 +1900,10 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
|
||||
public TreeMap<Integer, Double> getGainPoints() {
|
||||
Debug.trace();
|
||||
if (gainPoints == null) {
|
||||
gainPoints = new TreeMap<Integer, Double>();
|
||||
}
|
||||
return gainPoints;
|
||||
}
|
||||
|
||||
public void addGainPoint(Integer loc, Double g) {
|
||||
if (gainPoints == null) {
|
||||
gainPoints = new TreeMap<Integer, Double>();
|
||||
}
|
||||
gainPoints.put(loc, g);
|
||||
refreshAllData();
|
||||
}
|
||||
@@ -1925,10 +1918,6 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
}
|
||||
|
||||
public void adjustGainPoint(Integer loc, Double adj, boolean reload) {
|
||||
if (gainPoints == null) {
|
||||
gainPoints = new TreeMap<Integer, Double>();
|
||||
return;
|
||||
}
|
||||
Double gp = gainPoints.get(loc);
|
||||
if (gp == null) return;
|
||||
gp += adj;
|
||||
@@ -2048,10 +2037,11 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
|
||||
final int window = 500;
|
||||
|
||||
public double[] getWaveProfile() {
|
||||
public synchronized double[] getWaveProfile() {
|
||||
if (waveProfile != null) return waveProfile;
|
||||
double[][] samples = getProcessedAudioData();
|
||||
if (samples[LEFT].length == 0) return null;
|
||||
System.out.println(String.format("Sample length: %d", samples[LEFT].length));
|
||||
waveProfile = new double[samples[LEFT].length];
|
||||
|
||||
double rt = 0;
|
||||
|
||||
Reference in New Issue
Block a user