亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

direktori cari
android Manifest Manifest.permission Manifest.permission_group android.accessibilityservice AccessibilityService android.accounts Account android.app NotificationManager android.bluetooth BluetoothAdapter BluetoothClass BluetoothClass.Device BluetoothClass.Device.Major BluetoothClass.Service BluetoothDevice BluetoothServerSocket BluetoothSocket android.content SharedPreferences android.database.sqlite SQLiteCursorDriver SQLiteOpenHelper android.graphics Bitmap android.location LocationListener Geocoder GpsStatus GpsStatus.Listener GpsStatus.NmeaListener GpsSatellite android.media AudioFormat AsyncPlayer AudioRecord AudioRecord.OnRecordPositionUpdateListener ThumbnailUtils AudioManager android.net TrafficStats MailTo LocalSocket android.os AsyncTask AsyncTask.Status CountDownTimer Message MessageQueue HandlerThread android.text Html android.util JsonWriter android.view ContextMenu ContextMenu.ContextMenuInfo Display ViewManager View ViewStub ViewTreeObserver ViewParent WindowManager GestureDetector Gravity MenuInflater ScaleGestureDetector SoundEffectConstants android.view.inputmethod InputConnection InputMethod InputMethodSession BaseInputConnection InputMethodManager android.widget AbsListView AbsListView.LayoutParams AbsListView.OnScrollListener AbsListView.RecyclerListener AbsoluteLayout AbsoluteLayout.LayoutParams AbsSeekBar AbsSpinner AdapterView AdapterView.AdapterContextMenuInfo AdapterView.OnItemLongClickListener AdapterView.OnItemSelectedListener AdapterView.OnItemClickListener AnalogClock BaseAdapter BaseExpandableListAdapter Button CheckBox CheckedTextView Checkable Chronometer Chronometer.OnChronometerTickListener CompoundButton CompoundButton.OnCheckedChangeListener CursorAdapter CursorTreeAdapter DatePicker DatePicker.OnDateChangedListener DialerFilter DigitalClock EditText Filter Filter.FilterListener Filter.FilterResults ExpandableListAdapter ExpandableListView.OnChildClickListener ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupCollapseListener ExpandableListView.OnGroupExpandListener Filterable Gallery Gallery.LayoutParams GridView GridLayout GridLayout.Alignment RadioGroup ImageView ImageView.ScaleType HorizontalScrollView ImageButton ImageSwitcher FilterQueryProvider ListAdapter ListView MediaController MultiAutoCompleteTextView MultiAutoCompleteTextView.CommaTokenizer MultiAutoCompleteTextView.Tokenizer QuickContactBadge RadioButton RatingBar RatingBar.OnRatingBarChangeListener RelativeLayout RemoteViews ResourceCursorAdapter ResourceCursorTreeAdapter Scroller ScrollView SearchView SearchView.OnCloseListener SearchView.OnQueryTextListener SearchView.OnSuggestionListener SeekBar SeekBar.OnSeekBarChangeListener SimpleAdapter SimpleAdapter.ViewBinder SimpleCursorAdapter SimpleCursorAdapter.CursorToStringConverter SimpleCursorAdapter.ViewBinder SimpleCursorTreeAdapter SimpleCursorTreeAdapter.ViewBinder SimpleExpandableListAdapter SlidingDrawer SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener SlidingDrawer.OnDrawerScrollListener Spinner SpinnerAdapter WrapperListAdapter TabHost TabHost.TabSpec TextView TimePicker TimePicker.OnTimeChangedListener Toast TableLayout TableLayout.LayoutParams TableRow TableRow.LayoutParams TabWidget TextSwitcher ToggleButton TwoLineListItem VideoView ViewAnimator ViewFlipper ViewSwitcher ViewSwitcher.ViewFactory ZoomButtonsController ZoomButtonsController.OnZoomListener ZoomButton ZoomControls dalvik.system DexFile
watak


AudioRecord

版本:Android 3.1 r1

結(jié)構(gòu)

繼承關(guān)系

public class AudioRecord extends Object

java.lang.Object

android.media.AudioRecord

類概述

AudioRecord類在Java應(yīng)用程序中管理音頻資源,用來記錄從平臺音頻輸入設(shè)備產(chǎn)生的數(shù)據(jù)。 通過AudioRecord對象來完成"pulling"(讀?。?shù)據(jù)。 應(yīng)用通過以下幾個方法負責立即從AudioRecord對象讀?。?/span> read(byte[], int, int), read(short[], int, int)read(ByteBuffer, int). 無論使用哪種音頻格式,使用AudioRecord是最方便的。

在創(chuàng)建AudioRecord對象時,AudioRecord會初始化,并和音頻緩沖區(qū)連接,用來緩沖新的音頻數(shù)據(jù)。 根據(jù)構(gòu)造時指定的緩沖區(qū)大小,來決定AudioRecord能夠記錄多長的數(shù)據(jù)。 從硬件設(shè)備讀取的數(shù)據(jù),應(yīng)小于整個記錄緩沖區(qū)。

內(nèi)部類

interface AudioRecord.OnRecordPositionUpdateListener

