播放存储在独立存储中的大型录制音频文件
我正在使用 XNA 麦克风类录制音频,并将录制的数据以 wav 格式保存在独立存储中。
如果音频长度很短,我的应用程序工作正常。
但随着它增加消耗的内存应用程序的播放速度也会增加,这会大大减慢设备的速度。
以下代码用于播放音频
<代码>
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fileStream = isoStore.OpenFile(AudioFilePath, FileMode.Open))
{
sound = SoundEffect.FromStream(FileStream);
sound.Play();
}
}
关于如何在播放大型音频文件时处理内存问题的任何建议。或者我如何将 PCM 保存为其他格式(wma、mp3)以减小大小。
I am recording audio using the XNA Microphone class and saving the recorded data in isolated storage in wav format.
If the length of audio is small my app is working fine.
But as it increases the memory consumed by the app also increases,which drastically slows down the device.
The following code is used to play the audio
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SoundEffect
不适用于播放长音频。顾名思义,它适用于短曲,也可以同时演奏很多短曲。要播放较长的音频片段,您应该考虑
MediaElement
。SoundEffect
isn't intended for playing long pieces of audio. As the name suggests it is intended for short pieces and also playing lots of them, possibly at the same time.To play longer pieces of audio you shoudl consider the
MediaElement
.