課 程 設 計 (1) 框架
原文less
audioread
Read audio fileide
Syntax
[y,Fs] = audioread(filename)
測試
[y,Fs] = audioread(filename,samples)
ui
[y,Fs] = audioread(___,dataType)
thisDescription
Examples
Input Arguments
Output Arguments
Limitations
For MP3, MPEG-4 AAC, and AVI audio files on Windows 7 or later and Linux platforms,
audioread
might read fewer samples than expected. On Windows 7 platforms, this is due to a limitation in the underlying Media Foundation framework. On Linux platforms, this is due to a limitation in the underlying GStreamer framework. If you require sample-accurate reading, work with WAV or FLAC files.On Linux platforms,
audioread
reads MPEG-4 AAC files that contain single-channel data as stereo data.
翻譯
調用結構&描述
[y, Fs] =audioread(filename)
從以「filename」爲文件名的文件中讀取數據,並返回抽樣數據y和此數據的抽樣率Fs 。
[y, Fs] =audioread(filename, samples)
以選定範圍從文件中讀取音頻樣本,其中 samples 是具備[start, finish]形式的向量。
[y, Fs] =audioread( ____, dataType)
返回數據域中與 dataType 相對應的採樣數據,dataType 可選「native(本地類型)」或「double(雙精度型)」。
例子
能夠本身從本地音樂裏面選擇音樂來測試。可是建議適當縮減音頻長度,否則計算量會比較大,有可能卡死電腦。剪輯音頻可使用「格式工廠」,它也能用來轉換文件格式。
輸入 一、對於輸入文件,表中給的信息已經很詳細了,".wav"格式的音頻是必定支持的,通用的".mp3"格式在win7以上及Linux系統上都是能夠讀取的。
二、 對於輸入參數 samples ,在第一種調用結構中實際上是隱藏了 [1, inf] 的默認samples參數,意思是從文件頭讀到文件尾。在第二種調用格式裏面咱們能夠指定讀取的參數範圍。要注意 start, finish 兩個參數都是正整數,並且他們的大小不能超出抽樣個數。這個很容易理解,超出了源文件的抽樣範圍就不可能有數據。在使用中,能夠用 [start, inf] 表示從 start 讀到文件尾。
注意:當在win7平臺上讀取MP3以及在Linux上讀取MP3&M4A格式文件時,可能會出現讀取範圍轉移的現象,這是因爲底層Windows Media Foundation框架的侷限性形成的。
三、dataType有兩種取值,native 或 double 。默認狀況下,native 爲單精度類型 single 。
輸出
y 爲音頻數據,是一個mxn 的矩陣,m是讀取文件的抽樣個數,n是讀取文件的音頻信道個數。
· 在未明確 dataType 和 dataType 取 double 時,y 的類型也是 double。y 的元素爲值介於-1.0和1.0之間的規範化值。
· 若是 dataType 取 native,y 能夠爲matlab所容許的幾種數據類型之一。至於爲哪種類型取決於輸入文件的類型,這種對應關係在上面給出的表中。
注意:當 y 爲單精度或雙精度數, 且 BitPerSample 爲32或64時,y 的值有可能超出 -1.0~1.0。
侷限
· 對於 MP3, MPEG-4 AAC, AVI音頻文件,在win7及更高版本和Linux平臺上,有可能會出現抽樣個數比預期要少的現象。
· 在Linux上讀取MPEG-4 AAC文件時,即便是單聲道數據文件,也會當成立體聲文件來讀。