接口定義為:當AudioRecord 收到一個由setNotificationMarkerPosition(int)設(shè)置的通知標志,或由 setPositionNotificationPeriod(int)設(shè)置的周期更新記錄的進度狀態(tài)時,回調(diào)此接口。

常量

public static final int ERROR

表示操作失敗。

常量值: -1 (0xffffffff)

public static final int ERROR_BAD_VALUE

表示使用了一個不合理的值導(dǎo)致的失敗。

常量值: -2 (0xfffffffe)

public static final int ERROR_INVALID_OPERATION

表示不恰當?shù)姆椒▽?dǎo)致的失敗。

常量值: -3 (0xfffffffd)

public static final int RECORDSTATE_RECORDING

指示AudioRecord錄制狀態(tài)為“正在錄制”。

常量值: 3 (0x00000003)

public static final int RECORDSTATE_STOPPED

指示AudioRecord錄制狀態(tài)為“不在錄制”。

常量值: 1 (0x00000001)

public static final int STATE_INITIALIZED

指示AudioRecord準備就緒。

常量值: 1 (0x00000001)

public static final int STATE_UNINITIALIZED

指示AudioRecord狀態(tài)沒有初始化成功。

常量值: 0 (0x00000000)

public static final int SUCCESS

表示操作成功。

常量值: 0 (0x00000000)

構(gòu)造函數(shù)

public AudioRecord (int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes)

類構(gòu)造函數(shù)。

參數(shù)

audioSource 錄制源。 請見MediaRecorder.AudioSource錄制源定義。

sampleRateInHz 默認采樣率,單位Hz。 44100Hz是當前唯一能保證在所有設(shè)備上工作的采樣率,在一些設(shè)備上還有22050, 1600011025。

channelConfig 描述音頻通道設(shè)置。 請見CHANNEL_IN_MONO CHANNEL_IN_STEREO。 CHANNEL_IN_MONO保證能在所有設(shè)備上工作。

audioFormat 音頻數(shù)據(jù)保證支持此格式。 請見ENCODING_PCM_16BIT ENCODING_PCM_8BIT。

bufferSizeInBytes 在錄制過程中,音頻數(shù)據(jù)寫入緩沖區(qū)的總數(shù)(字節(jié))。 從緩沖區(qū)讀取的新音頻數(shù)據(jù)總會小于此值。 getMinBufferSize(int, int, int)返回AudioRecord 實例創(chuàng)建成功后的最小緩沖區(qū)。 設(shè)置的值比getMinBufferSize()還小則會導(dǎo)致初始化失敗。

異常

IllegalArgumentException

公共方法

public int getAudioFormat ()

返回設(shè)置的音頻數(shù)據(jù)格式。 請見ENCODING_PCM_16BIT ENCODING_PCM_8BIT。

public int getAudioSource ()

返回音頻錄制源。

參見

MediaRecorder.AudioSource

public int getChannelConfiguration ()

返回設(shè)置的頻道設(shè)置。 請見CHANNEL_IN_MONOCHANNEL_IN_STEREO

public int getChannelCount ()

返回設(shè)置的頻道數(shù)目。

public static int getMinBufferSize (int sampleRateInHz, int channelConfig, int audioFormat)

返回成功創(chuàng)建AudioRecord對象所需要的最小緩沖區(qū)大小。 注意:這個大小并不保證在負荷下的流暢錄制,應(yīng)根據(jù)預(yù)期的頻率來選擇更高的值,AudioRecord實例在推送新數(shù)據(jù)時使用此值。

參數(shù)

sampleRateInHz 默認采樣率,單位Hz

channelConfig 描述音頻通道設(shè)置。

請見CHANNEL_IN_MONOCHANNEL_IN_STEREO

audioFormat 音頻數(shù)據(jù)保證支持此格式。參見ENCODING_PCM_16BIT

返回值

如果硬件不支持錄制參數(shù),或輸入了一個無效的參數(shù),則返回ERROR_BAD_VALUE,如果硬件查詢到輸出屬性沒有實現(xiàn),或最小緩沖區(qū)用byte表示,則返回ERROR。

參見

更多信息請見有效的設(shè)置參數(shù)

public int getNotificationMarkerPosition ()

返回通知,標記框架中的位置。

public int getPositionNotificationPeriod ()

返回通知,更新框架中的時間位置。

public int getRecordingState ()

返回AudioRecord實例的錄制狀態(tài)。

參見

RECORDSTATE_STOPPED

RECORDSTATE_RECORDING

public int getSampleRate ()

返回設(shè)置的音頻數(shù)據(jù)樣本采樣率,單位Hz。

public int getState ()

返回AudioRecord實例的狀態(tài)。 這點非常有用,用在AudioRecord 實例創(chuàng)建成功后,檢查初始化屬性。 它能肯定請求到了合適的硬件資源。

參見

STATE_INITIALIZED

STATE_UNINITIALIZED

public int read (short[] audioData, int offsetInShorts, int sizeInShorts)

從音頻硬件錄制緩沖區(qū)讀取數(shù)據(jù)。

參數(shù)

audioData 寫入的音頻錄制數(shù)據(jù)。

