StretchedAudioInputStream.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:pumpernickel 作者:
/** Create a StretchedAudioInputStream that distorts the incoming
 * audio so it matches a fixed number of frames.
 * 
 * @param in the AudioInputStream to stretch.
 * @param frames the number of frames the input stream should be stretched to.
 * @throws IOException if an IO problem occurs.
 */
public static StretchedAudioInputStream create(AudioInputStream in,long frames) throws IOException {
    AudioFormat format = in.getFormat();
    if(!(format.getEncoding().equals(Encoding.PCM_SIGNED) ||
            format.getEncoding().equals(Encoding.PCM_UNSIGNED) ))
        throw new IllegalArgumentException("the audio input must be PCM-encoded data (found "+format.getEncoding()+")");

    PipedInputStream pipedIn = new PipedInputStream();
    PipedOutputStream pipedOut = new PipedOutputStream(pipedIn);

    /** One flaw with this model is that we always generate ALL the
     * transformed data: even if the entity working with pipedIn
     * is trying to skip large chunks of data.
     */

    Thread thread = new StretchThread(in, format, frames, pipedOut);
    thread.start();
    return new StretchedAudioInputStream( pipedIn, format, frames);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号