2011-04-21 75 views
1


我正在使用XNA Microphone類錄製音頻,並以wav格式將錄製的數據保存在獨立存儲中。
如果音頻的長度很小,我的應用程序工作正常。
但隨着它增加應用程序消耗的內存也增加,這大大減慢了設備。
以下代碼用於播放音頻
播放存儲在獨立存儲器中的大型錄制音頻文件

using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()) 
      { 
       using (IsolatedStorageFileStream fileStream = isoStore.OpenFile(AudioFilePath, FileMode.Open)) 
       { 
        sound = SoundEffect.FromStream(FileStream); 
        sound.Play(); 
       } 
      } 


Any suggestion on how to handle the memory issue while playing large audio files.Or how can i save the PCM in other formats (wma,mp3) to reduce the size.

回答

2

SoundEffect不適用於播放長段音頻。顧名思義,它是用於短片,也可以同時播放很多片。

要播放更長的音頻片段,請考慮MediaElement

+0

+1。這很有趣,我不知道。你知道任何可能討論何時使用'SoundEffect'和何時使用'MediaElement'的資源嗎? – 2011-04-22 19:07:05

相關問題