offsetInShorts 目標數(shù)組 audioData 的起始偏移量。

sizeInShorts 請求讀取的數(shù)據(jù)大小。

返回值

返回short型數(shù)據(jù),表示讀取到的數(shù)據(jù),如果對象屬性沒有初始化,則返回ERROR_INVALID_OPERATION,如果參數(shù)不能解析成有效的數(shù)據(jù)或索引,則返回ERROR_BAD_VALUE 返回數(shù)值不會超過sizeInShorts。

public int read (byte[] audioData, int offsetInBytes, int sizeInBytes)

從音頻硬件錄制緩沖區(qū)讀取數(shù)據(jù)。

參數(shù)

audioData 寫入的音頻錄制數(shù)據(jù)。

offsetInBytes audioData的起始偏移值,單位byte。

sizeInBytes 讀取的最大字節(jié)數(shù)。

返回值

讀入緩沖區(qū)的總byte數(shù),如果對象屬性沒有初始化,則返回ERROR_INVALID_OPERATION,如果參數(shù)不能解析成有效的數(shù)據(jù)或索引,則返回ERROR_BAD_VALUE 讀取的總byte數(shù)不會超過sizeInBytes。

public int read (ByteBuffer audioBuffer, int sizeInBytes)

從音頻硬件錄制緩沖區(qū)讀取數(shù)據(jù),直接復(fù)制到指定緩沖區(qū)。 如果audioBuffer不是直接的緩沖區(qū),此方法總是返回0。

參數(shù)

audioBuffer 存儲寫入音頻錄制數(shù)據(jù)的緩沖區(qū)。

sizeInBytes 請求的最大字節(jié)數(shù)。

返回值

讀入緩沖區(qū)的總byte數(shù),如果對象屬性沒有初始化,則返回ERROR_INVALID_OPERATION,如果參數(shù)不能解析成有效的數(shù)據(jù)或索引,則返回ERROR_BAD_VALUE。 讀取的總byte數(shù)不會超過sizeInBytes。

public void release ()

釋放本地AudioRecord資源。 對象不能經(jīng)常使用此方法,而且在調(diào)用release()后,必須設(shè)置引用為null。

public int setNotificationMarkerPosition (int markerInFrames)

如果設(shè)置了setRecordPositionUpdateListener(OnRecordPositionUpdateListener)setRecordPositionUpdateListener(OnRecordPositionUpdateListener, Handler),則通知監(jiān)聽者設(shè)置位置標記。

參數(shù)

markerInFrames 在框架中快速標記位置。

返回值

返回錯誤或成功代碼,請見SUCCESS、ERROR_BAD_VALUE、ERROR_INVALID_OPERATION

public int setPositionNotificationPeriod (int periodInFrames)

如果設(shè)置了setRecordPositionUpdateListener(OnRecordPositionUpdateListener)setRecordPositionUpdateListener(OnRecordPositionUpdateListener, Handler),則通知監(jiān)聽者設(shè)置時間標記。

參數(shù)

markerInFrames 在框架中快速更新時間標記。

返回值

返回錯誤或成功代碼,請見SUCCESSERROR_INVALID_OPERATION。

public void setRecordPositionUpdateListener (AudioRecord.OnRecordPositionUpdateListener listener, Handler handler)

當之前設(shè)置的標志已經(jīng)成立,或者周期錄制位置更新時,設(shè)置處理監(jiān)聽者。 使用此方法來將Handler 和別的線程聯(lián)系起來,來接收AudioRecord 事件,比創(chuàng)建AudioTrack 實例更好一些。

參數(shù)

handler 用來接收事件通知消息。

public void setRecordPositionUpdateListener (AudioRecord.OnRecordPositionUpdateListener listener)

當之前設(shè)置的標志已經(jīng)成立,或者周期錄制位置更新時,設(shè)置處理監(jiān)聽者。

public void startRecording ()

AudioRecord實例開始進行錄制。

異常

IllegalStateException

受保護方法

protected void finalize ()

通知VM回收此對象內(nèi)存。 此方法只能用在運行的應(yīng)用程序沒有任何線程再使用此對象,來告訴垃圾回收器回收此對象。

此方法用于釋放系統(tǒng)資源,由垃圾回收器清除此對象。 默認沒有實現(xiàn),由VM來決定,但子類根據(jù)需要可重寫finalize()。 在執(zhí)行期間,調(diào)用此方法可能會立即拋出未定義異常,但是可以忽略。

注意:VM保證對象可以一次或多次調(diào)用finalize(),但并不保證finalize()會馬上執(zhí)行。 例如,對象Bfinalize()可能延遲執(zhí)行,等待對象Afinalize()延遲回收A的內(nèi)存。 為了安全起見,請看ReferenceQueue,它提供了更多地控制VM的垃圾回收。

補充

文章精選

Android提高第十篇之AudioRecord實現(xiàn)"助聽器"

Android入門(9AudioRecordAudioTrack類的使用

Android多媒體學(xué)習(xí)十:利AudioRecord類實現(xiàn)自己的音頻錄制程序


Artikel sebelumnya: Artikel seterusnya: