×
Namespaces

Variants
Actions

如何获取音频文件的采样率和比特率信息

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

兼容于
文章
huwell 在 05 Dec 2007 创建
最后由 hamishwillee 在 06 May 2013 编辑
  • 详细描述

我们可以通过CMdaAudioRecorderUtility的DestinationSampleRateL()方法和DestinationBitRateL()方法获取音频格式的采样率和比特率信息。但作为例外,MP3编码的文件需要一些额外的处理。


  • 解决方案

下面的示例演示了如何从任意格式的音频中获取采样率和比特率,这里也包括MP3文件:

_LIT( KAudioFile, "c:\\system\\sample.mp3" );
 
CMdaAudioRecorderUtility* iUtility;
 
RMMFController iController;
 
iUtility->OpenFileL( KAudioFile );
 
// After successfully opening the file
 
TMMFPrioritySettings prioritySettings;
 
prioritySettings.iPriority = EMdaPriorityNormal;
 
prioritySettings.iPref = EMdaPriorityPreferenceTimeAndQuality;
 
const CMMFControllerImplementationInformation& impInfo =
 
iUtility->AudioPlayControllerImplementationInformationL();
 
 
 
iController.Open( impInfo.Uid(), prioritySettings );
 
TFileName filename;
 
filename.Copy(KAudioFile);
 
TMMFMessageDestination dataSource;
 
TMMFFileConfig sourceCfg;
 
sourceCfg().iPath = filename;
 
 
 
User::LeaveIfError( iController.AddDataSource(
 
KUidMmfFileSource,
 
sourceCfg,
 
dataSource) );
 
RMMFAudioControllerCustomCommands customCommands( iController );
 
TUint sampleRate = 0;
 
TUint bitRate = 0;
 
 
 
customCommands.GetSourceSampleRate( sampleRate );
 
customCommands.GetSourceBitRate( bitRate );
 
 
 
iController.Close();
This page was last modified on 6 May 2013, at 10:16.
59 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×