chr*_*ler 5 iphone audio core-audio
有人能够 为iPhone工作http://www.surina.net/soundtouch/吗?
简单的Xcode演示会很有帮助.
我只想用一些音调操作来发挥作用.
克里斯
使用SoundTouch实现音频效果的最佳方法是同时使用SoundStretch。
您可以从这里下载两者的源代码http://www.surina.net/soundtouch/sourcecode.html
SoundStretch 是一个命令行程序,可对 WAV 音频文件执行 SoundTouch 库效果。该程序是如何使用 SoundTouch 库例程在其他程序中处理声音的源代码示例,但它也可以用作独立的音频处理工具。
声音拉伸功能:
- 读取和写入
.wav音频文件- 允许非常宽的参数调整范围:
- 速度和播放速率可在 -95% .. +5000% 范围内调节
- 音高(调)可在 -60 .. +60 半音(+- 5 八度)范围内调节。
- 每秒节拍数 (BPM)检测,可以调整节奏以匹配所需的 BPM 速率。
- 提供完整的源代码
- 命令行界面允许使用SoundStretch
.wav实用程序以批处理模式处理音频文件- 支持
.wav通过标准输入/输出管道处理音频流- SoundStretch使用SoundTouch库例程进行音频处理。
使用示例:
NSArray *effects = [NSArray arrayWithObjects:@"-rate=-22", nil];
NSURL *audio = [self base:input output:output effects:effects];
Run Code Online (Sandbox Code Playgroud)
其中base:output:effects定义为:
- (NSURL *)base:(NSURL *)input output:(NSURL *)output effects:(NSArray *)effects{
int _argc = 3 + (int)[effects count];
const char *_argv[]={"createWavWithEffect",[[input path] UTF8String], [[output path] UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String],[@"" UTF8String]};
for (int i=0; i<[effects count]; i++) {
_argv[i+3] = [effects[i] UTF8String];
}
createWavWithEffect(_argc, _argv);
// IMPORTANT! Check the file size, maybe you will need to set by yourself
return output;
}
Run Code Online (Sandbox Code Playgroud)
如果您不想自己编译 SoundTouch,我已经共享了一个 GitHub 存储库,其中包含为armv7、armv7s、arm64和编译i386的库x86_64
https://github.com/enrimr/soundtouch-ios-library
如果您想自己使用 SoundTouch 而不使用 SoundStretch,则必须在 Xcode 项目中添加 SoundTouch 目录(其中包括 libSoundTouch.a 和带头文件的目录)。
对于 SWIFT 项目:
使用 SWIFT 编程,您无法导入 .h,因此您需要创建一个名为“ <Your-Project-Name>-Bridging-Header-File.h
Then”的 .h 文件,然后在项目构建设置中引用它(在“Swift 编译器”下查找“Objective C Bridging Header”):
$(SRCROOT)/<Your-Project-Name>-Bridging-Header.h
Run Code Online (Sandbox Code Playgroud)
现在您必须能够使用 SoundTouch 类。
对于 Objective-C 项目:
包括以下行
#include "SoundTouch.h"
Run Code Online (Sandbox Code Playgroud)
在你的控制器文件中。
实施createWavWithEffect:
int createWavWithEffect(const int nParams, const char * const paramStr[])
{
WavInFile *inFile;
WavOutFile *outFile;
RunParameters *params;
SoundTouch soundTouch;
fprintf(stderr, _helloText, SoundTouch::getVersionString());
try
{
// Parse command line parameters
params = new RunParameters(nParams, paramStr);
// Open input & output files
openFiles(&inFile, &outFile, params);
if (params->detectBPM == TRUE)
{
// detect sound BPM (and adjust processing parameters
// accordingly if necessary)
detectBPM(inFile, params);
}
// Setup the 'SoundTouch' object for processing the sound
setup(&soundTouch, inFile, params);
// clock_t cs = clock(); // for benchmarking processing duration
// Process the sound
process(&soundTouch, inFile, outFile);
// clock_t ce = clock(); // for benchmarking processing duration
// printf("duration: %lf\n", (double)(ce-cs)/CLOCKS_PER_SEC);
// Close WAV file handles & dispose of the objects
delete inFile;
delete outFile;
delete params;
fprintf(stderr, "Done!\n");
}
catch (const runtime_error &e)
{
// An exception occurred during processing, display an error message
fprintf(stderr, "%s\n", e.what());
return -1;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3035 次 |
| 最近记录: |