亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? animatedaudioplayer.java

?? 使用Exlipse編寫的一個語音程序
?? JAVA
字號:
/** * Copyright 2001 Sun Microsystems, Inc. *  * See the file "license.terms" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL  * WARRANTIES. */package com.sun.speech.freetts.audio;import javax.sound.sampled.*;import com.sun.speech.freetts.util.BulkTimer;/** * Provides an implementation of <code>AudioPlayer</code> that creates * javax.sound.sampled audio clips and outputs them via the * javax.sound API.  The interface provides a highly reliable audio * output package. Since audio is batched and not sent to the audio * layer until an entire utterance has been processed, this player has * higher latency (50 msecs for a typical 4 second utterance). * * The system property: * <code>	com.sun.speech.freetts.audio.AudioPlayer.debug; * </code> if set to <code>true</code> will cause this * class to emit debugging information (useful to a developer). */public class AnimatedAudioPlayer implements AudioPlayer {        private volatile boolean paused;    private volatile boolean done = false;    private volatile boolean cancelled = false;    private volatile Clip currentClip;    private float volume = 1.0f;  // the current volume    private boolean debug = false;    private BulkTimer timer = new BulkTimer();    private AudioFormat defaultFormat = // default format is 8khz	new AudioFormat(8000f, 16, 1, true, true);    private AudioFormat currentFormat = defaultFormat;    private boolean firstSample = true;    private int curIndex = 0;    private byte[] outputData;    private LineListener lineListener = new JavaClipLineListener();    private long closeDelay;	// workaround for linux sound bug	private LineListener externalLineListener; // -- added by bd 	/**	 * Constructs a default AnimatedAudioPlayer 	 * -- modified by bd	 */	public AnimatedAudioPlayer(LineListener externalLineListener) {		this.externalLineListener = externalLineListener;		debug = Boolean.getBoolean			("com.sun.speech.freetts.audio.AudioPlayer.debug");		closeDelay = Long.getLong			("com.sun.speech.freetts.audio.AudioPlayer.closeDelay",				150L).longValue();		setPaused(false);	}    /**     * Sets the audio format for this player     *     * @param format the audio format     *     * @throws UnsupportedOperationException if the line cannot be opened with     *     the given format     */    public synchronized void setAudioFormat(AudioFormat format) {	currentFormat = format;    }    /**     * Retrieves the audio format for this player     *     * @return format the audio format     */    public AudioFormat getAudioFormat() {	return currentFormat;    }    /**     * Pauses audio output.   All audio output is      * stopped. Output can be resumed at the     * current point by calling <code>resume</code>. Output can be     * aborted by calling <code> cancel </code>     */    public synchronized void pause() {	if (!isPaused()) {	    setPaused(true);	    Clip clip = currentClip;	    if (clip != null) {	        clip.stop();	    }	}    }    /**     * Resumes playing audio after a pause.     *     */    public synchronized void resume() {	if (isPaused()) {	    setPaused(false);	    Clip clip = currentClip;	    if (clip != null) {		clip.start();	    }	    notify();	}    }	    /**     * Cancels all queued audio. Any 'write' in process will return     * immediately false.     */    public synchronized void cancel() {	cancelled = true;	Clip clip = currentClip;	if (clip != null) {	    clip.close();	}    }    /**     * Prepares for another batch of output. Larger groups of output     * (such as all output associated with a single FreeTTSSpeakable)     * should be grouped between a reset/drain pair.     */    public synchronized void reset() {	timer.start("speakableOut");    }    /**     * Waits for all queued audio to be played     *     * @return <code>true</code> if the write completed successfully,      *       	<code> false </code>if the write was cancelled.     */    public boolean drain()  {	timer.stop("speakableOut");	return true;    }    /**     * Closes this audio player     */    public synchronized void close() {	done = true;	notify();    }            /**     * Returns the current volume.     * @return the current volume (between 0 and 1)     */    public float getVolume() {	return volume;    }	          /**     * Sets the current volume.     * @param volume  the current volume (between 0 and 1)     */    public void setVolume(float volume) {	if (volume > 1.0f) {	    volume = 1.0f;	}	if (volume < 0.0f) {	    volume = 0.0f;	}	this.volume = volume;	Clip clip = currentClip;	if (clip != null) {	    setVolume(clip, volume);	}    }	          /**     * Sets pause mode     * @param state true if we are paused     */    private void setPaused(boolean state) {	paused = state;    }    /**     * Returns true if we are in pause mode     *     * @return <code> true </code>if paused;      *		otherwise returns <code>false</code>     */    private boolean isPaused() {	return paused;    }    /**     * Sets the volume on the given clip     *     * @param line the line to set the volume on     * @param vol the volume (range 0 to 1)     */    private void setVolume(Clip clip, float vol) {	if (clip.isControlSupported (FloatControl.Type.MASTER_GAIN)) {	    FloatControl volumeControl = 		(FloatControl) clip.getControl (FloatControl.Type.MASTER_GAIN);	    float range = volumeControl.getMaximum() -			  volumeControl.getMinimum();	    volumeControl.setValue(vol * range + volumeControl.getMinimum());	}    }    /**     * Returns the current position in the output stream since the     * last <code>resetTime</code>      *     * Currently not supported.     *     * @return the position in the audio stream in milliseconds     *     */    public synchronized long getTime()  {        return -1L;    }    /**     * Resets the time for this audio stream to zero     */    public synchronized void resetTime() {    }        /**     *  Starts the output of a set of data. Audio data for a single     *  utterance should be grouped between begin/end pairs.     *     * @param size the size of data between now and the end     *     */    public void begin(int size) {	cancelled = false;	timer.start("utteranceOutput");	curIndex = 0;	outputData = new byte[size];    }    /**     *  Marks the end a set of data. Audio data for a single utterance should     *  be grouped between begin/end pairs.     *     *  @return <code>true</code> if the audio was output properly,      * 		<code>false </code> if the output was cancelled      *		or interrupted.     */    public synchronized boolean  end()  {	boolean ok = true;	while (!done && !cancelled && isPaused()) {	    try { 		wait();	    } catch (InterruptedException ie) {		return false;	    }	}	if (done || cancelled) {	    cancelled = false;	    return false;	}	timer.start("clipGeneration");	try {	    DataLine.Info info = new DataLine.Info(Clip.class, currentFormat);	    Clip clip = (Clip) AudioSystem.getLine(info);	    clip.addLineListener(lineListener);	    clip.addLineListener(externalLineListener); // -- added by bd	    clip.open(currentFormat, outputData, 0, outputData.length);	    setVolume(clip, volume);	    if (currentClip != null) {		throw new IllegalStateException("clip already set");	    }	    currentClip = clip;	    clip.start();	    try {		while (currentClip != null) {		    wait();	// drain does not work 		}	    } catch (InterruptedException ie) {		ok = false;	    }	} catch (LineUnavailableException lue) {	    System.err.println("Line unavailable");	    System.err.println("Format is " + currentFormat);	    ok = false;	}	timer.stop("clipGeneration");	timer.stop("utteranceOutput");	ok = !cancelled;	cancelled = false;	return ok;    }        /**     * Writes the given bytes to the audio stream     *     * @param audioData audio data to write to the device     *     * @return <code>true</code> if the write completed successfully,      *       	<code> false </code>if the write was cancelled.     */    public boolean write(byte[] audioData) {	return write(audioData, 0, audioData.length);    }        /**     * Writes the given bytes to the audio stream     *     * @param bytes audio data to write to the device     * @param offset the offset into the buffer     * @param size the size into the buffer     *     * @return <code>true</code> if the write completed successfully,      *       	<code> false </code>if the write was cancelled.     */    public boolean write(byte[] bytes, int offset, int size) {	if (firstSample) {	    firstSample = false;	    timer.stop("firstAudio");	}	System.arraycopy(bytes, offset, outputData, curIndex, size);	curIndex += size;	return true;    }    /**     * Returns the name of this audio player     *     * @return the name of the audio player     */    public String toString() {	return "JavaClipAudioPlayer";    }    /**     * Outputs the given msg if debugging is enabled for this     * audio player.     */    private void debugPrint(String msg) {	if (debug) {	    System.out.println(toString() + ": " + msg);	}    }    /**     * Shows metrics for this audio player     */    public void showMetrics() {	timer.show(toString());    }    /**     * Starts the first sample timer     */    public void startFirstSampleTimer() {	timer.start("firstAudio");	firstSample = true;    }    /**     * Provides a LineListener for this clas.     */    private class JavaClipLineListener implements LineListener {	/**	 * Implements update() method of LineListener interface. Responds	 * to the line events as appropriate.	 *	 * @param event the LineEvent to handle	 */	public void update(LineEvent event) {	    if (event.getType().equals(LineEvent.Type.START)) {		debugPrint("Event  START");	    } else if (event.getType().equals(LineEvent.Type.STOP)) {		debugPrint("Event  STOP");		// A line may be stopped for three reasons:		//    the clip has finished playing		//    the clip has been paused		//    the clip has been cancelled (i.e. closed)		// if the clip has stopped because it has finished		// playing, then we should close the clip, otherwise leave		// it alone		synchronized(AnimatedAudioPlayer.this) {		    if (!cancelled && !isPaused()) {	// BUG:	// There is a javax.sound bug that causes a crash on linux	// it is described here:	// http://developer.java.sun.com/developer/bugParade/bugs/4498848.html	// The bug seems to be related to synchronization of the close	// call on the clip.  If we delay before the close by 	// a small amount, the crash is averted.  This is a WORKAROUND	// only and should be removed once the javax.sound bug is	// fixed.  We get the delay from the property:	//	// com.sun.speech.freetts.audio.AudioPlayer.closeDelay	// 	// 			try {			    if (closeDelay > 0L) {				Thread.sleep(closeDelay);			    }		    	} catch (InterruptedException ie) {			}			currentClip.close();		    }		}	    }  else if (event.getType().equals(LineEvent.Type.OPEN)) {		debugPrint("Event OPEN");	    }  else if (event.getType().equals(LineEvent.Type.CLOSE)) {		// When a clip is closed we no longer need it, so 		// set currentClip to null and notify anyone who may		// be waiting on it.		debugPrint("EVNT CLOSE");		synchronized (AnimatedAudioPlayer.this) {		    currentClip = null;		    AnimatedAudioPlayer.this.notify();		}	    }	}    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品久久久久久久久久久久久久久久久| 自拍偷拍国产精品| 亚洲国产精品成人综合| 亚洲午夜精品一区二区三区他趣| 精品一区二区三区免费播放| 91电影在线观看| 中文字幕一区二区三区蜜月| 日韩国产精品久久久| 在线免费不卡视频| 中文字幕精品三区| 国产精品一区不卡| 日韩三级av在线播放| 婷婷久久综合九色综合伊人色| 成人黄色大片在线观看| 久久综合av免费| 免费观看日韩电影| 91精品国产欧美一区二区18| 亚洲一区二区三区在线看| 99久久精品国产导航| 国产免费观看久久| 国产福利一区在线| 国产视频一区在线观看| 国产资源在线一区| 日韩免费福利电影在线观看| 日本一不卡视频| 欧美一卡在线观看| 日韩二区三区四区| 日韩天堂在线观看| 捆绑紧缚一区二区三区视频| 日韩欧美色电影| 狠狠色丁香久久婷婷综合丁香| 日韩欧美的一区二区| 久久99精品久久久久久动态图 | 日韩电影在线一区| 69久久夜色精品国产69蝌蚪网 | 久久精品视频免费| 国产成人免费高清| 中文字幕一区二区三区色视频| 成人免费毛片高清视频| 综合在线观看色| 97国产精品videossex| 亚洲日本一区二区| 欧美性videosxxxxx| 婷婷久久综合九色国产成人| 欧美一卡2卡三卡4卡5免费| 久久av资源网| 欧美激情在线观看视频免费| 99国产精品久久| 亚洲最快最全在线视频| 91精品欧美福利在线观看| 久久国产精品无码网站| 久久精品欧美日韩| 99久久精品99国产精品| 午夜欧美一区二区三区在线播放| 日韩欧美综合在线| 成人性生交大片免费看在线播放| 亚洲人精品午夜| 91精品国产综合久久久久久漫画| 六月婷婷色综合| 国产精品乱人伦| 欧美高清视频不卡网| 黑人精品欧美一区二区蜜桃| 自拍偷在线精品自拍偷无码专区| 欧美日韩一区不卡| 国产一区二区美女诱惑| 亚洲色图一区二区| 欧美大度的电影原声| av在线综合网| 日本va欧美va精品发布| 国产精品国产自产拍高清av| 91精品国产综合久久久久久| 国产精品亚洲午夜一区二区三区| 一区二区三区国产| 国产亚洲污的网站| 91麻豆精品国产91久久久更新时间 | 欧美性色黄大片手机版| 久久66热偷产精品| 一区二区在线观看av| 精品国产一区二区三区四区四| 91免费观看国产| 国产成人欧美日韩在线电影| 香蕉乱码成人久久天堂爱免费| 国产欧美一区二区三区沐欲| 91精品国产综合久久香蕉麻豆| av电影天堂一区二区在线| 精品系列免费在线观看| 亚洲资源中文字幕| 中文字幕中文乱码欧美一区二区| 日韩精品一区二区三区四区| 欧美日韩中字一区| 99re在线精品| 成人高清伦理免费影院在线观看| 精品一区二区在线观看| 午夜精品福利一区二区蜜股av| 中文字幕不卡在线播放| 久久中文娱乐网| 日韩三级在线观看| 欧美日韩精品是欧美日韩精品| 99久久伊人精品| 成人免费精品视频| 国产精品一区二区黑丝| 精品一区二区三区视频在线观看| 视频在线观看91| 亚洲国产精品一区二区久久| 亚洲欧美日韩中文播放| 亚洲欧洲www| 国产精品午夜久久| 国产精品欧美一区二区三区| 国产日韩精品一区二区三区| 久久久久久久久久久久久久久99| 日韩视频免费观看高清完整版在线观看| 欧美日韩一卡二卡| 欧美肥妇毛茸茸| 欧美军同video69gay| 3atv在线一区二区三区| 欧美一区二区三区成人| 日韩精品一区二区三区在线观看| 欧美一区二区三区视频在线| 在线不卡免费欧美| 欧美一区二区久久| 日韩精品一区二区在线| 2021国产精品久久精品| 国产亚洲人成网站| 国产精品电影一区二区三区| 亚洲日本在线a| 亚洲国产精品综合小说图片区| 天天操天天干天天综合网| 日韩激情一区二区| 国产一区欧美二区| 成人av网站在线观看| 一本色道亚洲精品aⅴ| 欧美日韩国产中文| 欧美成人精品1314www| 国产日产欧美一区二区视频| 国产精品久久久久久久久久久免费看 | 久久久久久毛片| 国产精品久久久久aaaa| 一区二区三区免费网站| 秋霞av亚洲一区二区三| 国产成人8x视频一区二区| 成人av高清在线| 欧美伊人久久久久久久久影院| 4438x成人网最大色成网站| 久久久久88色偷偷免费 | 久久精品欧美一区二区三区不卡| 国产精品美女久久久久高潮| 亚洲午夜电影在线| 国内欧美视频一区二区| 一本色道久久综合狠狠躁的推荐| 欧美一区二区三区在线视频| 国产日韩欧美精品在线| 亚洲成人av电影在线| 国产精品77777竹菊影视小说| 91小视频在线| 精品播放一区二区| 亚洲精品日产精品乱码不卡| 久久er精品视频| 在线观看亚洲一区| 国产午夜精品久久久久久免费视 | 久久精品国产精品亚洲综合| 成人午夜伦理影院| 欧美剧情片在线观看| 国产女同互慰高潮91漫画| 天堂成人国产精品一区| 成人黄色一级视频| 欧美tk—视频vk| 亚洲v精品v日韩v欧美v专区| 成人高清免费在线播放| 精品国产乱码久久久久久浪潮| 亚洲免费av在线| 国产成人av一区二区三区在线观看| 欧美日韩日本视频| 亚洲男女一区二区三区| 国产成人在线电影| 欧美一级二级三级乱码| 亚洲自拍偷拍九九九| 成人激情小说网站| 欧美精品一区在线观看| 欧美a级一区二区| 欧美日韩在线播放| 亚洲视频在线观看一区| 国产福利一区在线观看| 精品国产亚洲一区二区三区在线观看 | 欧美视频在线一区二区三区| 亚洲啪啪综合av一区二区三区| 国产精品自产自拍| 久久综合精品国产一区二区三区| 日本视频一区二区三区| 欧美人妖巨大在线| 亚洲图片有声小说| 欧美亚洲国产一卡| 亚洲在线观看免费| 欧美亚洲高清一区二区三区不卡| 亚洲区小说区图片区qvod| 91在线云播放| 亚洲另类春色校园小说| 91成人在线免费观看| 亚洲一二三区不卡| 欧美夫妻性生活| 麻豆国产欧美日韩综合精品二区 |