20-音讯读写、录制与播放.PPT

  1. 1、本文档共46页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
20-音讯读写、录制与播放

非同步播放 在此例中,我們會聽到類似男女兩部合唱,一快一慢,這是因為 sound 指令的預設播放方式就是「非同步」。 範例20-13: playSync02.m load handel.mat sound(y, Fs); sound(y, 1.2*Fs); Playback Modes There are two playback modes Synchronous mode: Block everything till the end of playback. Asychronous mode: Nonblocking playSync01.m playSync02.m [y, fs]=audioread(welcome.wav); p=audioplayer(y, fs); playblocking(p); % Synchronous sound(y, 0.8*fs); % Asynchronous sound(y, 0.6*fs); % Asynchronous load handel.mat sound(y, Fs); sound(y, 1.2*Fs); 音量自動調整 另一個類似的指令是 soundsc,可針對音訊變數的數值先進行正規化(介於 –1 和 1 中間)後,再送到喇叭播放,以達到最好的播放效果。 soundsc01.m [y, fs]=audioread(welcome.wav); sound(y, fs); fprintf(Press any key to continue...\n); pause soundsc(y, fs); 在影像顯示方面,對應的命令是 imagesc。 Automatic Volume Adjustment “soundsc” adjusts the volume (by normalizing the signals to have max of 1 or min of -1) before playback soundsc01.m [y, fs]=audioread(welcome.wav); sound(y, fs); fprintf(Press any key to continue...\n); pause soundsc(y, fs); The corresponding command for image display is “imagesc”. 聲音訊號的錄製 我們在第一節已經說明了如何讀取音訊檔案,並在第二節說明如何播放。MATLAB 也支援直接由麥克風讀取訊號,因此可以直接進行聲音的錄製,所使用的指令是 audiorecorder recordblocking Recording of Audio Signals We can use the following MATLAB commands for recording from the microphone directly: audiorecorder recordblocking 音訊的錄製範例 (1/2) 使用預設參數,由麥克風進行3秒錄音: audioRecord01.m 預設錄音參數 取樣頻率為 8000 Hz 取樣點解析度為 8 bits 單聲道錄音 duration=3; % 錄音時間 recObj=audiorecorder; fprintf(按任意鍵後開始 %g 秒錄音:, duration); pause fprintf(錄音中...); recordblocking(recObj, duration); fprintf(錄音結束\n); fprintf(按任意鍵後開始播放:); pause play(recObj); Recording (1/2) Use default setting for 3-sec recording: audioRecord01.m Default settings for recording Sample rate: 8000 Hz Bit resolution: 8 bits Mono duration=3; % Duration of recording recObj=audiorecorder; fprintf(按任意鍵後開始 %g 秒錄音:, duration); pause % Prompt fprintf(錄音中...); % During recording recordblocking(recObj, duration); fprintf(錄音結束\n); % End of recording fprintf(按任意鍵後開始播放:); pause % Press any key for playback

文档评论(0)

youbika + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档