@Test public void test() throws URISyntaxException { BandDetector detector = new BandDetector(); String path; path = new File(getClass().getResource("10001-90210-01803-8khz.wav").toURI()).getPath(); assertTrue(detector.bandwidth(path)); path = new File(getClass().getResource("10001-90210-01803.wav").toURI()).getPath(); assertFalse(detector.bandwidth(path)); }
public boolean bandwidth(String file) { source.setAudioFile(new File(file), ""); Data data; double energy[] = new double[bands]; while ((data = frontend.getData()) != null) { if (data instanceof DoubleData) { double maxIntensity = lowIntensity; double[] frame = ((DoubleData) data).getValues(); for (int i = 0; i < bands; i++) maxIntensity = Math.max(maxIntensity, frame[i]); if (maxIntensity <= lowIntensity) { continue; } for (int i = 0; i < bands; i++) { energy[i] = Math.max(frame[i] / maxIntensity, energy[i]); } } } double maxLow = max(energy, lowRangeStart, lowRangeEnd); double maxHi = max(energy, highRangeStart, highRangeEnd); if (maxHi < noSignalLevel && maxLow > signalLevel) return true; return false; }
BandDetector { public boolean bandwidth(String file) { source.setAudioFile(new File(file), ""); Data data; double energy[] = new double[bands]; while ((data = frontend.getData()) != null) { if (data instanceof DoubleData) { double maxIntensity = lowIntensity; double[] frame = ((DoubleData) data).getValues(); for (int i = 0; i < bands; i++) maxIntensity = Math.max(maxIntensity, frame[i]); if (maxIntensity <= lowIntensity) { continue; } for (int i = 0; i < bands; i++) { energy[i] = Math.max(frame[i] / maxIntensity, energy[i]); } } } double maxLow = max(energy, lowRangeStart, lowRangeEnd); double maxHi = max(energy, highRangeStart, highRangeEnd); if (maxHi < noSignalLevel && maxLow > signalLevel) return true; return false; } }
BandDetector { public boolean bandwidth(String file) { source.setAudioFile(new File(file), ""); Data data; double energy[] = new double[bands]; while ((data = frontend.getData()) != null) { if (data instanceof DoubleData) { double maxIntensity = lowIntensity; double[] frame = ((DoubleData) data).getValues(); for (int i = 0; i < bands; i++) maxIntensity = Math.max(maxIntensity, frame[i]); if (maxIntensity <= lowIntensity) { continue; } for (int i = 0; i < bands; i++) { energy[i] = Math.max(frame[i] / maxIntensity, energy[i]); } } } double maxLow = max(energy, lowRangeStart, lowRangeEnd); double maxHi = max(energy, highRangeStart, highRangeEnd); if (maxHi < noSignalLevel && maxLow > signalLevel) return true; return false; } BandDetector(); }
BandDetector { public boolean bandwidth(String file) { source.setAudioFile(new File(file), ""); Data data; double energy[] = new double[bands]; while ((data = frontend.getData()) != null) { if (data instanceof DoubleData) { double maxIntensity = lowIntensity; double[] frame = ((DoubleData) data).getValues(); for (int i = 0; i < bands; i++) maxIntensity = Math.max(maxIntensity, frame[i]); if (maxIntensity <= lowIntensity) { continue; } for (int i = 0; i < bands; i++) { energy[i] = Math.max(frame[i] / maxIntensity, energy[i]); } } } double maxLow = max(energy, lowRangeStart, lowRangeEnd); double maxHi = max(energy, highRangeStart, highRangeEnd); if (maxHi < noSignalLevel && maxLow > signalLevel) return true; return false; } BandDetector(); static void main(String args[]); boolean bandwidth(String file); }
BandDetector { public boolean bandwidth(String file) { source.setAudioFile(new File(file), ""); Data data; double energy[] = new double[bands]; while ((data = frontend.getData()) != null) { if (data instanceof DoubleData) { double maxIntensity = lowIntensity; double[] frame = ((DoubleData) data).getValues(); for (int i = 0; i < bands; i++) maxIntensity = Math.max(maxIntensity, frame[i]); if (maxIntensity <= lowIntensity) { continue; } for (int i = 0; i < bands; i++) { energy[i] = Math.max(frame[i] / maxIntensity, energy[i]); } } } double maxLow = max(energy, lowRangeStart, lowRangeEnd); double maxHi = max(energy, highRangeStart, highRangeEnd); if (maxHi < noSignalLevel && maxLow > signalLevel) return true; return false; } BandDetector(); static void main(String args[]); boolean bandwidth(String file);  }