Package javax.sound.sampled

Examples of javax.sound.sampled.SourceDataLine.drain()


            }
        } catch (IOException e) {
            e.printStackTrace();
            return;
        } finally {
            auline.drain();
            auline.close();
        }
    }
}
View Full Code Here


                    byte[] buf = new byte[ 65536 ];
                    for ( int n = 0; (n = ais.read( buf, 0, buf.length )) > 0; )
                    {
                        sdl.write( buf, 0, n );
                    }
                    sdl.drain();
                    sdl.close();
                }
                catch ( Exception e )
                {
                    Common.hadleErrorMessage( e, "無法播放" + audioFileString );
View Full Code Here

                    nBytesWritten = line.write(data, 0, nBytesRead);
                }
            }

            // stop line
            line.drain();
            line.stop();
            line.close();

            // stop input stream
            dataIn.close();
View Full Code Here

      shortBuf.put(samples);
      sourceDataLine.write(rawSamples, 0, rawSamples.length);
    }

    // Shutdown.
    sourceDataLine.drain();
    sourceDataLine.stop();
    sourceDataLine.close();
  }
}
View Full Code Here

            }
        } catch (IOException e) {
            e.printStackTrace();
            return;
        } finally {
            auline.drain();
            mute();
            auline.close();
        }
      }
View Full Code Here

                        byte[] buf = new byte[(int) (SAMPLE_RATE * seconds)];
                        for (int i = 0; i < buf.length; i++) {
                            buf[i] = (byte) (Math.sin(RAD * frequency / SAMPLE_RATE * i) * 64.0 / Math.sqrt(i));
                        }
                        source.write(buf, 0, buf.length);
                        source.drain();
                        source.stop();
                        source.close();
                    } catch (Exception e) {
                        System.out.println(e);
                    }
View Full Code Here

            }
        } catch (IOException e) {
            e.printStackTrace();
            return;
        } finally {
            auline.drain();
            auline.close();
        }

    }
}
View Full Code Here

            }
        } catch (IOException e) {
            e.printStackTrace();
            return;
        } finally {
            auline.drain();
            auline.close();
        }

    }
}
View Full Code Here

            // first play the whole scale
            WaveMelodyGenerator.playScale(line, scaleFrequencies);
            // then generate a random melody in the scale
            WaveMelodyGenerator.playMelody(line, scaleFrequencies);

            line.drain();
            line.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

                            if (nBytesRead < 0) { break; }
                            audioOutputLine.write(abData, 0, nBytesRead); // => int nBytesWritten
                            command.possiblyInterrupt();
                        }
                        // end of audio, clean up
                        audioOutputLine.drain();
                        audioOutputLine.close();
                        audioOutputLine = null;
                        Utils.close(audioInputStream);
                        audioInputStream = null;
                        playingUrl = null;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.