Partial 96kHz support

This commit is contained in:
2018-09-27 11:05:56 +01:00
parent fab11f5755
commit 981f9bd539
7 changed files with 100 additions and 6 deletions

View File

@@ -40,6 +40,7 @@ public class IIR extends IIRBase {
public final static float EQ_22050_RATE = 22050;
public final static float EQ_44100_RATE = 44100;
public final static float EQ_48000_RATE = 48000;
public final static float EQ_96000_RATE = 96000;
/**
* Supported number of bands
*/
@@ -108,7 +109,7 @@ public class IIR extends IIRBase {
* @return true if parameters are supported
*/
public static boolean isParamsSupported(int bands, float rate, int channels) {
if (rate != EQ_11025_RATE && rate != EQ_22050_RATE && rate != EQ_44100_RATE && rate != EQ_48000_RATE)
if (rate != EQ_11025_RATE && rate != EQ_22050_RATE && rate != EQ_44100_RATE && rate != EQ_48000_RATE && rate != EQ_96000_RATE)
return false;
switch (bands) {
@@ -180,6 +181,12 @@ public class IIR extends IIRBase {
iircf = iir_cf10_48000;
break;
}
} else if (rate == EQ_96000_RATE) {
switch (bands) {
case 31:
iircf = iir_cf31_96000;
break;
}
}
}

View File

@@ -410,4 +410,68 @@ public class IIRBase {
/* 20k Hz*/
new IIRCoefficients(6.0884213704e-01, 1.9557893148e-01, -1.3932981614e+00),
};
public final static IIRCoefficients iir_cf31_96000[] = {
/* 20 Hz*/
new IIRCoefficients(9.9939388451e-01, 3.0305774630e-04, 1.9993870327e+00),
/* 25 Hz*/
new IIRCoefficients(9.9924247917e-01, 3.7876041632e-04, 1.9992317740e+00),
/* 31.5 Hz*/
new IIRCoefficients(9.9904564663e-01, 4.7717668529e-04, 1.9990286528e+00),
/* 40 Hz*/
new IIRCoefficients(9.9878827195e-01, 6.0586402557e-04, 1.9987608731e+00),
/* 50 Hz*/
new IIRCoefficients(9.9848556942e-01, 7.5721528829e-04, 1.9984427652e+00),
/* 63 Hz*/
new IIRCoefficients(9.9809219264e-01, 9.5390367779e-04, 1.9980242502e+00),
/* 80 Hz*/
new IIRCoefficients(9.9757801538e-01, 1.2109923088e-03, 1.9974684869e+00),
/* 100 Hz*/
new IIRCoefficients(9.9697343933e-01, 1.5132803374e-03, 1.9968023538e+00),
/* 125 Hz*/
new IIRCoefficients(9.9621823598e-01, 1.8908820086e-03, 1.9959510180e+00),
/* 160 Hz*/
new IIRCoefficients(9.9516191728e-01, 2.4190413595e-03, 1.9947243453e+00),
/* 200 Hz*/
new IIRCoefficients(9.9395607757e-01, 3.0219612131e-03, 1.9932727986e+00),
/* 250 Hz*/
new IIRCoefficients(9.9245085008e-01, 3.7745749576e-03, 1.9913840669e+00),
/* 315 Hz*/
new IIRCoefficients(9.9049749914e-01, 4.7512504310e-03, 1.9888056233e+00),
/* 400 Hz*/
new IIRCoefficients(9.8794899744e-01, 6.0255012789e-03, 1.9852245824e+00),
/* 500 Hz*/
new IIRCoefficients(9.8495930023e-01, 7.5203498850e-03, 1.9807093500e+00),
/* 630 Hz*/
new IIRCoefficients(9.8108651246e-01, 9.4567437704e-03, 1.9743538683e+00),
/* 800 Hz*/
new IIRCoefficients(9.7604570090e-01, 1.1977149551e-02, 1.9652207158e+00),
/* 1k Hz*/
new IIRCoefficients(9.7014963927e-01, 1.4925180364e-02, 1.9532947360e+00),
/* 1.25k Hz*/
new IIRCoefficients(9.6283181641e-01, 1.8584091793e-02, 1.9366149237e+00),
/* 1.6k Hz*/
new IIRCoefficients(9.5268463224e-01, 2.3657683878e-02, 1.9100137880e+00),
/* 2k Hz*/
new IIRCoefficients(9.4122788957e-01, 2.9386055213e-02, 1.8750821533e+00),
/* 2.5k Hz*/
new IIRCoefficients(9.2711765003e-01, 3.6441174983e-02, 1.8248457659e+00),
/* 3.15k Hz*/
new IIRCoefficients(9.0912548757e-01, 4.5437256213e-02, 1.7491177803e+00),
/* 4k Hz*/
new IIRCoefficients(8.8619860800e-01, 5.6900696000e-02, 1.6334959111e+00),
/* 5k Hz*/
new IIRCoefficients(8.6010264114e-01, 6.9948679430e-02, 1.4757186436e+00),
/* 6.3k Hz*/
new IIRCoefficients(8.2760520925e-01, 8.6197395374e-02, 1.2405797786e+00),
/* 8k Hz*/
new IIRCoefficients(7.8757448309e-01, 1.0621275845e-01, 8.9378724155e-01),
/* 10k Hz*/
new IIRCoefficients(7.4415362476e-01, 1.2792318762e-01, 4.5142017567e-01),
/* 12.5k Hz*/
new IIRCoefficients(6.9581428034e-01, 1.5209285983e-01, -1.1091156053e-01),
/* 16k Hz*/
new IIRCoefficients(6.4120506488e-01, 1.7939746756e-01, -8.2060253244e-01),
/* 20k Hz*/
new IIRCoefficients(6.0884213704e-01, 1.9557893148e-01, -1.3932981614e+00),
};
}

View File

@@ -1619,8 +1619,18 @@ public class AudiobookRecorder extends JFrame {
bookTree.setSelectionPath(new TreePath(s.getPath()));
}
}
play.drain();
play.stop();
play.close();
play = null;
} catch (Exception e) {
playing = null;
if (play != null) {
play.drain();
play.stop();
play.close();
}
play = null;
}
toolBar.enableSentence();
toolBar.disableStop();
@@ -1720,6 +1730,8 @@ public class AudiobookRecorder extends JFrame {
} catch (Exception e) {
e.printStackTrace();
}
microphone = null;
microphoneStream = null;
}
public void execScript(String s) {

View File

@@ -56,11 +56,20 @@ public class Equaliser extends JPanel {
}
}
});
JButton load = new JButton("Load from default");
load.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (int i = 0; i < 31; i++) {
channels[i].setValue(Options.getFloat("audio.eq." + i));
}
}
});
JPanel buttons = new JPanel();
buttons.setLayout(new FlowLayout());
buttons.add(smooth);
buttons.add(def);
buttons.add(load);
add(buttons, BorderLayout.SOUTH);
}

