有人能够做出
http://www.surina.net/soundtouch/
为iPhone工作?

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

我只想通过一些音调操纵来发挥音效。

谢谢
克里斯

最佳答案

使用SoundTouch来实现音频效果的最佳方法是也使用SoundStretch。
您可以从这里下载两者的源代码http://www.surina.net/soundtouch/sourcecode.html

使用示例:

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存储库共享了一个GitHub存储库,该库针对armv7armv7sarm64i386x86_64进行了编译
https://github.com/enrimr/soundtouch-ios-library
而且,如果您想不使用SoundStretch就自己使用SoundTouch,则必须在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/

10-13 03:43