/** * Closes standard audio. */ public static void close() { line.drain(); line.stop(); }
line.drain(); line.close(); line = null;
line.drain(); line.close();
@Override public void stop() { if (line == null) { LOG.debug("Can't stop - sound wasn't started"); } LOG.debug("Stop sound"); line.drain(); line.stop(); line = null; }
line.drain();
line.drain();
byte[] buf = new byte[ 1 ];; AudioFormat af = new AudioFormat( (float )44100, 8, 1, true, false ); SourceDataLine sdl = AudioSystem.getSourceDataLine( af ); sdl.open(); sdl.start(); for( int i = 0; i < 1000 * (float )44100 / 1000; i++ ) { double angle = i / ( (float )44100 / 440 ) * 2.0 * Math.PI; buf[ 0 ] = (byte )( Math.sin( angle ) * 100 ); sdl.write( buf, 0, 1 ); } sdl.drain(); sdl.stop();
log.debug("Before write to line {}", line); line.write(buffer, 0, buffer.length); line.drain(); line.stop(); log.debug("Line completed: {}", line);
public static void tone(int hz, int msecs, double vol) { try { byte[] buf = new byte[1]; AudioFormat af = new AudioFormat( SAMPLE_RATE, // sampleRate 8, // sampleSizeInBits 1, // channels true, // signed false); // bigEndian SourceDataLine sdl; sdl = AudioSystem.getSourceDataLine(af); sdl.open(af); sdl.start(); for (int i=0; i < msecs*8; i++) { double angle = i / (SAMPLE_RATE / hz) * 2.0 * Math.PI; buf[0] = (byte)(Math.sin(angle) * 127.0 * vol); sdl.write(buf,0,1); } sdl.drain(); sdl.stop(); sdl.close(); } catch (Exception e) { } }
public static void tone(int hz, int msecs, double vol) { try { byte[] buf = new byte[1]; AudioFormat af = new AudioFormat( SAMPLE_RATE, // sampleRate 8, // sampleSizeInBits 1, // channels true, // signed false); // bigEndian SourceDataLine sdl; sdl = AudioSystem.getSourceDataLine(af); sdl.open(af); sdl.start(); for (int i=0; i < msecs*8; i++) { double angle = i / (SAMPLE_RATE / hz) * 2.0 * Math.PI; buf[0] = (byte)(Math.sin(angle) * 127.0 * vol); sdl.write(buf,0,1); } sdl.drain(); sdl.stop(); sdl.close(); } catch (Exception e) { } }
public static void tone(int hz, int msecs, double vol) { try { byte[] buf = new byte[1]; AudioFormat af = new AudioFormat( SAMPLE_RATE, // sampleRate 8, // sampleSizeInBits 1, // channels true, // signed false); // bigEndian SourceDataLine sdl; sdl = AudioSystem.getSourceDataLine(af); sdl.open(af); sdl.start(); for (int i=0; i < msecs*8; i++) { double angle = i / (SAMPLE_RATE / hz) * 2.0 * Math.PI; buf[0] = (byte)(Math.sin(angle) * 127.0 * vol); sdl.write(buf,0,1); } sdl.drain(); sdl.stop(); sdl.close(); } catch (Exception e) { } }
protected void flushImpl() { if (source!=null) { source.drain(); } }
/** * Closes standard audio. */ public static void close() { line.drain(); line.stop(); }
/** * Stop the clip playing */ public void stop() { if (stopped()) { return; } player = null; outputLine.drain(); }
public void close(){ if(myOutputLine != null){ myOutputLine.drain(); myOutputLine.close(); } } }
/** * Close standard audio. */ public static void close() { line.drain(); line.stop(); }
@Override public void drain(MediaPlayer mediaPlayer) { System.out.println("drain()"); dataLine.drain(); } }
@Override public void cleanUp() { if (sourceDataLine != null) { sourceDataLine.drain(); sourceDataLine.stop(); sourceDataLine.close(); } }
@Override public void stop() { super.stop(); first = false; if (sourceDataLine != null) { sourceDataLine.drain(); sourceDataLine.close(); } }
private SourceDataLine getOutputLine(int channels, int rate) { if (outputLine == null || this.rate != rate || this.channels != channels) { if (outputLine != null) { outputLine.drain(); outputLine.stop(); outputLine.close(); } initJavaSound(channels, rate); outputLine.start(); } return outputLine; }