/** * Chainable constructor * @param as The audio stream to process */ public BeatDetector( final AudioStream as ) { this( as, as.getFormat() ); }
/** * Chainable constructor * @param as The audio stream to process */ public BeatDetector( final AudioStream as ) { this( as, as.getFormat() ); }
/** * Create a new looper that will loop the given stream the given number * of times. Whether the stream is cached or not is able to be specified. * * @param stream The stream to loop * @param nLoops The number of loops to do * @param cacheStream Whether to cache the stream or not */ public AudioLooper( AudioStream stream, int nLoops, boolean cacheStream ) { this.stream = stream; this.nLoops = nLoops; this.cacheStream = cacheStream; this.format = stream.getFormat(); if( cacheStream ) streamCache = new ArrayList<SampleChunk>(); }
/** * Create a new looper that will loop the given stream the given number * of times. Whether the stream is cached or not is able to be specified. * * @param stream The stream to loop * @param nLoops The number of loops to do * @param cacheStream Whether to cache the stream or not */ public AudioLooper( AudioStream stream, int nLoops, boolean cacheStream ) { this.stream = stream; this.nLoops = nLoops; this.cacheStream = cacheStream; this.format = stream.getFormat(); if( cacheStream ) streamCache = new ArrayList<SampleChunk>(); }
/** * Sets the underlying stream, allowing it to be changed. * * @param stream * The stream */ public void setUnderlyingStream(final AudioStream stream) { this.stream = stream; if (stream != null) this.format = stream.getFormat().clone(); }
/** * Construct a new processor based on the given stream. This processor can * then be used as a stream itself in a chain. * * @param a * The audio stream to process. */ public AudioProcessor(final AudioStream a) { this.stream = a; if (a != null) this.format = a.getFormat().clone(); }
/** * Sets the underlying stream, allowing it to be changed. * * @param stream * The stream */ public void setUnderlyingStream(final AudioStream stream) { this.stream = stream; if (stream != null) this.format = stream.getFormat().clone(); }
/** * Construct a new processor based on the given stream. This processor can * then be used as a stream itself in a chain. * * @param a * The audio stream to process. */ public AudioProcessor(final AudioStream a) { this.stream = a; if (a != null) this.format = a.getFormat().clone(); }
/** * Construct with given stream and window parameters. Note that the window * parameters are given in milliseconds and converted into a number of * samples by the method. * * @param stream The audio stream * @param windowSizeMillis The window size in milliseconds * @param overlapMillis The overlap between windows in milliseconds */ public EffectiveSoundPressure( final AudioStream stream, final int windowSizeMillis, final int overlapMillis ) { super( stream, (int) (stream.getFormat().getSampleRateKHz() * windowSizeMillis * stream.getFormat().getNumChannels()) ); this.setWindowStep( (int) (stream.getFormat().getSampleRateKHz() * overlapMillis * stream.getFormat().getNumChannels()) ); }
/** * Construct with given stream and window parameters. Note that the window * parameters are given in milliseconds and converted into a number of * samples by the method. * * @param stream The audio stream * @param windowSizeMillis The window size in milliseconds * @param overlapMillis The overlap between windows in milliseconds */ public EffectiveSoundPressure( final AudioStream stream, final int windowSizeMillis, final int overlapMillis ) { super( stream, (int) (stream.getFormat().getSampleRateKHz() * windowSizeMillis * stream.getFormat().getNumChannels()) ); this.setWindowStep( (int) (stream.getFormat().getSampleRateKHz() * overlapMillis * stream.getFormat().getNumChannels()) ); }
this.audioFormat = as.getFormat().clone(); new Thread( new Runnable()
/** * Open a line to the Java Sound APIs. * * @throws Exception * if the Java sound system could not be initialised. */ private void openJavaSound() throws Exception { try { // Get a line (either the one we ask for, or any one). if (this.deviceName != null) this.mLine = AudioUtils.getJavaOutputLine(this.deviceName, this.stream.getFormat()); else this.mLine = AudioUtils.getAnyJavaOutputLine(this.stream.getFormat()); if (this.mLine == null) throw new Exception("Cannot instantiate a sound line."); // If no exception has been thrown we open the line. this.mLine.open(this.mLine.getFormat(), (int) (this.stream.getFormat().getSampleRateKHz() * this.soundLineBufferSize)); // If we've opened the line, we start it running this.mLine.start(); System.out.println("Opened Java Sound Line: " + this.mLine.getFormat()); } catch (final LineUnavailableException e) { throw new Exception("Could not open Java Sound audio line for" + " the audio format " + this.stream.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 { try { // Get a line (either the one we ask for, or any one). if (this.deviceName != null) this.mLine = AudioUtils.getJavaOutputLine(this.deviceName, this.stream.getFormat()); else this.mLine = AudioUtils.getAnyJavaOutputLine(this.stream.getFormat()); if (this.mLine == null) throw new Exception("Cannot instantiate a sound line."); // If no exception has been thrown we open the line. this.mLine.open(this.mLine.getFormat(), (int) (this.stream.getFormat().getSampleRateKHz() * this.soundLineBufferSize)); // If we've opened the line, we start it running this.mLine.start(); System.out.println("Opened Java Sound Line: " + this.mLine.getFormat()); } catch (final LineUnavailableException e) { throw new Exception("Could not open Java Sound audio line for" + " the audio format " + this.stream.getFormat()); } }
/** * Chainable constructor that takes the stream to chain and the * output format to convert the stream to. * @param stream The stream to chain to * @param output The required output format */ public AudioConverter( final AudioStream stream, final AudioFormat output ) { super( stream ); this.inputFormat = stream.getFormat().clone(); this.setFormat( output.clone() ); this.processor = AudioConverter.calculateProcess( this.inputFormat, output ); }
/** * Chainable constructor that takes the stream to chain and the * output format to convert the stream to. * @param stream The stream to chain to * @param output The required output format */ public AudioConverter( final AudioStream stream, final AudioFormat output ) { super( stream ); this.inputFormat = stream.getFormat().clone(); this.setFormat( output.clone() ); this.processor = AudioConverter.calculateProcess( this.inputFormat, output ); }
this.nSamplesPerPixel, this.data.getFormat().getNumChannels());
final double sampleRate = audioStream.getFormat().getSampleRateKHz() * 1000;
final double sampleRate = audioStream.getFormat().getSampleRateKHz() * 1000;