规范化音频文件OBJ-C [英] Normalize Audio File obj-c

查看:219
本文介绍了规范化音频文件OBJ-C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个库函数正常化声音文件?我已经搜索周围,但找不到任何。

Is there a library function to normalize a sound file? I have searched around but could not find any.

我希望能够正常化声音文件和设置的成声音文件,因此只需要进行一次,而不是在飞行。

I would like to be able to normalize a sound file and setting that into the sound file so it only needs to be done once rather than on the fly.

这能与核心音频做了什么?

Can this be done with Core-Audio?

推荐答案

是的,这是可以做到的,但不是一个函数调用。

Yes it can be done, but not with a single function call.

您想要的功能其实也不是CoreAudio的,而是<一个href=\"https://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/ExtendedAudioFileServicesReference/Reference/reference.html\"相对=nofollow> ExtendedAudioFile.h - 的一部分,<一个href=\"https://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/CAAudioTooboxRef/_index.html#//apple_ref/doc/uid/TP40002089\"相对=nofollow> AudioToolbox 框架。这是适用于iOS和MacOSX的。我可以证明这是比较难找。

The functionality you want is not in fact CoreAudio, but rather in ExtendedAudioFile.h - part of the AudioToolbox framework. This is available for both iOS and MacOSX. I can attest for this being rather hard to find.

在这个头感兴趣的函数是 ExtAudioFileOpenURL() ExtAudioFileRead() ExtAudioFileWrite()

Functions of interest in this header are ExtAudioFileOpenURL(), ExtAudioFileRead() and ExtAudioFileWrite().

在轮廓你做什么:


  1. 使用 ExtAudioFileOpenURL()来打开输入文件

  2. 使用 ExtAudioFileGetProperty()与属性ID kExtAudioFileProperty_FileDataFormat 来获得<一个href=\"https://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/CoreAudioDataTypesRef/Reference/reference.html#//apple_ref/c/tdef/AudioStreamBasicDescription\"相对=nofollow> AudioStreamBasicDescription 描述文件。

  1. Use ExtAudioFileOpenURL() to open the input file
  2. Use ExtAudioFileGetProperty() with propertyId kExtAudioFileProperty_FileDataFormat to obtain an AudioStreamBasicDescription describing the file.

可能设置ASBD得到你想要的格式。 AudioToolBox MacOSX上似乎而非iOS上更适合于这一点。

Possibly set the ASBD to get the format you want. AudioToolBox on MacOSX seems rather more amenable to this than on iOS.

计算的分配大到足以容纳整个音频文件的缓冲区

Calculate an allocate a buffer large enough to hold the entire audio file

阅读与整个文件 ExtAudioFileRead() - 注:此调用可能不读这一切一气呵成 - 在大致相同的工作是为POSIX 阅读()

Read the entire file with ExtAudioFileRead() - NB: this call might not read it all in one go - operating in much the same was as POSIX read()

执行规范化

的文档链接到几个示例项目,可以为工作code捐助者采取行动。你会发现做归一化处理样品的花车容易得多,但在iOS上,我永远无法转换为自动工作,所以你可能需要格式转换自己。

The documentation links to several example projects that can act as donors of working code. You'll find doing normalisation much easier with the samples as floats, but in iOS, I could never get the conversion to work automatically, so you might have to format convert yourself.

这篇关于规范化音频文件OBJ-C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