View File

@@ -345,7 +345,7 @@ public class Options extends JDialog {
TreeSet<KVPair> list = new TreeSet<KVPair>();
AudioFormat stereoFormat = new AudioFormat(44100f, 16, 2, true, false);
AudioFormat monoFormat = new AudioFormat(44100f, 16, 2, true, false);
AudioFormat monoFormat = new AudioFormat(44100f, 16, 1, true, false);
DataLine.Info stereoDIF = new DataLine.Info(TargetDataLine.class, stereoFormat);
DataLine.Info monoDIF = new DataLine.Info(TargetDataLine.class, monoFormat);
@@ -381,7 +381,7 @@ public class Options extends JDialog {
TreeSet<KVPair> list = new TreeSet<KVPair>();
AudioFormat stereoFormat = new AudioFormat(44100f, 16, 2, true, false);
AudioFormat monoFormat = new AudioFormat(44100f, 16, 2, true, false);
AudioFormat monoFormat = new AudioFormat(44100f, 16, 1, true, false);
DataLine.Info stereoDIF = new DataLine.Info(SourceDataLine.class, stereoFormat);
DataLine.Info monoDIF = new DataLine.Info(SourceDataLine.class, monoFormat);

View File

@@ -497,8 +497,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
AudioFormat format = eq.getFormat();
// IIRControls controls = eq.getControls();
// AudiobookRecorder.window.book.equaliser.apply(controls, format.getChannels());
IIRControls controls = eq.getControls();
AudiobookRecorder.window.book.equaliser.apply(controls, format.getChannels());
int frameSize = format.getFrameSize();
@@ -511,7 +511,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
play.start();
byte[] buffer = new byte[50000];
byte[] buffer = new byte[1024];
eq.skip(pos);
@@ -660,6 +660,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
public int findNearestZeroCrossing(int pos, int range) {
int[] data = getAudioData();
if (data == null) return 0;
if (data.length == 0) return 0;
if (pos < 0) pos = 0;
if (pos >= data.length) pos = data.length-1;

View File

@@ -49,6 +49,7 @@ public class Waveform extends JPanel {
int num = samples.length;
int step = num / w;
if (step == 0) return;
for (int n = 0; n < w; n++) {
int hcnt = 0;