iaudiorecorder.java

来自「JAVA录音和播放」· Java 代码 · 共 82 行

JAVA
82
字号
/*
 * IAudioRecorder.java
 *
 * Created on 2007年3月19日, 上午1:48
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package audio;

import javax.sound.sampled.AudioFormat;

/**
 *
 * @author 吕硕
 */
public interface IAudioRecorder 
{
    /**
     * Default AudioFormat with the folowing settings: Sampling rate = 44.1 kHz,
     * Sample Size = 16 bits, Num Channels = 2 (stareo), Frame Size = 4,
     * Frame Rate = 44.1 kHz (same as Sampling Rate), little endiain = false.
     * </br>
     * @see javax.sound.sampled.AudioFormat
     */
    public static final AudioFormat DEFAULT_AUDIO_FORMAT = new AudioFormat
    (
            AudioFormat.Encoding.PCM_SIGNED,
            44100.0f, //44.1 kHz sampling rate = CD quality audio
            16, //1 bytes, 8 bit audio (1 * 8 bit byte)
            1, //1 channels, stereo
            2, //frame size = number of bytes in a sample * number of channels = Default WAVE
            44100, //frame rate = sampling rate = Default WAVE
            false //little endian = Default WAVE
    );

    /**
     * Default Buffer Size used for recording. This is the amount to record in each
     * succesive read() call while recording.
     *
     * @see javax.sound.sampled.TargetDataLine#read
     */
    public static final int bufSize = 16384;


    /**
     * Starts recording
     *
     * @throws Exception
     */
    public void startRecording() throws Exception;

    /**
     * Stops recording or playback
     */
    public void stopRecording();

    /**
     * Clears the current recorded audio in buffer (if any)
     */
    public void reset();


    /**
     * @param format The AudioFormat to use for recording
     * @see javax.sound.sampled.AudioFormat
     */
    public void setAudioFormat(AudioFormat format);

    /**
     * @return the current AudioFormat used for recording
     * @see javax.sound.sampled.AudioFormat
     */
    public AudioFormat getAudioFormat();

    /**
     * Sets default audio format for recording
     */
    public void setDefaultAudioFormat();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?