java类javax.sound.sampled.AudioFileFormat.Type的实例源码

WaveFloatFileWriter.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 19 收藏 0 点赞 0 评论 0
private void checkFormat(AudioFileFormat.Type type, AudioInputStream stream) {
    if (!Type.WAVE.equals(type))
        throw new IllegalArgumentException("File type " + type
                + " not supported.");
    if (!stream.getFormat().getEncoding().equals(Encoding.PCM_FLOAT))
        throw new IllegalArgumentException("File format "
                + stream.getFormat() + " not supported.");
}
WaveFloatFileWriter.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 22 收藏 0 点赞 0 评论 0
public int write(AudioInputStream stream, Type fileType, OutputStream out)
        throws IOException {

    checkFormat(fileType, stream);
    if (stream.getFormat().isBigEndian())
        stream = toLittleEndian(stream);
    RIFFWriter writer = new RIFFWriter(new NoCloseOutputStream(out), "WAVE");
    write(stream, writer);
    int fpointer = (int) writer.getFilePointer();
    writer.close();
    return fpointer;
}
WaveFloatFileWriter.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 18 收藏 0 点赞 0 评论 0
public int write(AudioInputStream stream, Type fileType, File out)
        throws IOException {
    checkFormat(fileType, stream);
    if (stream.getFormat().isBigEndian())
        stream = toLittleEndian(stream);
    RIFFWriter writer = new RIFFWriter(out, "WAVE");
    write(stream, writer);
    int fpointer = (int) writer.getFilePointer();
    writer.close();
    return fpointer;
}
WaveFloatFileWriter.java 文件源码 项目:TuxGuitar-1.3.1-fork 阅读 21 收藏 0 点赞 0 评论 0
public Type[] getAudioFileTypes(AudioInputStream stream) {

        if (!stream.getFormat().getEncoding().equals(
                AudioFloatConverter.PCM_FLOAT))
            return new Type[0];
        return new Type[] { Type.WAVE };
    }
WaveFloatFileWriter.java 文件源码 项目:TuxGuitar-1.3.1-fork 阅读 18 收藏 0 点赞 0 评论 0
private void checkFormat(AudioFileFormat.Type type, AudioInputStream stream) {
    if (!Type.WAVE.equals(type))
        throw new IllegalArgumentException("File type " + type
                + " not supported.");
    if (!stream.getFormat().getEncoding().equals(
            AudioFloatConverter.PCM_FLOAT))
        throw new IllegalArgumentException("File format "
                + stream.getFormat() + " not supported.");
}
WaveFloatFileWriter.java 文件源码 项目:TuxGuitar-1.3.1-fork 阅读 18 收藏 0 点赞 0 评论 0
public int write(AudioInputStream stream, Type fileType, OutputStream out)
        throws IOException {

    checkFormat(fileType, stream);
    if (stream.getFormat().isBigEndian())
        stream = toLittleEndian(stream);
    RIFFWriter writer = new RIFFWriter(new NoCloseOutputStream(out), "WAVE");
    write(stream, writer);
    int fpointer = (int) writer.getFilePointer();
    writer.close();
    return fpointer;
}
WaveFloatFileWriter.java 文件源码 项目:TuxGuitar-1.3.1-fork 阅读 23 收藏 0 点赞 0 评论 0
public int write(AudioInputStream stream, Type fileType, File out)
        throws IOException {
    checkFormat(fileType, stream);
    if (stream.getFormat().isBigEndian())
        stream = toLittleEndian(stream);
    RIFFWriter writer = new RIFFWriter(out, "WAVE");
    write(stream, writer);
    int fpointer = (int) writer.getFilePointer();
    writer.close();
    return fpointer;
}
GstAudioFileWriter.java 文件源码 项目:javify 阅读 17 收藏 0 点赞 0 评论 0
@Override
public int write(AudioInputStream ais, Type type, File out)
    throws IOException
{
  // TODO Auto-generated method stub
  return 0;
}
GstAudioFileWriter.java 文件源码 项目:javify 阅读 19 收藏 0 点赞 0 评论 0
@Override
public int write(AudioInputStream ais, Type type, OutputStream os)
    throws IOException
{
  // TODO Auto-generated method stub
  return 0;
}
PdOffline.java 文件源码 项目:gdx-pd 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Bake a path to a wav file
 * @param patch the patch to bake
 * @param wav the wav file to write
 * @param channels how many channels (1 for mono, 2 for stereo, can be more than 2 channels)
 * @param sampleRate sample rate used by Pd
 * @param time baking duration in seconds
 * @throws IOException
 */
public static void bake(File patch, File wav, int channels, int sampleRate, float time) throws IOException {

    // disable Pd : does nothing if Pd alreay initialized.
    PdConfiguration.disabled = true;

    // Pause audio.
    // Does nothing in headless mode but required to 
    // have Pd static code executed (load library)
    Pd.audio.pause();

    int handle = PdBase.openPatch(patch);
    PdBase.openAudio(0, channels, sampleRate);
    PdBase.computeAudio(true);

    int frames = (int)(time * sampleRate);
    int samples = frames * channels;
    short [] data = new short[samples];
    int ticks = frames / PdBase.blockSize();
    PdBase.process(ticks, new short[]{}, data);

    PdBase.closePatch(handle);

    // save
    byte [] buf = new byte[data.length * 2];
    for(int i=0 ; i<data.length ; i++){
        buf[i*2+0] = (byte)(data[i] & 0xFF);
        buf[i*2+1] = (byte)((data[i] >> 8) & 0xFF);
    }

    ByteArrayInputStream stream = new ByteArrayInputStream(buf);
    AudioFormat format = new AudioFormat(sampleRate, 16, channels, true, false);
    AudioInputStream audioStream = new AudioInputStream(stream, format, data.length);
    AudioSystem.write(audioStream, Type.WAVE, wav);

    // resume audio
    Pd.audio.resume();
}


问题


面经


文章

微信
公众号

扫码关注公众号