/** * Open a line to the Java Sound APIs. * * @throws Exception * if the Java sound system could not be initialised. */ private void openJavaSound() throws Exception { // Convert the OpenIMAJ audio format to a Java Sound audio format object final javax.sound.sampled.AudioFormat audioFormat = new javax.sound.sampled.AudioFormat( (int) (this.getFormat().getSampleRateKHz() * 1000), this .getFormat().getNBits(), this.getFormat() .getNumChannels(), this.getFormat().isSigned(), this .getFormat().isBigEndian()); System.out.println("Creating Java Sound Line with " + this.getFormat()); // Create info to create an output data line final DataLine.Info info = new DataLine.Info(TargetDataLine.class, audioFormat); try { // Get the output line to write to using the given // sample format we just created. this.mLine = (TargetDataLine) AudioSystem.getLine(info); // If no exception has been thrown we open the line. this.mLine.open(audioFormat); } catch (final LineUnavailableException e) { throw new Exception("Could not open Java Sound audio line for" + " the audio format " + this.getFormat()); } }
/** * Open a line to the Java Sound APIs. * * @throws Exception * if the Java sound system could not be initialised. */ private void openJavaSound() throws Exception { // Convert the OpenIMAJ audio format to a Java Sound audio format object final javax.sound.sampled.AudioFormat audioFormat = new javax.sound.sampled.AudioFormat( (int) (this.getFormat().getSampleRateKHz() * 1000), this .getFormat().getNBits(), this.getFormat() .getNumChannels(), this.getFormat().isSigned(), this .getFormat().isBigEndian()); System.out.println("Creating Java Sound Line with " + this.getFormat()); // Create info to create an output data line final DataLine.Info info = new DataLine.Info(TargetDataLine.class, audioFormat); try { // Get the output line to write to using the given // sample format we just created. this.mLine = (TargetDataLine) AudioSystem.getLine(info); // If no exception has been thrown we open the line. this.mLine.open(audioFormat); } catch (final LineUnavailableException e) { throw new Exception("Could not open Java Sound audio line for" + " the audio format " + this.getFormat()); } }
/** * From * http://www.javadocexamples.com/java_source/ccs/chaos/NoiseGrabber.java * .html Not sure if this will work for non 44.1KHz samples? * * @return */ private int calculateBufferSize() { final int nmax = (this.maxBufferSize == -1 ? this.mLine.getBufferSize() / 4 : this.maxBufferSize); final int[] FAC44100 = { 7, 7, 5, 5, 3, 3, 2, 2 }; int nwad = 1; for (int i = 0; i < 8; i++) if (nwad * FAC44100[i] <= nmax) nwad *= FAC44100[i]; return nwad << (this.getFormat().getNBits() / 8); }
/** * From * http://www.javadocexamples.com/java_source/ccs/chaos/NoiseGrabber.java * .html Not sure if this will work for non 44.1KHz samples? * * @return */ private int calculateBufferSize() { final int nmax = (this.maxBufferSize == -1 ? this.mLine.getBufferSize() / 4 : this.maxBufferSize); final int[] FAC44100 = { 7, 7, 5, 5, 3, 3, 2, 2 }; int nwad = 1; for (int i = 0; i < 8; i++) if (nwad * FAC44100[i] <= nmax) nwad *= FAC44100[i]; return nwad << (this.getFormat().getNBits() / 8); }
new HanningAudioProcessor(xa, this.img.getWidth() * xa.getFormat().getNumChannels())
new HanningAudioProcessor(xa, this.img.getWidth() * xa.getFormat().getNumChannels())