Store recording settings in the book configuration
This commit is contained in:
@@ -1220,6 +1220,10 @@ public class AudiobookRecorder extends JFrame {
|
||||
prefs.setProperty("book.genre", book.getGenre());
|
||||
prefs.setProperty("book.comment", book.getComment());
|
||||
|
||||
prefs.setProperty("audio.recording.samplerate", "" + book.getSampleRate());
|
||||
prefs.setProperty("audio.recording.resolution", "" + book.getResolution());
|
||||
prefs.setProperty("audio.recording.channels", "" + book.getChannels());
|
||||
|
||||
for (int i = 0; i < 31; i++) {
|
||||
prefs.setProperty("audio.eq." + i, String.format("%.3f", book.equaliser.getChannel(i)));
|
||||
}
|
||||
@@ -1270,6 +1274,13 @@ public class AudiobookRecorder extends JFrame {
|
||||
|
||||
File r = f.getParentFile();
|
||||
File cf = new File(r, "coverart.png");
|
||||
if (!cf.exists()) {
|
||||
cf = new File(r, "coverart.jpg");
|
||||
if (!cf.exists()) {
|
||||
cf = new File(r, "coverart.gif");
|
||||
}
|
||||
}
|
||||
|
||||
if (cf.exists()) {
|
||||
ImageIcon i = new ImageIcon(cf.getAbsolutePath());
|
||||
Image ri = Utils.getScaledImage(i.getImage(), 22, 22);
|
||||
@@ -1289,6 +1300,25 @@ public class AudiobookRecorder extends JFrame {
|
||||
book.setGenre(prefs.getProperty("book.genre"));
|
||||
book.setComment(prefs.getProperty("book.comment"));
|
||||
|
||||
int sr = Utils.s2i(prefs.getProperty("audio.recording.samplerate"));
|
||||
if (sr == 0) {
|
||||
sr = Options.getInteger("audio.recording.samplerate");
|
||||
}
|
||||
book.setSampleRate(sr);
|
||||
|
||||
int chans = Utils.s2i(prefs.getProperty("audio.recording.channels"));
|
||||
if (chans == 0) {
|
||||
chans = Options.getInteger("audio.recording.channels");
|
||||
}
|
||||
book.setChannels(chans);
|
||||
|
||||
int res = Utils.s2i(prefs.getProperty("audio.recording.resolution"));
|
||||
if (res == 0) {
|
||||
res = Options.getInteger("audio.recording.resolution");
|
||||
}
|
||||
book.setResolution(res);
|
||||
|
||||
|
||||
for (int i = 0; i < 31; i++) {
|
||||
if (prefs.getProperty("audio.eq." + i) == null) {
|
||||
book.equaliser.setChannel(i, Options.getFloat("audio.eq." + i));
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import javax.swing.tree.*;
|
||||
import davaguine.jeq.core.IIRControls;
|
||||
import javax.sound.sampled.*;
|
||||
|
||||
public class Book extends DefaultMutableTreeNode {
|
||||
|
||||
@@ -17,6 +18,10 @@ public class Book extends DefaultMutableTreeNode {
|
||||
String genre;
|
||||
String comment;
|
||||
|
||||
int sampleRate;
|
||||
int channels;
|
||||
int resolution;
|
||||
|
||||
ImageIcon icon;
|
||||
|
||||
public Equaliser equaliser;
|
||||
@@ -155,4 +160,15 @@ public class Book extends DefaultMutableTreeNode {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getSampleRate() { return sampleRate; }
|
||||
public void setSampleRate(int sr) { sampleRate = sr; }
|
||||
public int getChannels() { return channels; }
|
||||
public void setChannels(int c) { channels = c; }
|
||||
public int getResolution() { return resolution; }
|
||||
public void setResolution(int r) { resolution = r; }
|
||||
|
||||
public AudioFormat getAudioFormat() {
|
||||
return new AudioFormat(getSampleRate(), getResolution(), getChannels(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
}
|
||||
|
||||
|
||||
recordingThread = new RecordingThread(getTempFile(), getFile(), Options.getAudioFormat());
|
||||
recordingThread = new RecordingThread(getTempFile(), getFile(), AudiobookRecorder.window.book.getAudioFormat());
|
||||
|
||||
Thread rc = new Thread(recordingThread);
|
||||
rc.setDaemon(true);
|
||||
|
||||
Reference in New Issue
Block a user