gpt4 book ai didi

iphone - iPhone 版 Soundtouch

转载 作者:行者123 更新时间:2023-12-03 19:01:38 25 4
gpt4 key购买 nike

有人能做到吗 http://www.surina.net/soundtouch/适用于 iPhone?

简单的 Xcode 演示会很有帮助。

我只想通过一些音调操作来播放音效。

谢谢克里斯

最佳答案

使用 SoundTouch 实现音频效果的最佳方法是同时使用 SoundStretch。

您可以从这里下载两者的源代码 http://www.surina.net/soundtouch/sourcecode.html

SoundStretch is a command-line program that performs SoundTouchlibrary effects on WAV audio files. The program is a source codeexample how SoundTouch library routines can be used to process soundin other programs, but it can be used as a stand-alone audioprocessing tool as well.

SoundStretch features:

  • Reads & writes .wav audio files
  • Allows very broad parameter adjustment ranges:
  • Tempo & Playback Rate adjustable in range -95% .. +5000%
  • The sound Pitch (key) adjustable in range -60 .. +60 semitones (+- 5 octaves).
  • Beats-Per-Second (BPM) detection that can adjust tempo to match with the desired BPM rate.
  • Full source codes available
  • Command-line interface allows using the SoundStretch utility for processing .wav audio files in batch mode
  • Supports processing .wav audio streams through standard input/output pipes
  • SoundStretch uses the SoundTouch library routines for the audio procesing.

使用示例:

NSArray *effects = [NSArray arrayWithObjects:@"-rate=-22", nil];
NSURL *audio = [self base:input output:output effects:effects];

哪里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;
}

如果您不想自己编译 SoundTouch,我已经共享了一个 GitHub 存储库,其中包含为 armv7 编译的库。 , armv7s , arm64 , i386x86_64

https://github.com/enrimr/soundtouch-ios-library

如果你想自己使用SoundTouch而不使用SoundStretch,你必须在你的Xcode项目中添加SoundTouch目录(其中包括libSoundTouch.a和带有头文件的目录)。

对于 SWIFT 项目:

使用 SWIFT 编程时,您无法导入 .h,因此您需要创建一个名为 <Your-Project-Name>-Bridging-Header-File.h 的 .h 文件。然后在项目build设置中引用它(在“Swift Compiler”下查找“Objective C Bridging Header”):

$(SRCROOT)/<Your-Project-Name>-Bridging-Header.h

现在您必须能够使用 SoundTouch 类。

对于 Objective-C 项目:

包含以下行

#include "SoundTouch.h" 

在你的 Controller 文件中。

实现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;
}

关于iphone - iPhone 版 Soundtouch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2258113/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com